23 namespace std_ph = std::placeholders;
33 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Updating maneuver starting_lane_id to " << start_id);
36 case carma_planning_msgs::msg::Maneuver::LANE_CHANGE:
37 mvr.lane_change_maneuver.starting_lane_id =
std::to_string(start_id);
39 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT:
40 mvr.intersection_transit_straight_maneuver.starting_lane_id =
std::to_string(start_id);
42 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN:
43 mvr.intersection_transit_left_turn_maneuver.starting_lane_id =
std::to_string(start_id);
45 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN:
46 mvr.intersection_transit_right_turn_maneuver.starting_lane_id =
std::to_string(start_id);
48 case carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT:
49 mvr.stop_and_wait_maneuver.starting_lane_id =
std::to_string(start_id);
52 throw std::invalid_argument(
"Maneuver type does not have starting and ending lane ids");
62 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Updating maneuver ending_lane_id to " << end_id);
65 case carma_planning_msgs::msg::Maneuver::LANE_CHANGE:
68 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT:
69 mvr.intersection_transit_straight_maneuver.ending_lane_id =
std::to_string(end_id);
71 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN:
72 mvr.intersection_transit_left_turn_maneuver.ending_lane_id =
std::to_string(end_id);
74 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN:
75 mvr.intersection_transit_right_turn_maneuver.ending_lane_id =
std::to_string(end_id);
77 case carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT:
78 mvr.stop_and_wait_maneuver.ending_lane_id =
std::to_string(end_id);
81 throw std::invalid_argument(
"Maneuver type does not have starting and ending lane ids");
92 case carma_planning_msgs::msg::Maneuver::LANE_CHANGE:
93 return mvr.lane_change_maneuver.starting_lane_id;
94 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT:
95 return mvr.intersection_transit_straight_maneuver.starting_lane_id;
96 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN:
97 return mvr.intersection_transit_left_turn_maneuver.starting_lane_id;
98 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN:
99 return mvr.intersection_transit_right_turn_maneuver.starting_lane_id;
100 case carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT:
101 return mvr.stop_and_wait_maneuver.starting_lane_id;
103 throw std::invalid_argument(
"Maneuver type does not have starting and ending lane ids");
114 case carma_planning_msgs::msg::Maneuver::LANE_CHANGE:
115 return mvr.lane_change_maneuver.ending_lane_id;
116 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_STRAIGHT:
117 return mvr.intersection_transit_straight_maneuver.ending_lane_id;
118 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_LEFT_TURN:
119 return mvr.intersection_transit_left_turn_maneuver.ending_lane_id;
120 case carma_planning_msgs::msg::Maneuver::INTERSECTION_TRANSIT_RIGHT_TURN:
121 return mvr.intersection_transit_right_turn_maneuver.ending_lane_id;
122 case carma_planning_msgs::msg::Maneuver::STOP_AND_WAIT:
123 return mvr.stop_and_wait_maneuver.ending_lane_id;
125 throw std::invalid_argument(
"Maneuver type does not have starting and ending lane ids");
132 tf2_buffer_(this->get_clock()),
133 wml_(this->get_node_base_interface(), this->get_node_logging_interface(),
134 this->get_node_topics_interface(), this->get_node_parameters_interface())
161 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Done loading parameters: " <<
config_);
164 traj_pub_ = create_publisher<carma_planning_msgs::msg::TrajectoryPlan>(
"plan_trajectory", 5);
170 twist_sub_ = create_subscription<geometry_msgs::msg::TwistStamped>(
"current_velocity", 5,
171 [
this](geometry_msgs::msg::TwistStamped::UniquePtr twist) {this->
latest_twist_ = *twist;});
177 return CallbackReturn::SUCCESS;
185 return CallbackReturn::SUCCESS;
195 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Received request to delegate plan ID " << std::string(plan->maneuver_plan_id));
197 auto copy_plan = *plan;
202 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Received plan with " <<
latest_maneuver_plan_.maneuvers.size() <<
" maneuvers");
210 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Received empty plan, no maneuvers found in plan ID " << std::string(plan->maneuver_plan_id));
217 double current_downtrack =
wm_->routeTrackPos(current_loc).downtrack;
222 if(maneuver.type == carma_planning_msgs::msg::Maneuver::LANE_CHANGE){
223 if(current_downtrack >= maneuver.lane_change_maneuver.start_dist){
258 lane_change_information.
starting_downtrack = lane_change_maneuver.lane_change_maneuver.start_dist;
261 lanelet::ConstLanelet starting_lanelet =
wm_->getMap()->laneletLayer.get(std::stoi(lane_change_maneuver.lane_change_maneuver.starting_lane_id));
262 lanelet::ConstLanelet ending_lanelet =
wm_->getMap()->laneletLayer.get(std::stoi(lane_change_maneuver.lane_change_maneuver.ending_lane_id));
265 bool shared_boundary_found =
false;
267 lanelet::ConstLanelet current_lanelet = starting_lanelet;
269 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Searching for shared boundary with starting lanechange lanelet " <<
std::to_string(current_lanelet.id()) <<
" and ending lanelet " <<
std::to_string(ending_lanelet.id()));
270 while(!shared_boundary_found){
273 if(current_lanelet.leftBound() == ending_lanelet.rightBound()){
275 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Lanelet " <<
std::to_string(current_lanelet.id()) <<
" shares left boundary with " <<
std::to_string(ending_lanelet.id()));
277 shared_boundary_found =
true;
279 else if(current_lanelet.rightBound() == ending_lanelet.leftBound()){
281 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Lanelet " <<
std::to_string(current_lanelet.id()) <<
" shares right boundary with " <<
std::to_string(ending_lanelet.id()));
283 shared_boundary_found =
true;
287 if(
wm_->getMapRoutingGraph()->following(current_lanelet,
false).empty())
292 throw(std::invalid_argument(
"No following lanelets from current lanelet reachable without a lane change, incorrectly chosen end lanelet"));
295 current_lanelet =
wm_->getMapRoutingGraph()->following(current_lanelet,
false).front();
296 if(current_lanelet.id() == starting_lanelet.id()){
298 throw(std::invalid_argument(
"No lane change in path"));
300 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Now checking for shared lane boundary with lanelet " <<
std::to_string(current_lanelet.id()) <<
" and ending lanelet " <<
std::to_string(ending_lanelet.id()));
304 return lane_change_information;
309 carma_planning_msgs::msg::UpcomingLaneChangeStatus upcoming_lane_change_status;
312 if(upcoming_lane_change_information){
315 double current_downtrack =
wm_->routeTrackPos(current_loc).downtrack;
316 upcoming_lane_change_status.downtrack_until_lanechange = std::max(0.0, upcoming_lane_change_information.get().starting_downtrack - current_downtrack);
319 if(upcoming_lane_change_information.get().is_right_lane_change){
320 upcoming_lane_change_status.lane_change = carma_planning_msgs::msg::UpcomingLaneChangeStatus::RIGHT;
323 upcoming_lane_change_status.lane_change = carma_planning_msgs::msg::UpcomingLaneChangeStatus::LEFT;
327 upcoming_lane_change_status.lane_change = carma_planning_msgs::msg::UpcomingLaneChangeStatus::NONE;
337 void PlanDelegator::publishTurnSignalCommand(
const boost::optional<LaneChangeInformation>& current_lane_change_information,
const carma_planning_msgs::msg::UpcomingLaneChangeStatus& upcoming_lane_change_status)
341 autoware_msgs::msg::LampCmd turn_signal_command;
344 if(current_lane_change_information){
346 if(current_lane_change_information.get().is_right_lane_change){
347 turn_signal_command.r = 1;
350 turn_signal_command.l = 1;
354 else if(upcoming_lane_change_status.lane_change != carma_planning_msgs::msg::UpcomingLaneChangeStatus::NONE){
357 if(upcoming_lane_change_status.lane_change == carma_planning_msgs::msg::UpcomingLaneChangeStatus::RIGHT){
358 turn_signal_command.r = 1;
361 turn_signal_command.l = 1;
377 if(planner_name.size() == 0)
379 throw std::invalid_argument(
"Invalid trajectory planner name because it has zero length!");
383 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Discovered new trajectory planner: " << planner_name);
394 return !maneuver_plan.maneuvers.empty();
400 return !(trajectory_plan.trajectory_points.size() < 2);
407 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"current time:" <<
std::to_string(now().seconds()));
408 bool isexpired = rclcpp::Time(
GET_MANEUVER_PROPERTY(maneuver, end_time), get_clock()->get_clock_type()) <= current_time;
409 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"isexpired:" << isexpired);
414 std::shared_ptr<carma_planning_msgs::srv::PlanTrajectory::Request>
PlanDelegator::composePlanTrajectoryRequest(
const carma_planning_msgs::msg::TrajectoryPlan& latest_trajectory_plan,
const uint16_t& current_maneuver_index)
const
416 auto plan_req = std::make_shared<carma_planning_msgs::srv::PlanTrajectory::Request>();
420 if(latest_trajectory_plan.trajectory_points.empty())
423 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"latest_pose_.header.stamp: " <<
std::to_string(rclcpp::Time(
latest_pose_.header.stamp).seconds()));
424 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"plan_req->header.stamp: " <<
std::to_string(rclcpp::Time(plan_req->header.stamp).seconds()));
426 plan_req->vehicle_state.longitudinal_vel =
latest_twist_.twist.linear.x;
427 plan_req->vehicle_state.x_pos_global =
latest_pose_.pose.position.x;
428 plan_req->vehicle_state.y_pos_global =
latest_pose_.pose.position.y;
429 double roll, pitch, yaw;
431 plan_req->vehicle_state.orientation = yaw;
432 plan_req->maneuver_index_to_plan = current_maneuver_index;
437 carma_planning_msgs::msg::TrajectoryPlanPoint last_point = latest_trajectory_plan.trajectory_points.back();
438 carma_planning_msgs::msg::TrajectoryPlanPoint second_last_point = *(latest_trajectory_plan.trajectory_points.rbegin() + 1);
439 plan_req->vehicle_state.x_pos_global = last_point.x;
440 plan_req->vehicle_state.y_pos_global = last_point.y;
441 auto distance_diff = std::sqrt(std::pow(last_point.x - second_last_point.x, 2) + std::pow(last_point.y - second_last_point.y, 2));
442 rclcpp::Duration time_diff = rclcpp::Time(last_point.target_time) - rclcpp::Time(second_last_point.target_time);
443 auto time_diff_sec = time_diff.seconds();
444 plan_req->maneuver_index_to_plan = current_maneuver_index;
446 plan_req->header.stamp = latest_trajectory_plan.trajectory_points.back().target_time;
447 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"plan_req->header.stamp: " <<
std::to_string(rclcpp::Time(plan_req->header.stamp).seconds()));
449 plan_req->vehicle_state.longitudinal_vel = distance_diff / time_diff_sec;
457 rclcpp::Duration time_diff = rclcpp::Time(plan.trajectory_points.back().target_time) - rclcpp::Time(plan.trajectory_points.front().target_time);
458 return time_diff.seconds() >= config_.max_trajectory_duration;
465 RCLCPP_ERROR_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Map is not set yet");
472 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Changing maneuver distances for planner: " <<
GET_MANEUVER_PROPERTY(maneuver, parameters.planning_tactical_plugin));
474 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"original_start_dist:" << original_start_dist);
475 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"adjusted_start_dist:" << adjusted_start_dist);
477 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"original_end_dist:" << original_end_dist);
478 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"adjusted_end_dist:" << adjusted_end_dist);
484 if(maneuver.type == carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING && !maneuver.lane_following_maneuver.lane_ids.empty()){
488 lanelet::Id original_starting_lanelet_id = std::stoi(maneuver.lane_following_maneuver.lane_ids.front());
489 lanelet::ConstLanelet original_starting_lanelet =
wm_->getMap()->laneletLayer.get(original_starting_lanelet_id);
492 lanelet::BasicPoint2d original_starting_lanelet_centerline_start_point = lanelet::utils::to2D(original_starting_lanelet.centerline()).front();
493 double original_starting_lanelet_centerline_start_point_dt =
wm_->routeTrackPos(original_starting_lanelet_centerline_start_point).downtrack;
495 if(adjusted_start_dist < original_starting_lanelet_centerline_start_point_dt){
497 auto previous_lanelets =
wm_->getMapRoutingGraph()->previous(original_starting_lanelet,
false);
499 if(!previous_lanelets.empty()){
501 auto llt_on_route_optional =
wm_->getFirstLaneletOnShortestPath(previous_lanelets);
503 lanelet::ConstLanelet previous_lanelet_to_add;
505 if (llt_on_route_optional){
506 previous_lanelet_to_add = llt_on_route_optional.value();
509 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"When adjusting maneuver for lane follow, no previous lanelet found on the shortest path for lanelet "
510 << original_starting_lanelet.id() <<
". Picking arbitrary lanelet: " << previous_lanelets[0].id() <<
", instead");
511 previous_lanelet_to_add = previous_lanelets[0];
515 maneuver.lane_following_maneuver.lane_ids.insert(maneuver.lane_following_maneuver.lane_ids.begin(),
std::to_string(previous_lanelet_to_add.id()));
517 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Inserted lanelet " <<
std::to_string(previous_lanelet_to_add.id()) <<
" to beginning of maneuver.");
520 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"No previous lanelet was found for lanelet " << original_starting_lanelet.id());
525 lanelet::Id original_ending_lanelet_id = std::stoi(maneuver.lane_following_maneuver.lane_ids.back());
526 lanelet::ConstLanelet original_ending_lanelet =
wm_->getMap()->laneletLayer.get(original_ending_lanelet_id);
529 lanelet::BasicPoint2d original_ending_lanelet_centerline_start_point = lanelet::utils::to2D(original_ending_lanelet.centerline()).front();
530 double original_ending_lanelet_centerline_start_point_dt =
wm_->routeTrackPos(original_ending_lanelet_centerline_start_point).downtrack;
532 if(adjusted_end_dist < original_ending_lanelet_centerline_start_point_dt){
533 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Original ending lanelet " << original_ending_lanelet.id() <<
" removed from lane_ids since the updated maneuver no longer crosses it");
536 maneuver.lane_following_maneuver.lane_ids.pop_back();
539 else if (maneuver.type != carma_planning_msgs::msg::Maneuver::LANE_FOLLOWING){
544 lanelet::ConstLanelet original_starting_lanelet =
wm_->getMap()->laneletLayer.get(original_starting_lanelet_id);
547 lanelet::BasicPoint2d original_starting_lanelet_centerline_start_point = lanelet::utils::to2D(original_starting_lanelet.centerline()).front();
548 double original_starting_lanelet_centerline_start_point_dt =
wm_->routeTrackPos(original_starting_lanelet_centerline_start_point).downtrack;
550 if(adjusted_start_dist < original_starting_lanelet_centerline_start_point_dt){
551 auto previous_lanelets =
wm_->getMapRoutingGraph()->previous(original_starting_lanelet,
false);
552 if(!previous_lanelets.empty()){
553 auto llt_on_route_optional =
wm_->getFirstLaneletOnShortestPath(previous_lanelets);
554 lanelet::ConstLanelet previous_lanelet_to_add;
556 if (llt_on_route_optional){
557 previous_lanelet_to_add = llt_on_route_optional.value();
560 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"When adjusting non-lane follow maneuver, no previous lanelet found on the shortest path for lanelet "
561 << original_starting_lanelet.id() <<
". Picking arbitrary lanelet: " << previous_lanelets[0].id() <<
", instead");
562 previous_lanelet_to_add = previous_lanelets[0];
567 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"No previous lanelet was found for lanelet " << original_starting_lanelet.id());
573 lanelet::ConstLanelet original_ending_lanelet =
wm_->getMap()->laneletLayer.get(original_ending_lanelet_id);
576 lanelet::BasicPoint2d original_ending_lanelet_centerline_start_point = lanelet::utils::to2D(original_ending_lanelet.centerline()).front();
577 double original_ending_lanelet_centerline_start_point_dt =
wm_->routeTrackPos(original_ending_lanelet_centerline_start_point).downtrack;
579 if(adjusted_end_dist < original_ending_lanelet_centerline_start_point_dt){
580 auto previous_lanelets =
wm_->getMapRoutingGraph()->previous(original_ending_lanelet,
false);
582 if(!previous_lanelets.empty()){
586 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"No previous lanelet was found for lanelet " << original_starting_lanelet.id());
594 carma_planning_msgs::msg::TrajectoryPlan latest_trajectory_plan;
597 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Guidance is not engaged. Plan delegator will not plan trajectory.");
598 return latest_trajectory_plan;
602 bool first_trajectory_plan =
true;
605 uint16_t current_maneuver_index = 0;
616 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Dropping expired maneuver: " <<
GET_MANEUVER_PROPERTY(maneuver, parameters.maneuver_id));
618 ++current_maneuver_index;
622 double current_downtrack =
wm_->routeTrackPos(current_loc).downtrack;
623 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"current_downtrack" << current_downtrack);
625 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"maneuver_end_dist" << maneuver_end_dist);
628 if (current_downtrack > maneuver_end_dist)
630 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Dropping passed maneuver: " <<
GET_MANEUVER_PROPERTY(maneuver, parameters.maneuver_id));
632 ++current_maneuver_index;
642 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Current planner: " << maneuver_planner);
647 auto plan_response = client->async_send_request(plan_req);
652 if (future_status == std::future_status::ready)
657 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Found invalid trajectory with less than 2 trajectory points for " << std::string(
latest_maneuver_plan_.maneuver_plan_id));
661 if(latest_trajectory_plan.trajectory_points.size() !=0){
663 if(latest_trajectory_plan.trajectory_points.back().target_time == plan_response.get()->trajectory_plan.trajectory_points.front().target_time){
664 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Removing duplicate point for planner: " << maneuver_planner);
665 plan_response.get()->trajectory_plan.trajectory_points.erase(plan_response.get()->trajectory_plan.trajectory_points.begin());
666 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"plan_response.get()->trajectory_plan size: " << plan_response.get()->trajectory_plan.trajectory_points.size());
670 latest_trajectory_plan.trajectory_points.insert(latest_trajectory_plan.trajectory_points.end(),
671 plan_response.get()->trajectory_plan.trajectory_points.begin(),
672 plan_response.get()->trajectory_plan.trajectory_points.end());
673 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"new latest_trajectory_plan size: " << latest_trajectory_plan.trajectory_points.size());
676 if(first_trajectory_plan ==
true)
678 latest_trajectory_plan.initial_longitudinal_velocity = plan_response.get()->trajectory_plan.initial_longitudinal_velocity;
679 first_trajectory_plan =
false;
684 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Plan Trajectory completed for " << std::string(
latest_maneuver_plan_.maneuver_plan_id));
690 if(plan_response.get()->related_maneuvers.size() > 0)
692 current_maneuver_index = plan_response.get()->related_maneuvers.back() + 1;
697 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Unsuccessful service call to trajectory planner:" << maneuver_planner <<
" for plan ID " << std::string(
latest_maneuver_plan_.maneuver_plan_id));
703 return latest_trajectory_plan;
708 carma_planning_msgs::msg::TrajectoryPlan trajectory_plan =
planTrajectory();
713 trajectory_plan.header.stamp = get_clock()->now();
718 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"),
"Planned trajectory is empty. It will not be published!");
728 geometry_msgs::msg::TransformStamped tf =
tf2_buffer_.lookupTransform(
"base_link",
"vehicle_front", rclcpp::Time(0), rclcpp::Duration(20.0, 0));
730 RCLCPP_DEBUG_STREAM(rclcpp::get_logger(
"plan_delegator"),
"length_to_front_bumper_: " <<
length_to_front_bumper_);
733 catch (
const tf2::TransformException &ex)
735 RCLCPP_WARN_STREAM(rclcpp::get_logger(
"plan_delegator"), ex.what());
742#include "rclcpp_components/register_node_macro.hpp"
#define GET_MANEUVER_PROPERTY(mvr, property)
Macro definition to enable easier access to fields shared across the maneuver types.
WorldModelConstPtr getWorldModel()
Returns a pointer to an intialized world model instance.
void onTrajPlanTick()
Callback function for triggering trajectory planning.
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::GuidanceState > guidance_state_sub_
carma_planning_msgs::msg::TrajectoryPlan planTrajectory()
Plan trajectory based on latest maneuver plan via ROS service call to plugins.
LaneChangeInformation getLaneChangeInformation(const carma_planning_msgs::msg::Maneuver &lane_change_maneuver)
Function for generating a LaneChangeInformation object from a provided lane change maneuver.
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > getPlannerClientByName(const std::string &planner_name)
Get PlanTrajectory service client by plugin name and create new PlanTrajectory service client if spec...
void poseCallback(geometry_msgs::msg::PoseStamped::UniquePtr pose_msg)
Callback function for vehicle pose subscriber. Updates latest_pose_ and makes calls to publishUpcomin...
carma_wm::WorldModelConstPtr wm_
carma_ros2_utils::SubPtr< geometry_msgs::msg::TwistStamped > twist_sub_
carma_ros2_utils::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &)
boost::optional< LaneChangeInformation > upcoming_lane_change_information_
tf2_ros::Buffer tf2_buffer_
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::UpcomingLaneChangeStatus > upcoming_lane_change_status_pub_
carma_planning_msgs::msg::UpcomingLaneChangeStatus upcoming_lane_change_status_
bool isTrajectoryValid(const carma_planning_msgs::msg::TrajectoryPlan &trajectory_plan) const noexcept
Example if a trajectory plan contains at least two trajectory points.
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &)
std::shared_ptr< carma_planning_msgs::srv::PlanTrajectory::Request > composePlanTrajectoryRequest(const carma_planning_msgs::msg::TrajectoryPlan &latest_trajectory_plan, const uint16_t ¤t_maneuver_index) const
Generate new PlanTrajecory service request based on current planning progress.
bool isManeuverExpired(const carma_planning_msgs::msg::Maneuver &maneuver, rclcpp::Time current_time) const
Example if a maneuver end time has passed current system time.
void guidanceStateCallback(carma_planning_msgs::msg::GuidanceState::UniquePtr plan)
Callback function of guidance state subscriber.
void updateManeuverParameters(carma_planning_msgs::msg::Maneuver &maneuver)
Update the starting downtrack, ending downtrack, and maneuver-specific Lanelet ID parameters associat...
rclcpp::TimerBase::SharedPtr traj_timer_
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::ManeuverPlan > plan_sub_
bool isTrajectoryLongEnough(const carma_planning_msgs::msg::TrajectoryPlan &plan) const noexcept
Example if a trajectory plan is longer than configured time thresheld.
carma_planning_msgs::msg::ManeuverPlan latest_maneuver_plan_
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::TrajectoryPlan > traj_pub_
carma_ros2_utils::PubPtr< autoware_msgs::msg::LampCmd > turn_signal_command_pub_
std::unique_ptr< tf2_ros::TransformListener > tf2_listener_
boost::optional< LaneChangeInformation > current_lane_change_information_
std::unordered_map< std::string, carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > > trajectory_planners_
bool isManeuverPlanValid(const carma_planning_msgs::msg::ManeuverPlan &maneuver_plan) const noexcept
Example if a maneuver plan contains at least one maneuver.
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseStamped > pose_sub_
geometry_msgs::msg::TwistStamped latest_twist_
double length_to_front_bumper_
void lookupFrontBumperTransform()
Lookup transfrom from front bumper to base link.
geometry_msgs::msg::PoseStamped latest_pose_
PlanDelegator(const rclcpp::NodeOptions &)
PlanDelegator constructor.
void maneuverPlanCallback(carma_planning_msgs::msg::ManeuverPlan::UniquePtr plan)
Callback function of maneuver plan subscriber.
autoware_msgs::msg::LampCmd latest_turn_signal_command_
void publishTurnSignalCommand(const boost::optional< LaneChangeInformation > ¤t_lane_change_information, const carma_planning_msgs::msg::UpcomingLaneChangeStatus &upcoming_lane_change_status)
Function for processing an optional LaneChangeInformation object pertaining to the currently-occurrin...
void publishUpcomingLaneChangeStatus(const boost::optional< LaneChangeInformation > &upcoming_lane_change_information)
Function for processing an optional LaneChangeInformation object pertaining to an upcoming lane chang...
carma_wm::WMListener wml_
auto to_string(const UtmZone &zone) -> std::string
void rpyFromQuaternion(const tf2::Quaternion &q, double &roll, double &pitch, double &yaw)
Extract extrinsic roll-pitch-yaw from quaternion.
std::string getManeuverEndingLaneletId(carma_planning_msgs::msg::Maneuver mvr)
Anonymous function to get the ending lanelet id for all maneuver types except lane following....
void setManeuverEndingLaneletId(carma_planning_msgs::msg::Maneuver &mvr, lanelet::Id end_id)
Anonymous function to set the ending_lane_id for all maneuver types except lane following....
std::string getManeuverStartingLaneletId(carma_planning_msgs::msg::Maneuver mvr)
Anonymous function to get the starting lanelet id for all maneuver types except lane following....
void setManeuverStartingLaneletId(carma_planning_msgs::msg::Maneuver &mvr, lanelet::Id start_id)
Anonymous function to set the starting_lane_id for all maneuver types except lane following....
#define SET_MANEUVER_PROPERTY(mvr, property, value)
double trajectory_planning_rate
std::string planning_topic_suffix
std::string planning_topic_prefix
int tactical_plugin_service_call_timeout
double duration_to_signal_before_lane_change
double max_trajectory_duration