15 #ifndef TRAFFIC_SIMULATOR__TEST__HELPER_FUNCTIONS_HPP_
16 #define TRAFFIC_SIMULATOR__TEST__HELPER_FUNCTIONS_HPP_
18 #include <ament_index_cpp/get_package_share_directory.hpp>
23 #include <traffic_simulator_msgs/msg/entity_subtype.hpp>
24 #include <traffic_simulator_msgs/msg/entity_type.hpp>
29 constexpr
auto convertDegToRad(
const double deg) ->
double {
return deg / 180.0 * M_PI; }
30 constexpr
auto convertRadToDeg(
const double rad) ->
double {
return rad * 180.0 / M_PI; }
32 auto makePoint(
const double x,
const double y,
const double z = 0.0) -> geometry_msgs::msg::Point
34 return geometry_msgs::build<geometry_msgs::msg::Point>().x(x).y(y).z(z);
37 auto makeBoundingBox(
const double center_y = 0.0) -> traffic_simulator_msgs::msg::BoundingBox
39 return traffic_simulator_msgs::build<traffic_simulator_msgs::msg::BoundingBox>()
41 .dimensions(geometry_msgs::build<geometry_msgs::msg::Vector3>().x(4.0).y(2.0).z(1.5));
45 const double x,
const double y,
const double x_offset = 0.0,
const double y_offset = 0.0)
46 -> traffic_simulator_msgs::msg::BoundingBox
48 return traffic_simulator_msgs::build<traffic_simulator_msgs::msg::BoundingBox>()
49 .center(geometry_msgs::build<geometry_msgs::msg::Point>().x(x_offset).y(y_offset).z(0.0))
50 .dimensions(geometry_msgs::build<geometry_msgs::msg::Vector3>().x(x).y(y).z(0.0));
55 return traffic_simulator_msgs::build<traffic_simulator_msgs::msg::BoundingBox>()
57 .dimensions(geometry_msgs::build<geometry_msgs::msg::Vector3>().x(1.0).y(1.0).z(1.0));
63 geometry_msgs::build<geometry_msgs::msg::Vector3>().x(0.0).y(0.0).z(yaw));
66 auto makePose(
const double x,
const double y,
const double z,
const double yaw_deg)
67 -> geometry_msgs::msg::Pose
72 return geometry_msgs::build<geometry_msgs::msg::Pose>()
73 .position(geometry_msgs::build<geometry_msgs::msg::Point>().x(x).y(y).z(z))
75 geometry_msgs::build<geometry_msgs::msg::Vector3>().x(0.0).y(0.0).z(
80 geometry_msgs::msg::Point position,
81 geometry_msgs::msg::Quaternion orientation = geometry_msgs::msg::Quaternion())
82 -> geometry_msgs::msg::Pose
84 return geometry_msgs::build<geometry_msgs::msg::Pose>().position(position).orientation(
90 return std::make_shared<hdmap_utils::HdMapUtils>(
91 ament_index_cpp::get_package_share_directory(
"traffic_simulator") +
92 "/map/standard_map/lanelet2_map.osm",
93 geographic_msgs::build<geographic_msgs::msg::GeoPoint>()
94 .latitude(35.9037067912303)
95 .longitude(139.9337945139059)
100 std::shared_ptr<hdmap_utils::HdMapUtils>
hdmap_utils,
const lanelet::Id
id = 120659,
101 const double s = 0.0,
const double offset = 0.0)
109 std::shared_ptr<hdmap_utils::HdMapUtils>
hdmap_utils,
111 traffic_simulator_msgs::msg::BoundingBox bbox,
const double speed = 0.0,
113 const uint8_t type = traffic_simulator_msgs::msg::EntityType::VEHICLE)
116 return traffic_simulator_msgs::build<traffic_simulator::EntityStatus>()
117 .type(traffic_simulator_msgs::build<traffic_simulator_msgs::msg::EntityType>().type(type))
118 .subtype(traffic_simulator_msgs::build<traffic_simulator_msgs::msg::EntitySubtype>().value(
119 traffic_simulator_msgs::msg::EntitySubtype::UNKNOWN))
126 .lanelet_pose_valid(
true);
130 std::shared_ptr<hdmap_utils::HdMapUtils> , geometry_msgs::msg::Pose pose,
131 traffic_simulator_msgs::msg::BoundingBox bbox,
const double speed = 0.0,
133 const uint8_t type = traffic_simulator_msgs::msg::EntityType::VEHICLE)
136 return traffic_simulator_msgs::build<traffic_simulator::EntityStatus>()
137 .type(traffic_simulator_msgs::build<traffic_simulator_msgs::msg::EntityType>().type(type))
138 .subtype(traffic_simulator_msgs::build<traffic_simulator_msgs::msg::EntitySubtype>().value(
139 traffic_simulator_msgs::msg::EntitySubtype::UNKNOWN))
146 .lanelet_pose_valid(
false);
150 std::shared_ptr<hdmap_utils::HdMapUtils>
hdmap_utils,
152 traffic_simulator_msgs::msg::BoundingBox bbox,
const double speed = 0.0,
154 const uint8_t type = traffic_simulator_msgs::msg::EntityType::VEHICLE)
159 canonicalized_lanelet_pose);
163 std::shared_ptr<hdmap_utils::HdMapUtils>
hdmap_utils, geometry_msgs::msg::Pose pose,
164 traffic_simulator_msgs::msg::BoundingBox bbox,
const double matching_distance = 1.0,
165 const double speed = 0.0,
const std::string name =
"default_entity_name",
166 const uint8_t type = traffic_simulator_msgs::msg::EntityType::VEHICLE)
169 const auto include_crosswalk =
170 (traffic_simulator_msgs::msg::EntityType::PEDESTRIAN == type ||
171 traffic_simulator_msgs::msg::EntityType::MISC_OBJECT == type);
173 pose, bbox, include_crosswalk, matching_distance,
hdmap_utils);
Definition: entity_status.hpp:32
Definition: lanelet_pose.hpp:27
auto convertEulerAngleToQuaternion(const T &v)
Definition: euler_to_quaternion.hpp:30
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
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
auto toCanonicalizedLaneletPose(const geometry_msgs::msg::Pose &map_pose, const bool include_crosswalk, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> std::optional< CanonicalizedLaneletPose >
Definition: pose.cpp:77
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22
traffic_simulator_msgs::msg::EntityStatus EntityStatus
Definition: entity_status.hpp:25
std::string string
Definition: junit5.hpp:26
traffic_simulator::lanelet_pose::CanonicalizedLaneletPose CanonicalizedLaneletPose
Definition: test_lanelet_pose.cpp:21
auto makeSmallBoundingBox(const double center_y=0.0) -> traffic_simulator_msgs::msg::BoundingBox
Definition: helper_functions.hpp:53
auto makeHdMapUtilsSharedPointer() -> std::shared_ptr< hdmap_utils::HdMapUtils >
Definition: helper_functions.hpp:88
auto makeEntityStatus(std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils, traffic_simulator::lanelet_pose::CanonicalizedLaneletPose pose, traffic_simulator_msgs::msg::BoundingBox bbox, const double speed=0.0, const std::string name="default_entity_name", const uint8_t type=traffic_simulator_msgs::msg::EntityType::VEHICLE) -> traffic_simulator::EntityStatus
Definition: helper_functions.hpp:108
auto makeBoundingBox(const double center_y=0.0) -> traffic_simulator_msgs::msg::BoundingBox
Definition: helper_functions.hpp:37
auto makePoint(const double x, const double y, const double z=0.0) -> geometry_msgs::msg::Point
Definition: helper_functions.hpp:32
auto makeQuaternionFromYaw(const double yaw) -> geometry_msgs::msg::Quaternion
Definition: helper_functions.hpp:60
auto makeCanonicalizedEntityStatus(std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils, traffic_simulator::lanelet_pose::CanonicalizedLaneletPose canonicalized_lanelet_pose, traffic_simulator_msgs::msg::BoundingBox bbox, const double speed=0.0, const std::string name="default_entity_name", const uint8_t type=traffic_simulator_msgs::msg::EntityType::VEHICLE) -> traffic_simulator::entity_status::CanonicalizedEntityStatus
Definition: helper_functions.hpp:149
auto makeCustom2DBoundingBox(const double x, const double y, const double x_offset=0.0, const double y_offset=0.0) -> traffic_simulator_msgs::msg::BoundingBox
Definition: helper_functions.hpp:44
constexpr auto convertDegToRad(const double deg) -> double
Definition: helper_functions.hpp:29
auto makePose(const double x, const double y, const double z, const double yaw_deg) -> geometry_msgs::msg::Pose
Definition: helper_functions.hpp:66
auto makeCanonicalizedLaneletPose(std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils, const lanelet::Id id=120659, const double s=0.0, const double offset=0.0) -> traffic_simulator::lanelet_pose::CanonicalizedLaneletPose
Definition: helper_functions.hpp:99
constexpr auto convertRadToDeg(const double rad) -> double
Definition: helper_functions.hpp:30