Skip to content

Commit 1749d66

Browse files
committed
improve velocity factors
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent d070c1d commit 1749d66

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

planning/motion_velocity_planner/motion_velocity_out_of_lane_module/src/out_of_lane_module.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ void OutOfLaneModule::init(rclcpp::Node & node, const std::string & module_name)
5656
node.create_publisher<visualization_msgs::msg::MarkerArray>("~/" + ns_ + "/debug_markers", 1);
5757
virtual_wall_publisher_ =
5858
node.create_publisher<visualization_msgs::msg::MarkerArray>("~/" + ns_ + "/virtual_walls", 1);
59-
velocity_factor_publisher_ =
60-
node.create_publisher<autoware_adapi_v1_msgs::msg::VelocityFactorArray>(
61-
std::string("/planning/velocity_factors/") + ns_, 1);
6259
}
6360
void OutOfLaneModule::init_parameters(rclcpp::Node & node)
6461
{
@@ -196,7 +193,7 @@ VelocityPlanningResult OutOfLaneModule::plan(
196193
if (overlapped_lanelet_it != other_lanelets.end()) {
197194
debug_data_.current_overlapped_lanelets.push_back(*overlapped_lanelet_it);
198195
RCLCPP_DEBUG(logger_, "Ego is already overlapping a lane, skipping the module\n");
199-
return result; // TODO(Maxime): properly populate the result
196+
return result;
200197
}
201198
}
202199
// Calculate overlapping ranges
@@ -296,7 +293,7 @@ VelocityPlanningResult OutOfLaneModule::plan(
296293
virtual_wall_marker_creator.add_virtual_walls(
297294
out_of_lane::debug::create_virtual_walls(debug_data_, params_));
298295
virtual_wall_publisher_->publish(virtual_wall_marker_creator.create_markers(clock_->now()));
299-
velocity_factor_publisher_->publish(velocity_factor_interface_.get_array(clock_->now()));
296+
result.velocity_factor = velocity_factor_interface_.get();
300297
return result;
301298
}
302299

planning/motion_velocity_planner/motion_velocity_planner_common/include/motion_velocity_planner_common/plugin_module_interface.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class PluginModuleInterface
4444
rclcpp::Logger logger_ = rclcpp::get_logger("");
4545
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr debug_publisher_;
4646
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr virtual_wall_publisher_;
47-
rclcpp::Publisher<autoware_adapi_v1_msgs::msg::VelocityFactorArray>::SharedPtr
48-
velocity_factor_publisher_;
4947
motion_utils::VirtualWallMarkerCreator virtual_wall_marker_creator{};
5048
};
5149

planning/motion_velocity_planner/motion_velocity_planner_common/include/motion_velocity_planner_common/velocity_planning_result.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <motion_utils/marker/virtual_wall_marker_creator.hpp>
1919

20+
#include <autoware_adapi_v1_msgs/msg/velocity_factor.hpp>
2021
#include <geometry_msgs/msg/point.hpp>
2122
#include <visualization_msgs/msg/marker_array.hpp>
2223

@@ -40,6 +41,7 @@ struct VelocityPlanningResult
4041
{
4142
std::vector<geometry_msgs::msg::Point> stop_points{};
4243
std::vector<SlowdownInterval> slowdown_intervals{};
44+
autoware_adapi_v1_msgs::msg::VelocityFactor velocity_factor{};
4345
};
4446
} // namespace motion_velocity_planner
4547

planning/motion_velocity_planner/motion_velocity_planner_node/src/node.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ MotionVelocityPlannerNode::MotionVelocityPlannerNode(const rclcpp::NodeOptions &
152152
// Publishers
153153
trajectory_pub_ =
154154
this->create_publisher<autoware_auto_planning_msgs::msg::Trajectory>("~/output/trajectory", 1);
155+
velocity_factor_publisher_ =
156+
this->create_publisher<autoware_adapi_v1_msgs::msg::VelocityFactorArray>(
157+
"~/output/velocity_factors", 1);
155158

156159
// Parameters
157160
planner_data_.stop_line_extend_length = declare_parameter<double>("stop_line_extend_length");
@@ -402,6 +405,10 @@ autoware_auto_planning_msgs::msg::Trajectory MotionVelocityPlannerNode::generate
402405
smoothed_trajectory_points, std::make_shared<const PlannerData>(planner_data_));
403406

404407
autoware_auto_planning_msgs::msg::Trajectory output_trajectory_msg = input_trajectory_msg;
408+
autoware_adapi_v1_msgs::msg::VelocityFactorArray velocity_factors;
409+
velocity_factors.header.frame_id = "map";
410+
velocity_factors.header.stamp = get_clock()->now();
411+
405412
for (const auto & planning_result : planning_results) {
406413
for (const auto & stop_point : planning_result.stop_points) {
407414
const auto seg_idx =
@@ -426,8 +433,10 @@ autoware_auto_planning_msgs::msg::Trajectory MotionVelocityPlannerNode::generate
426433
RCLCPP_WARN(get_logger(), "Failed to insert slowdown points");
427434
}
428435
}
436+
velocity_factors.factors.push_back(planning_result.velocity_factor);
429437
}
430438

439+
velocity_factor_publisher_->publish(velocity_factors);
431440
return output_trajectory_msg;
432441
}
433442

planning/motion_velocity_planner/motion_velocity_planner_node/src/node.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class MotionVelocityPlannerNode : public rclcpp::Node
9090
// publishers
9191
rclcpp::Publisher<autoware_auto_planning_msgs::msg::Trajectory>::SharedPtr trajectory_pub_;
9292
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr debug_viz_pub_;
93+
rclcpp::Publisher<autoware_adapi_v1_msgs::msg::VelocityFactorArray>::SharedPtr
94+
velocity_factor_publisher_;
9395

9496
// parameters
9597
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr set_param_callback_;

0 commit comments

Comments
 (0)