Skip to content

Commit 594fc7b

Browse files
feat(autonomous_emergency_braking): add virtual stop wall to aeb (autowarefoundation#7894)
* add virtual stop wall to aeb Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> * add maintainer Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> * add uppercase Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> * use motion utils function instead of shiftPose Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> --------- Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
1 parent a195768 commit 594fc7b

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

control/autoware_autonomous_emergency_braking/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ When vehicle odometry information is faulty, it is possible that the MPC fails t
192192

193193
| Name | Unit | Type | Description | Default value |
194194
| :-------------------------------- | :----- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ |
195+
| publish_debug_markers | [-] | bool | flag to publish debug markers | true |
195196
| publish_debug_pointcloud | [-] | bool | flag to publish the point cloud used for debugging | false |
196197
| use_predicted_trajectory | [-] | bool | flag to use the predicted path from the control module | true |
197198
| use_imu_path | [-] | bool | flag to use the predicted path generated by sensor data | true |

control/autoware_autonomous_emergency_braking/config/autonomous_emergency_braking.param.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Debug
1616
publish_debug_pointcloud: false
17+
publish_debug_markers: true
1718

1819
# Point cloud partitioning
1920
detection_range_min_height: 0.0

control/autoware_autonomous_emergency_braking/include/autoware/autonomous_emergency_braking/node.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class AEB : public rclcpp::Node
329329

330330
// member variables
331331
bool publish_debug_pointcloud_;
332+
bool publish_debug_markers_;
332333
bool use_predicted_trajectory_;
333334
bool use_imu_path_;
334335
bool use_pointcloud_data_;

control/autoware_autonomous_emergency_braking/include/autoware/autonomous_emergency_braking/utils.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
3434
#endif
3535

36-
#include <vector>
37-
3836
namespace autoware::motion::control::autonomous_emergency_braking::utils
3937
{
4038
using autoware::universe_utils::Polygon2d;

control/autoware_autonomous_emergency_braking/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<maintainer email="tomoya.kimura@tier4.jp">Tomoya Kimura</maintainer>
99
<maintainer email="mamoru.sobue@tier4.jp">Mamoru Sobue</maintainer>
1010
<maintainer email="daniel.sanchez@tier4.jp">Daniel Sanchez</maintainer>
11+
<maintainer email="kyoichi.sugahara@tier4.jp">Kyoichi Sugahara</maintainer>
1112

1213
<license>Apache License 2.0</license>
1314

control/autoware_autonomous_emergency_braking/src/node.cpp

+36-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <autoware/autonomous_emergency_braking/node.hpp>
1616
#include <autoware/autonomous_emergency_braking/utils.hpp>
17+
#include <autoware/motion_utils/marker/marker_helper.hpp>
1718
#include <autoware/universe_utils/geometry/boost_geometry.hpp>
1819
#include <autoware/universe_utils/geometry/boost_polygon_utils.hpp>
1920
#include <autoware/universe_utils/geometry/geometry.hpp>
@@ -41,7 +42,9 @@
4142
#include <tf2/utils.h>
4243

4344
#include <cmath>
45+
#include <functional>
4446
#include <limits>
47+
#include <optional>
4548
#ifdef ROS_DISTRO_GALACTIC
4649
#include <tf2_eigen/tf2_eigen.h>
4750
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
@@ -131,6 +134,7 @@ AEB::AEB(const rclcpp::NodeOptions & node_options)
131134
}
132135
// parameter
133136
publish_debug_pointcloud_ = declare_parameter<bool>("publish_debug_pointcloud");
137+
publish_debug_markers_ = declare_parameter<bool>("publish_debug_markers");
134138
use_predicted_trajectory_ = declare_parameter<bool>("use_predicted_trajectory");
135139
use_imu_path_ = declare_parameter<bool>("use_imu_path");
136140
use_pointcloud_data_ = declare_parameter<bool>("use_pointcloud_data");
@@ -182,6 +186,7 @@ rcl_interfaces::msg::SetParametersResult AEB::onParameter(
182186
{
183187
using autoware::universe_utils::updateParam;
184188
updateParam<bool>(parameters, "publish_debug_pointcloud", publish_debug_pointcloud_);
189+
updateParam<bool>(parameters, "publish_debug_markers", publish_debug_markers_);
185190
updateParam<bool>(parameters, "use_predicted_trajectory", use_predicted_trajectory_);
186191
updateParam<bool>(parameters, "use_imu_path", use_imu_path_);
187192
updateParam<bool>(parameters, "use_pointcloud_data", use_pointcloud_data_);
@@ -378,7 +383,9 @@ void AEB::onCheckCollision(DiagnosticStatusWrapper & stat)
378383
stat.addf("RSS", "%.2f", data.rss);
379384
stat.addf("Distance", "%.2f", data.distance_to_object);
380385
stat.addf("Object Speed", "%.2f", data.velocity);
381-
addCollisionMarker(data, debug_markers);
386+
if (publish_debug_markers_) {
387+
addCollisionMarker(data, debug_markers);
388+
}
382389
} else {
383390
const std::string error_msg = "[AEB]: No Collision";
384391
const auto diag_level = DiagnosticStatus::OK;
@@ -455,7 +462,7 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
455462
});
456463

457464
// Add debug markers
458-
{
465+
if (publish_debug_markers_) {
459466
const auto [color_r, color_g, color_b, color_a] = debug_colors;
460467
addMarker(
461468
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
896903
autoware::universe_utils::createMarkerColor(1.0, 0.0, 0.0, 0.3));
897904
point_marker.pose.position = data.position;
898905
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+
}
899933
}
900934

901935
} // namespace autoware::motion::control::autonomous_emergency_braking

0 commit comments

Comments
 (0)