|
14 | 14 |
|
15 | 15 | #include <autoware/autonomous_emergency_braking/node.hpp>
|
16 | 16 | #include <autoware/autonomous_emergency_braking/utils.hpp>
|
| 17 | +#include <autoware/motion_utils/marker/marker_helper.hpp> |
17 | 18 | #include <autoware/universe_utils/geometry/boost_geometry.hpp>
|
18 | 19 | #include <autoware/universe_utils/geometry/boost_polygon_utils.hpp>
|
19 | 20 | #include <autoware/universe_utils/geometry/geometry.hpp>
|
|
41 | 42 | #include <tf2/utils.h>
|
42 | 43 |
|
43 | 44 | #include <cmath>
|
| 45 | +#include <functional> |
44 | 46 | #include <limits>
|
| 47 | +#include <optional> |
45 | 48 | #ifdef ROS_DISTRO_GALACTIC
|
46 | 49 | #include <tf2_eigen/tf2_eigen.h>
|
47 | 50 | #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
|
@@ -131,6 +134,7 @@ AEB::AEB(const rclcpp::NodeOptions & node_options)
|
131 | 134 | }
|
132 | 135 | // parameter
|
133 | 136 | publish_debug_pointcloud_ = declare_parameter<bool>("publish_debug_pointcloud");
|
| 137 | + publish_debug_markers_ = declare_parameter<bool>("publish_debug_markers"); |
134 | 138 | use_predicted_trajectory_ = declare_parameter<bool>("use_predicted_trajectory");
|
135 | 139 | use_imu_path_ = declare_parameter<bool>("use_imu_path");
|
136 | 140 | use_pointcloud_data_ = declare_parameter<bool>("use_pointcloud_data");
|
@@ -182,6 +186,7 @@ rcl_interfaces::msg::SetParametersResult AEB::onParameter(
|
182 | 186 | {
|
183 | 187 | using autoware::universe_utils::updateParam;
|
184 | 188 | updateParam<bool>(parameters, "publish_debug_pointcloud", publish_debug_pointcloud_);
|
| 189 | + updateParam<bool>(parameters, "publish_debug_markers", publish_debug_markers_); |
185 | 190 | updateParam<bool>(parameters, "use_predicted_trajectory", use_predicted_trajectory_);
|
186 | 191 | updateParam<bool>(parameters, "use_imu_path", use_imu_path_);
|
187 | 192 | updateParam<bool>(parameters, "use_pointcloud_data", use_pointcloud_data_);
|
@@ -378,7 +383,9 @@ void AEB::onCheckCollision(DiagnosticStatusWrapper & stat)
|
378 | 383 | stat.addf("RSS", "%.2f", data.rss);
|
379 | 384 | stat.addf("Distance", "%.2f", data.distance_to_object);
|
380 | 385 | stat.addf("Object Speed", "%.2f", data.velocity);
|
381 |
| - addCollisionMarker(data, debug_markers); |
| 386 | + if (publish_debug_markers_) { |
| 387 | + addCollisionMarker(data, debug_markers); |
| 388 | + } |
382 | 389 | } else {
|
383 | 390 | const std::string error_msg = "[AEB]: No Collision";
|
384 | 391 | const auto diag_level = DiagnosticStatus::OK;
|
@@ -455,7 +462,7 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
|
455 | 462 | });
|
456 | 463 |
|
457 | 464 | // Add debug markers
|
458 |
| - { |
| 465 | + if (publish_debug_markers_) { |
459 | 466 | const auto [color_r, color_g, color_b, color_a] = debug_colors;
|
460 | 467 | addMarker(
|
461 | 468 | this->get_clock()->now(), path, ego_polys, objects, closest_object_point, color_r, color_g,
|
@@ -896,6 +903,33 @@ void AEB::addCollisionMarker(const ObjectData & data, MarkerArray & debug_marker
|
896 | 903 | autoware::universe_utils::createMarkerColor(1.0, 0.0, 0.0, 0.3));
|
897 | 904 | point_marker.pose.position = data.position;
|
898 | 905 | debug_markers.markers.push_back(point_marker);
|
| 906 | + |
| 907 | + const auto ego_map_pose = std::invoke([this]() -> std::optional<geometry_msgs::msg::Pose> { |
| 908 | + geometry_msgs::msg::TransformStamped tf_current_pose; |
| 909 | + geometry_msgs::msg::Pose p; |
| 910 | + try { |
| 911 | + tf_current_pose = tf_buffer_.lookupTransform( |
| 912 | + "map", "base_link", rclcpp::Time(0), rclcpp::Duration::from_seconds(1.0)); |
| 913 | + } catch (tf2::TransformException & ex) { |
| 914 | + RCLCPP_ERROR(get_logger(), "%s", ex.what()); |
| 915 | + return std::nullopt; |
| 916 | + } |
| 917 | + |
| 918 | + p.orientation = tf_current_pose.transform.rotation; |
| 919 | + p.position.x = tf_current_pose.transform.translation.x; |
| 920 | + p.position.y = tf_current_pose.transform.translation.y; |
| 921 | + p.position.z = tf_current_pose.transform.translation.z; |
| 922 | + return std::make_optional(p); |
| 923 | + }); |
| 924 | + |
| 925 | + if (ego_map_pose.has_value()) { |
| 926 | + const double base_to_front_offset = vehicle_info_.max_longitudinal_offset_m; |
| 927 | + const auto ego_front_pose = autoware::universe_utils::calcOffsetPose( |
| 928 | + ego_map_pose.value(), base_to_front_offset, 0.0, 0.0, 0.0); |
| 929 | + const auto virtual_stop_wall = autoware::motion_utils::createStopVirtualWallMarker( |
| 930 | + ego_front_pose, "autonomous_emergency_braking", this->now(), 0); |
| 931 | + autoware::universe_utils::appendMarkerArray(virtual_stop_wall, &debug_markers); |
| 932 | + } |
899 | 933 | }
|
900 | 934 |
|
901 | 935 | } // namespace autoware::motion::control::autonomous_emergency_braking
|
|
0 commit comments