Skip to content

Commit 0dfdafe

Browse files
takayuki5168kyoichi-sugahara
authored andcommitted
feat(pid_longitudinal_controller): add virtual wall for dry steering and emergency (autowarefoundation#9685)
* feat(pid_longitudinal_controller): add virtual wall for dry steering and emergency Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> --------- Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 0374878 commit 0dfdafe

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

control/autoware_pid_longitudinal_controller/include/autoware/pid_longitudinal_controller/pid_longitudinal_controller.hpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@
5050

5151
namespace autoware::motion::control::pid_longitudinal_controller
5252
{
53-
using autoware::universe_utils::createDefaultMarker;
54-
using autoware::universe_utils::createMarkerColor;
55-
using autoware::universe_utils::createMarkerScale;
5653
using autoware_adapi_v1_msgs::msg::OperationModeState;
57-
using visualization_msgs::msg::Marker;
54+
using visualization_msgs::msg::MarkerArray;
5855

5956
namespace trajectory_follower = ::autoware::motion::control::trajectory_follower;
6057

@@ -103,7 +100,7 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
103100
// ros variables
104101
rclcpp::Publisher<tier4_debug_msgs::msg::Float32MultiArrayStamped>::SharedPtr m_pub_slope;
105102
rclcpp::Publisher<tier4_debug_msgs::msg::Float32MultiArrayStamped>::SharedPtr m_pub_debug;
106-
rclcpp::Publisher<Marker>::SharedPtr m_pub_stop_reason_marker;
103+
rclcpp::Publisher<MarkerArray>::SharedPtr m_pub_virtual_wall_marker;
107104

108105
rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr m_set_param_res;
109106
rcl_interfaces::msg::SetParametersResult paramCallback(

control/autoware_pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

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

1515
#include "autoware/pid_longitudinal_controller/pid_longitudinal_controller.hpp"
1616

17+
#include "autoware/motion_utils/marker/marker_helper.hpp"
1718
#include "autoware/motion_utils/trajectory/trajectory.hpp"
1819
#include "autoware/universe_utils/geometry/geometry.hpp"
1920
#include "autoware/universe_utils/math/normalization.hpp"
@@ -215,7 +216,7 @@ PidLongitudinalController::PidLongitudinalController(
215216
"~/output/slope_angle", rclcpp::QoS{1});
216217
m_pub_debug = node.create_publisher<tier4_debug_msgs::msg::Float32MultiArrayStamped>(
217218
"~/output/longitudinal_diagnostic", rclcpp::QoS{1});
218-
m_pub_stop_reason_marker = node.create_publisher<Marker>("~/output/stop_reason", rclcpp::QoS{1});
219+
m_pub_virtual_wall_marker = node.create_publisher<MarkerArray>("~/virtual_wall", 1);
219220

220221
// set parameter callback
221222
m_set_param_res = node.add_on_set_parameters_callback(
@@ -521,8 +522,8 @@ PidLongitudinalController::ControlData PidLongitudinalController::getControlData
521522

522523
// distance to stopline
523524
control_data.stop_dist = longitudinal_utils::calcStopDistance(
524-
control_data.interpolated_traj.points.at(control_data.nearest_idx).pose,
525-
control_data.interpolated_traj, m_ego_nearest_dist_threshold, m_ego_nearest_yaw_threshold);
525+
current_pose, control_data.interpolated_traj, m_ego_nearest_dist_threshold,
526+
m_ego_nearest_yaw_threshold);
526527

527528
// pitch
528529
// NOTE: getPitchByTraj() calculates the pitch angle as defined in
@@ -576,6 +577,11 @@ PidLongitudinalController::Motion PidLongitudinalController::calcEmergencyCtrlCm
576577
longitudinal_utils::applyDiffLimitFilter(raw_ctrl_cmd.acc, m_prev_raw_ctrl_cmd.acc, dt, p.jerk);
577578
m_debug_values.setValues(DebugValues::TYPE::ACC_CMD_JERK_LIMITED, raw_ctrl_cmd.acc);
578579

580+
const auto virtual_wall_marker = autoware::motion_utils::createStopVirtualWallMarker(
581+
m_current_kinematic_state.pose.pose, "velocity control\n (emergency)", clock_->now(), 0,
582+
m_wheel_base + m_front_overhang);
583+
m_pub_virtual_wall_marker->publish(virtual_wall_marker);
584+
579585
return raw_ctrl_cmd;
580586
}
581587

@@ -740,14 +746,12 @@ void PidLongitudinalController::updateControlState(const ControlData & control_d
740746
}
741747

742748
// publish debug marker
743-
auto marker = createDefaultMarker(
744-
"map", clock_->now(), "stop_reason", 0, Marker::TEXT_VIEW_FACING,
745-
createMarkerScale(0.0, 0.0, 1.0), createMarkerColor(1.0, 1.0, 1.0, 0.999));
746-
marker.pose = autoware::universe_utils::calcOffsetPose(
747-
m_current_kinematic_state.pose.pose, m_wheel_base + m_front_overhang,
748-
m_vehicle_width / 2 + 2.0, 1.5);
749-
marker.text = "steering not\nconverged";
750-
m_pub_stop_reason_marker->publish(marker);
749+
if (is_under_control) {
750+
const auto virtual_wall_marker = autoware::motion_utils::createStopVirtualWallMarker(
751+
m_current_kinematic_state.pose.pose, "velocity control\n(steering not converged)",
752+
clock_->now(), 0, m_wheel_base + m_front_overhang);
753+
m_pub_virtual_wall_marker->publish(virtual_wall_marker);
754+
}
751755

752756
// keep STOPPED
753757
return;

0 commit comments

Comments
 (0)