Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
|
#include <plan_delegator.hpp>
Public Member Functions | |
PlanDelegator (const rclcpp::NodeOptions &) | |
PlanDelegator constructor. More... | |
void | maneuverPlanCallback (carma_planning_msgs::msg::ManeuverPlan::UniquePtr plan) |
Callback function of maneuver plan subscriber. More... | |
void | guidanceStateCallback (carma_planning_msgs::msg::GuidanceState::UniquePtr plan) |
Callback function of guidance state subscriber. More... | |
void | poseCallback (geometry_msgs::msg::PoseStamped::UniquePtr pose_msg) |
Callback function for vehicle pose subscriber. Updates latest_pose_ and makes calls to publishUpcomingLaneChangeStatus() and publishTurnSignalCommand(). More... | |
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 specified name does not exist. More... | |
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. More... | |
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. More... | |
void | lookupFrontBumperTransform () |
Lookup transfrom from front bumper to base link. More... | |
void | updateManeuverParameters (carma_planning_msgs::msg::Maneuver &maneuver) |
Update the starting downtrack, ending downtrack, and maneuver-specific Lanelet ID parameters associated with a given maneuver. These updates are required since the starting and ending downtrack values of each maneuver are shifted based on the distance between the base_link frame and the vehicle_front frame. More... | |
carma_ros2_utils::CallbackReturn | handle_on_configure (const rclcpp_lifecycle::State &) |
carma_ros2_utils::CallbackReturn | handle_on_activate (const rclcpp_lifecycle::State &) |
Static Public Attributes | |
static const constexpr double | MILLISECOND_TO_SECOND = 0.001 |
Protected Attributes | |
Config | config_ |
std::unordered_map< std::string, carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > > | trajectory_planners_ |
carma_planning_msgs::msg::ManeuverPlan | latest_maneuver_plan_ |
geometry_msgs::msg::PoseStamped | latest_pose_ |
geometry_msgs::msg::TwistStamped | latest_twist_ |
carma_wm::WMListener | wml_ |
carma_wm::WorldModelConstPtr | wm_ |
Private Member Functions | |
void | onTrajPlanTick () |
Callback function for triggering trajectory planning. More... | |
bool | isManeuverPlanValid (const carma_planning_msgs::msg::ManeuverPlan &maneuver_plan) const noexcept |
Example if a maneuver plan contains at least one maneuver. More... | |
bool | isTrajectoryValid (const carma_planning_msgs::msg::TrajectoryPlan &trajectory_plan) const noexcept |
Example if a trajectory plan contains at least two trajectory points. More... | |
bool | isTrajectoryLongEnough (const carma_planning_msgs::msg::TrajectoryPlan &plan) const noexcept |
Example if a trajectory plan is longer than configured time thresheld. More... | |
carma_planning_msgs::msg::TrajectoryPlan | planTrajectory () |
Plan trajectory based on latest maneuver plan via ROS service call to plugins. More... | |
LaneChangeInformation | getLaneChangeInformation (const carma_planning_msgs::msg::Maneuver &lane_change_maneuver) |
Function for generating a LaneChangeInformation object from a provided lane change maneuver. More... | |
void | publishUpcomingLaneChangeStatus (const boost::optional< LaneChangeInformation > &upcoming_lane_change_information) |
Function for processing an optional LaneChangeInformation object pertaining to an upcoming lane change. If not empty, an UpcomingLaneChangeStatus message is created and published based on the contents of the LaneChangeInformation. The published UpcomingLaneChangeStatus message is stored in upcoming_lane_change_status_. More... | |
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-occurring lane change and an UpcomingLaneChangeStatus message. If the optional object pertaining to the currently-occurring lane change is not empty, then a turn signal command is published based on the current lane change direction. Otherwise, a turn signal command in the direction of the UpcomingLaneChangeStatus message is published if the vehicle is estimated to begin that lane change in under the time threshold defined by config_.duration_to_signal_before_lane_change. The published TurnSignalComand message is stored in latest_turn_signal_command_. More... | |
FRIEND_TEST (TestPlanDelegator, UnitTestPlanDelegator) | |
FRIEND_TEST (TestPlanDelegator, TestPlanDelegator) | |
FRIEND_TEST (TestPlanDelegator, TestLaneChangeInformation) | |
FRIEND_TEST (TestPlanDelegator, TestUpcomingLaneChangeAndTurnSignals) | |
FRIEND_TEST (TestPlanDelegator, TestUpdateManeuverParameters) | |
Private Attributes | |
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::TrajectoryPlan > | traj_pub_ |
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::UpcomingLaneChangeStatus > | upcoming_lane_change_status_pub_ |
carma_ros2_utils::PubPtr< autoware_msgs::msg::LampCmd > | turn_signal_command_pub_ |
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::ManeuverPlan > | plan_sub_ |
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseStamped > | pose_sub_ |
carma_ros2_utils::SubPtr< geometry_msgs::msg::TwistStamped > | twist_sub_ |
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::GuidanceState > | guidance_state_sub_ |
rclcpp::TimerBase::SharedPtr | traj_timer_ |
bool | guidance_engaged = false |
double | length_to_front_bumper_ = 3.0 |
tf2_ros::Buffer | tf2_buffer_ |
std::unique_ptr< tf2_ros::TransformListener > | tf2_listener_ |
boost::optional< LaneChangeInformation > | upcoming_lane_change_information_ |
boost::optional< LaneChangeInformation > | current_lane_change_information_ |
carma_planning_msgs::msg::UpcomingLaneChangeStatus | upcoming_lane_change_status_ |
autoware_msgs::msg::LampCmd | latest_turn_signal_command_ |
Definition at line 106 of file plan_delegator.hpp.
|
explicit |
PlanDelegator constructor.
Definition at line 131 of file plan_delegator.cpp.
References config_, plan_delegator::Config::duration_to_signal_before_lane_change, plan_delegator::Config::max_trajectory_duration, plan_delegator::Config::min_crawl_speed, plan_delegator::Config::planning_topic_prefix, plan_delegator::Config::planning_topic_suffix, plan_delegator::Config::tactical_plugin_service_call_timeout, and plan_delegator::Config::trajectory_planning_rate.
std::shared_ptr< carma_planning_msgs::srv::PlanTrajectory::Request > plan_delegator::PlanDelegator::composePlanTrajectoryRequest | ( | const carma_planning_msgs::msg::TrajectoryPlan & | latest_trajectory_plan, |
const uint16_t & | current_maneuver_index | ||
) | const |
Generate new PlanTrajecory service request based on current planning progress.
Definition at line 414 of file plan_delegator.cpp.
References latest_maneuver_plan_, latest_pose_, latest_twist_, carma_wm::geometry::rpyFromQuaternion(), and carma_cooperative_perception::to_string().
Referenced by planTrajectory().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Function for generating a LaneChangeInformation object from a provided lane change maneuver.
lane_change_maneuver | The lane change maneuver that a LaneChangeInformation object shall be generated from. |
Definition at line 255 of file plan_delegator.cpp.
References plan_delegator::LaneChangeInformation::is_right_lane_change, plan_delegator::LaneChangeInformation::starting_downtrack, carma_cooperative_perception::to_string(), and wm_.
Referenced by maneuverPlanCallback().
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > plan_delegator::PlanDelegator::getPlannerClientByName | ( | const std::string & | planner_name | ) |
Get PlanTrajectory service client by plugin name and create new PlanTrajectory service client if specified name does not exist.
Definition at line 375 of file plan_delegator.cpp.
References config_, plan_delegator::Config::planning_topic_prefix, plan_delegator::Config::planning_topic_suffix, and trajectory_planners_.
Referenced by planTrajectory().
void plan_delegator::PlanDelegator::guidanceStateCallback | ( | carma_planning_msgs::msg::GuidanceState::UniquePtr | plan | ) |
Callback function of guidance state subscriber.
Definition at line 188 of file plan_delegator.cpp.
References lightbar_manager::ENGAGED, and guidance_engaged.
Referenced by handle_on_configure().
carma_ros2_utils::CallbackReturn plan_delegator::PlanDelegator::handle_on_activate | ( | const rclcpp_lifecycle::State & | ) |
Definition at line 180 of file plan_delegator.cpp.
References config_, onTrajPlanTick(), traj_timer_, and plan_delegator::Config::trajectory_planning_rate.
carma_ros2_utils::CallbackReturn plan_delegator::PlanDelegator::handle_on_configure | ( | const rclcpp_lifecycle::State & | ) |
Definition at line 148 of file plan_delegator.cpp.
References config_, plan_delegator::Config::duration_to_signal_before_lane_change, carma_wm::WMListener::getWorldModel(), guidance_state_sub_, guidanceStateCallback(), latest_twist_, lookupFrontBumperTransform(), maneuverPlanCallback(), plan_delegator::Config::max_trajectory_duration, plan_delegator::Config::min_crawl_speed, plan_sub_, plan_delegator::Config::planning_topic_prefix, plan_delegator::Config::planning_topic_suffix, pose_sub_, poseCallback(), plan_delegator::Config::tactical_plugin_service_call_timeout, traj_pub_, plan_delegator::Config::trajectory_planning_rate, turn_signal_command_pub_, twist_sub_, upcoming_lane_change_status_pub_, wm_, and wml_.
bool plan_delegator::PlanDelegator::isManeuverExpired | ( | const carma_planning_msgs::msg::Maneuver & | maneuver, |
rclcpp::Time | current_time | ||
) | const |
Example if a maneuver end time has passed current system time.
Definition at line 403 of file plan_delegator.cpp.
References GET_MANEUVER_PROPERTY, and carma_cooperative_perception::to_string().
Referenced by planTrajectory().
|
privatenoexcept |
Example if a maneuver plan contains at least one maneuver.
Definition at line 391 of file plan_delegator.cpp.
Referenced by maneuverPlanCallback().
|
privatenoexcept |
Example if a trajectory plan is longer than configured time thresheld.
Definition at line 455 of file plan_delegator.cpp.
Referenced by planTrajectory().
|
privatenoexcept |
Example if a trajectory plan contains at least two trajectory points.
Definition at line 397 of file plan_delegator.cpp.
Referenced by onTrajPlanTick(), and planTrajectory().
void plan_delegator::PlanDelegator::lookupFrontBumperTransform | ( | ) |
Lookup transfrom from front bumper to base link.
Definition at line 722 of file plan_delegator.cpp.
References length_to_front_bumper_, tf2_buffer_, and tf2_listener_.
Referenced by handle_on_configure().
void plan_delegator::PlanDelegator::maneuverPlanCallback | ( | carma_planning_msgs::msg::ManeuverPlan::UniquePtr | plan | ) |
Callback function of maneuver plan subscriber.
Definition at line 193 of file plan_delegator.cpp.
References current_lane_change_information_, getLaneChangeInformation(), isManeuverPlanValid(), latest_maneuver_plan_, latest_pose_, upcoming_lane_change_information_, updateManeuverParameters(), and wm_.
Referenced by handle_on_configure().
|
private |
Callback function for triggering trajectory planning.
Definition at line 706 of file plan_delegator.cpp.
References isTrajectoryValid(), planTrajectory(), and traj_pub_.
Referenced by handle_on_activate().
|
private |
Plan trajectory based on latest maneuver plan via ROS service call to plugins.
Definition at line 592 of file plan_delegator.cpp.
References composePlanTrajectoryRequest(), config_, GET_MANEUVER_PROPERTY, getPlannerClientByName(), guidance_engaged, isManeuverExpired(), isTrajectoryLongEnough(), isTrajectoryValid(), latest_maneuver_plan_, latest_pose_, plan_delegator::Config::tactical_plugin_service_call_timeout, and wm_.
Referenced by onTrajPlanTick().
void plan_delegator::PlanDelegator::poseCallback | ( | geometry_msgs::msg::PoseStamped::UniquePtr | pose_msg | ) |
Callback function for vehicle pose subscriber. Updates latest_pose_ and makes calls to publishUpcomingLaneChangeStatus() and publishTurnSignalCommand().
pose_msg | The received pose message. |
Definition at line 244 of file plan_delegator.cpp.
References current_lane_change_information_, latest_pose_, publishTurnSignalCommand(), publishUpcomingLaneChangeStatus(), upcoming_lane_change_information_, and upcoming_lane_change_status_.
Referenced by handle_on_configure().
|
private |
Function for processing an optional LaneChangeInformation object pertaining to the currently-occurring lane change and an UpcomingLaneChangeStatus message. If the optional object pertaining to the currently-occurring lane change is not empty, then a turn signal command is published based on the current lane change direction. Otherwise, a turn signal command in the direction of the UpcomingLaneChangeStatus message is published if the vehicle is estimated to begin that lane change in under the time threshold defined by config_.duration_to_signal_before_lane_change. The published TurnSignalComand message is stored in latest_turn_signal_command_.
current_lane_change_information | An optional LaneChangeInformation object pertaining to the current lane change. Empty if vehicle is not currently changing lanes. |
upcoming_lane_change_status | An UpcomingLaneChangeStatus message containing the lane change direction of an upcoming lane change, along with the downtrack distance to that lane change. |
Definition at line 337 of file plan_delegator.cpp.
References config_, plan_delegator::Config::duration_to_signal_before_lane_change, latest_turn_signal_command_, latest_twist_, and turn_signal_command_pub_.
Referenced by poseCallback().
|
private |
Function for processing an optional LaneChangeInformation object pertaining to an upcoming lane change. If not empty, an UpcomingLaneChangeStatus message is created and published based on the contents of the LaneChangeInformation. The published UpcomingLaneChangeStatus message is stored in upcoming_lane_change_status_.
upcoming_lane_change_information | An optional LaneChangeInformation object. Empty if no upcoming lane change exists. |
Definition at line 307 of file plan_delegator.cpp.
References latest_pose_, upcoming_lane_change_status_, upcoming_lane_change_status_pub_, and wm_.
Referenced by poseCallback().
void plan_delegator::PlanDelegator::updateManeuverParameters | ( | carma_planning_msgs::msg::Maneuver & | maneuver | ) |
Update the starting downtrack, ending downtrack, and maneuver-specific Lanelet ID parameters associated with a given maneuver. These updates are required since the starting and ending downtrack values of each maneuver are shifted based on the distance between the base_link frame and the vehicle_front frame.
maneuver | The maneuver to be updated. |
Definition at line 461 of file plan_delegator.cpp.
References GET_MANEUVER_PROPERTY, plan_delegator::anonymous_namespace{plan_delegator.cpp}::getManeuverEndingLaneletId(), plan_delegator::anonymous_namespace{plan_delegator.cpp}::getManeuverStartingLaneletId(), length_to_front_bumper_, SET_MANEUVER_PROPERTY, plan_delegator::anonymous_namespace{plan_delegator.cpp}::setManeuverEndingLaneletId(), plan_delegator::anonymous_namespace{plan_delegator.cpp}::setManeuverStartingLaneletId(), carma_cooperative_perception::to_string(), and wm_.
Referenced by maneuverPlanCallback().
|
protected |
Definition at line 176 of file plan_delegator.hpp.
Referenced by PlanDelegator(), getPlannerClientByName(), handle_on_activate(), handle_on_configure(), planTrajectory(), and publishTurnSignalCommand().
|
private |
Definition at line 215 of file plan_delegator.hpp.
Referenced by maneuverPlanCallback(), and poseCallback().
|
private |
Definition at line 203 of file plan_delegator.hpp.
Referenced by guidanceStateCallback(), and planTrajectory().
|
private |
Definition at line 199 of file plan_delegator.hpp.
Referenced by handle_on_configure().
|
protected |
Definition at line 181 of file plan_delegator.hpp.
Referenced by composePlanTrajectoryRequest(), maneuverPlanCallback(), and planTrajectory().
|
protected |
Definition at line 182 of file plan_delegator.hpp.
Referenced by composePlanTrajectoryRequest(), maneuverPlanCallback(), planTrajectory(), poseCallback(), and publishUpcomingLaneChangeStatus().
|
private |
Definition at line 221 of file plan_delegator.hpp.
Referenced by publishTurnSignalCommand().
|
protected |
Definition at line 183 of file plan_delegator.hpp.
Referenced by composePlanTrajectoryRequest(), handle_on_configure(), and publishTurnSignalCommand().
|
private |
Definition at line 205 of file plan_delegator.hpp.
Referenced by lookupFrontBumperTransform(), and updateManeuverParameters().
|
staticconstexpr |
Definition at line 111 of file plan_delegator.hpp.
|
private |
Definition at line 196 of file plan_delegator.hpp.
Referenced by handle_on_configure().
|
private |
Definition at line 197 of file plan_delegator.hpp.
Referenced by handle_on_configure().
|
private |
Definition at line 208 of file plan_delegator.hpp.
Referenced by lookupFrontBumperTransform().
|
private |
Definition at line 209 of file plan_delegator.hpp.
Referenced by lookupFrontBumperTransform().
|
private |
Definition at line 191 of file plan_delegator.hpp.
Referenced by handle_on_configure(), and onTrajPlanTick().
|
private |
Definition at line 201 of file plan_delegator.hpp.
Referenced by handle_on_activate().
|
protected |
Definition at line 179 of file plan_delegator.hpp.
Referenced by getPlannerClientByName().
|
private |
Definition at line 193 of file plan_delegator.hpp.
Referenced by handle_on_configure(), and publishTurnSignalCommand().
|
private |
Definition at line 198 of file plan_delegator.hpp.
Referenced by handle_on_configure().
|
private |
Definition at line 212 of file plan_delegator.hpp.
Referenced by maneuverPlanCallback(), and poseCallback().
|
private |
Definition at line 218 of file plan_delegator.hpp.
Referenced by poseCallback(), and publishUpcomingLaneChangeStatus().
|
private |
Definition at line 192 of file plan_delegator.hpp.
Referenced by handle_on_configure(), and publishUpcomingLaneChangeStatus().
|
protected |
Definition at line 187 of file plan_delegator.hpp.
Referenced by getLaneChangeInformation(), handle_on_configure(), maneuverPlanCallback(), planTrajectory(), publishUpcomingLaneChangeStatus(), and updateManeuverParameters().
|
protected |
Definition at line 186 of file plan_delegator.hpp.
Referenced by handle_on_configure().