15 #ifndef TRAFFIC_SIMULATOR__HELPER__HELPER_HPP_
16 #define TRAFFIC_SIMULATOR__HELPER__HELPER_HPP_
18 #include <simulation_api_schema.pb.h>
22 #include <geometry_msgs/msg/pose.hpp>
23 #include <geometry_msgs/msg/quaternion.hpp>
24 #include <geometry_msgs/msg/vector3.hpp>
28 #include <traffic_simulator_msgs/msg/action_status.hpp>
29 #include <traffic_simulator_msgs/msg/lanelet_pose.hpp>
30 #include <unordered_set>
47 double linear_vel = 0,
double angular_vel = 0,
double linear_accel = 0,
double angular_accel = 0);
61 lanelet::Id lanelet_id,
double s,
double offset = 0,
double roll = 0,
double pitch = 0,
74 lanelet::Id lanelet_id,
double s,
double offset,
90 lanelet::Id lanelet_id,
double s,
double offset,
double roll,
double pitch,
double yaw,
101 geometry_msgs::msg::Vector3
constructRPY(
double roll = 0,
double pitch = 0,
double yaw = 0);
123 double x,
double y,
double z,
double roll,
double pitch,
double yaw);
131 template <
typename T>
134 std::vector<T> output_vector(input_vector);
136 std::unordered_set<T> unique_values;
137 auto empty_elements_start = std::remove_if(
138 output_vector.begin(), output_vector.end(),
139 [&unique_values](T
const & element) { return !unique_values.insert(element).second; });
140 output_vector.erase(empty_elements_start, output_vector.end());
142 return output_vector;
149 const double lidar_sensor_delay = 0,
const double horizontal_resolution = 1.0 / 180.0 * M_PI);
153 const double range = 300.0,
const bool detect_all_objects_in_range =
false,
154 const double pos_noise_stddev = 0,
const int random_seed = 0,
155 const double probability_of_lost = 0,
const double object_recognition_delay = 0,
156 const double object_recognition_ground_truth_delay = 0);
162 std::ostream &
operator<<(std::ostream & os,
const geometry_msgs::msg::Point & point);
164 std::ostream &
operator<<(std::ostream & os,
const geometry_msgs::msg::Vector3 & vector);
166 std::ostream &
operator<<(std::ostream & os,
const geometry_msgs::msg::Quaternion & quat);
168 std::ostream &
operator<<(std::ostream & os,
const geometry_msgs::msg::Pose & pose);
170 template <
typename T>
171 auto operator+(
const std::vector<T> & v0,
const std::vector<T> & v1) -> decltype(
auto)
174 result.reserve(v0.size() + v1.size());
175 result.insert(result.end(), v1.begin(), v1.end());
179 template <
typename T>
180 auto operator+=(std::vector<T> & v0,
const std::vector<T> & v1) -> decltype(
auto)
182 v0.reserve(v0.size() + v1.size());
183 v0.insert(v0.end(), v1.begin(), v1.end());
187 template <
typename T>
190 std::vector<T> ret = data;
191 std::sort(ret.begin(), ret.end());
192 ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
std::ostream & operator<<(std::ostream &os, const traffic_simulator::LaneletPose &ll_pose)
Definition: helper.cpp:192
auto operator+(const std::vector< T > &v0, const std::vector< T > &v1) -> decltype(auto)
Definition: helper.hpp:171
auto operator+=(std::vector< T > &v0, const std::vector< T > &v1) -> decltype(auto)
Definition: helper.hpp:180
auto sortAndUnique(const std::vector< T > &data) -> std::vector< T >
Definition: helper.hpp:188
geometry_msgs::msg::Vector3 constructRPY(double roll=0, double pitch=0, double yaw=0)
helper function for constructing rpy
Definition: helper.cpp:77
auto constructCanonicalizedLaneletPose(lanelet::Id lanelet_id, double s, double offset, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> CanonicalizedLaneletPose
helper function for constructing canonicalized lanelet pose
Definition: helper.cpp:70
geometry_msgs::msg::Pose constructPose(double x, double y, double z, double roll, double pitch, double yaw)
helper function for constructing pose
Definition: helper.cpp:91
const simulation_api_schema::LidarConfiguration constructLidarConfiguration(const LidarType type, const std::string &entity, const std::string &architecture_type, const double lidar_sensor_delay=0, const double horizontal_resolution=1.0/180.0 *M_PI)
Definition: helper.cpp:122
std::vector< T > getUniqueValues(const std::vector< T > &input_vector)
helper function for creating vector without duplicates, with preserved order
Definition: helper.hpp:132
const simulation_api_schema::DetectionSensorConfiguration constructDetectionSensorConfiguration(const std::string &entity, const std::string &architecture_type, const double update_duration, const double range=300.0, const bool detect_all_objects_in_range=false, const double pos_noise_stddev=0, const int random_seed=0, const double probability_of_lost=0, const double object_recognition_delay=0, const double object_recognition_ground_truth_delay=0)
Definition: helper.cpp:102
geometry_msgs::msg::Vector3 constructRPYfromQuaternion(geometry_msgs::msg::Quaternion quaternion)
helper function for constructing rpy
Definition: helper.cpp:86
traffic_simulator_msgs::msg::ActionStatus constructActionStatus(double linear_vel=0, double angular_vel=0, double linear_accel=0, double angular_accel=0)
helper function for constructing action status
Definition: helper.cpp:25
LidarType
Definition: helper.hpp:145
LaneletPose constructLaneletPose(lanelet::Id lanelet_id, double s, double offset=0, double roll=0, double pitch=0, double yaw=0)
helper function for constructing lanelet pose
Definition: helper.cpp:40
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22
std::string string
Definition: junit5.hpp:26
traffic_simulator::lanelet_pose::CanonicalizedLaneletPose CanonicalizedLaneletPose
Definition: test_lanelet_pose.cpp:21