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.
|
Class containing primary business logic for the Light Controlled Intersection Tactical Plugin. More...
#include <light_controlled_intersection_tactical_plugin.hpp>
Public Member Functions | |
LightControlledIntersectionTacticalPlugin (carma_wm::WorldModelConstPtr wm, const Config &config, const DebugPublisher &debug_publisher, const std::string &plugin_name, std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > nh) | |
LightControlledIntersectionTacticalPlugin constructor. More... | |
void | planTrajectoryCB (carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp) |
Function to process the light controlled intersection tactical plugin service call for trajectory planning. More... | |
void | set_yield_client (carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > client) |
set the yield service More... | |
void | setConfig (const Config &config) |
Setter function to set a new config for this object. More... | |
Private Member Functions | |
void | applyTrajectorySmoothingAlgorithm (const carma_wm::WorldModelConstPtr &wm, std::vector< PointSpeedPair > &points_and_target_speeds, double start_dist, double remaining_dist, double starting_speed, double departure_speed, TrajectoryParams tsp) |
Creates a speed profile according to case one or two of the light controlled intersection, where the vehicle accelerates (then cruises if needed) and decelerates into the intersection. More... | |
void | applyOptimizedTargetSpeedProfile (const carma_planning_msgs::msg::Maneuver &maneuver, const double starting_speed, std::vector< PointSpeedPair > &points_and_target_speeds) |
Apply optimized target speeds to the trajectory determined for fixed-time and actuated signals. Based on TSMO USE CASE 2. Chapter 2. Trajectory Smoothing. More... | |
std::vector< PointSpeedPair > | createGeometryProfile (const std::vector< carma_planning_msgs::msg::Maneuver > &maneuvers, double max_starting_downtrack, const carma_wm::WorldModelConstPtr &wm, carma_planning_msgs::msg::VehicleState &ending_state_before_buffer, const carma_planning_msgs::msg::VehicleState &state, const GeneralTrajConfig &general_config, const DetailedTrajConfig &detailed_config) |
Creates geometry profile to return a point speed pair struct for INTERSECTION_TRANSIT maneuver types (by converting it to LANE_FOLLOW) More... | |
double | findSpeedLimit (const lanelet::ConstLanelet &llt, const carma_wm::WorldModelConstPtr &wm) const |
Given a Lanelet, find its associated Speed Limit. More... | |
void | logDebugInfoAboutPreviousTrajectory () |
Logs debug information about the previously planned trajectory. More... | |
bool | shouldUseLastTrajectory (TSCase new_case, bool is_new_case_successful, const rclcpp::Time ¤t_time) |
Determines whether the last trajectory should be reused based on the planning case. Should use last case if 1) last traj is valid AND last case is the same as new case, OR 2) last traj is valid AND within certain evaluation zone before the intersection where the new case is not successful but last case is. More... | |
void | planTrajectorySmoothing (carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr req, carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr resp) |
Smooths the trajectory as part of the trajectory planning process. More... | |
carma_planning_msgs::msg::TrajectoryPlan | generateNewTrajectory (const std::vector< carma_planning_msgs::msg::Maneuver > &maneuver_plan, const carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr &req, std::vector< double > &final_speeds) |
Generates a new trajectory plan based on the provided maneuver plan and request. NOTE: This function plans for the entire maneuver input and doesn't time bound it. More... | |
bool | isLastTrajectoryValid (const rclcpp::Time ¤t_time, double min_remaining_time_seconds=0.0) const |
Checks if the last trajectory plan remains valid based on the current time. More... | |
FRIEND_TEST (LCITacticalPluginTest, applyTrajectorySmoothingAlgorithm) | |
FRIEND_TEST (LCITacticalPluginTest, applyOptimizedTargetSpeedProfile) | |
FRIEND_TEST (LCITacticalPluginTest, planTrajectorySmoothing) | |
FRIEND_TEST (LCITacticalPluginTest, createGeometryProfile) | |
FRIEND_TEST (LCITacticalPluginTest, planTrajectoryCB) | |
FRIEND_TEST (LCITacticalPluginTest, setConfig) | |
Private Attributes | |
carma_wm::WorldModelConstPtr | wm_ |
Config | config_ |
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > | nh_ |
uint32_t | street_msg_timestamp_ = 0.0 |
uint32_t | scheduled_stop_time_ = 0.0 |
uint32_t | scheduled_enter_time_ = 0.0 |
uint32_t | scheduled_depart_time_ = 0.0 |
uint32_t | scheduled_latest_depart_time_ = 0.0 |
bool | is_allowed_int_ = false |
double | speed_limit_ = 11.176 |
boost::optional< TSCase > | last_case_ |
boost::optional< bool > | is_last_case_successful_ |
carma_planning_msgs::msg::TrajectoryPlan | last_trajectory_time_unbound_ |
carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > | yield_client_ |
const std::string | LCI_TACTICAL_LOGGER = "light_controlled_intersection_tactical_plugin" |
carma_planning_msgs::msg::VehicleState | ending_state_before_buffer_ |
rclcpp::Time | latest_traj_request_header_stamp_ |
double | epsilon_ = 0.001 |
double | current_downtrack_ = 0.0 |
double | last_successful_ending_downtrack_ |
double | last_successful_scheduled_entry_time_ |
std::string | plugin_name_ |
DebugPublisher | debug_publisher_ |
carma_debug_ros2_msgs::msg::TrajectoryCurvatureSpeeds | debug_msg_ |
std::vector< double > | last_speeds_time_unbound_ |
std::string | light_controlled_intersection_strategy_ = "Carma/signalized_intersection" |
Class containing primary business logic for the Light Controlled Intersection Tactical Plugin.
Definition at line 105 of file light_controlled_intersection_tactical_plugin.hpp.
light_controlled_intersection_tactical_plugin::LightControlledIntersectionTacticalPlugin::LightControlledIntersectionTacticalPlugin | ( | carma_wm::WorldModelConstPtr | wm, |
const Config & | config, | ||
const DebugPublisher & | debug_publisher, | ||
const std::string & | plugin_name, | ||
std::shared_ptr< carma_ros2_utils::CarmaLifecycleNode > | nh | ||
) |
LightControlledIntersectionTacticalPlugin constructor.
Definition at line 23 of file light_controlled_intersection_tactical_plugin.cpp.
|
private |
Apply optimized target speeds to the trajectory determined for fixed-time and actuated signals. Based on TSMO USE CASE 2. Chapter 2. Trajectory Smoothing.
maneuver | Maneuver associated that has starting downtrack and desired entry time |
starting_speed | Starting speed of the vehicle |
points | The set of points with raw speed limits whose speed profile to be changed. These points must be in the same lane as the vehicle and must extend in front of it though it is fine if they also extend behind it. |
Definition at line 519 of file light_controlled_intersection_tactical_plugin.cpp.
References light_controlled_intersection_tactical_plugin::TrajectoryParams::a1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::a2_, light_controlled_intersection_tactical_plugin::TrajectoryParams::a3_, applyTrajectorySmoothingAlgorithm(), GET_MANEUVER_PROPERTY, light_controlled_intersection_tactical_plugin::TrajectoryParams::v1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::v2_, light_controlled_intersection_tactical_plugin::TrajectoryParams::v3_, wm_, light_controlled_intersection_tactical_plugin::TrajectoryParams::x1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::x2_, and light_controlled_intersection_tactical_plugin::TrajectoryParams::x3_.
Referenced by generateNewTrajectory().
|
private |
Creates a speed profile according to case one or two of the light controlled intersection, where the vehicle accelerates (then cruises if needed) and decelerates into the intersection.
wm | world_model pointer |
points_and_target_speeds | of centerline points paired with speed limits whose speeds are to be modified: |
start_dist | starting downtrack of the maneuver to be planned (excluding buffer points) in m |
remaining_dist | distance for the maneuver to be planned (excluding buffer points) in m |
starting_speed | starting speed at the start of the maneuver in m/s |
departure_speed | ending speed of the maneuver a.k.a entry speed into the intersection m/s |
tsp | trajectory smoothing parameters NOTE: Cruising speed profile is applied (case 1) if speed before deceleration is higher than speed limit. Otherwise Case 2. NOTE: when applying the speed profile, the function ignores buffer points beyond start_dist and end_dist. Internally uses: config_.back_distance and speed_limit_ |
Definition at line 432 of file light_controlled_intersection_tactical_plugin.cpp.
References light_controlled_intersection_tactical_plugin::TrajectoryParams::a1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::a2_, light_controlled_intersection_tactical_plugin::TrajectoryParams::a3_, config_, epsilon_, LCI_TACTICAL_LOGGER, light_controlled_intersection_tactical_plugin::Config::minimum_speed, process_traj_logs::point, speed_limit_, light_controlled_intersection_tactical_plugin::TrajectoryParams::v1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::v2_, light_controlled_intersection_tactical_plugin::TrajectoryParams::v3_, light_controlled_intersection_tactical_plugin::TrajectoryParams::x1_, light_controlled_intersection_tactical_plugin::TrajectoryParams::x2_, and light_controlled_intersection_tactical_plugin::TrajectoryParams::x3_.
Referenced by applyOptimizedTargetSpeedProfile().
|
private |
Creates geometry profile to return a point speed pair struct for INTERSECTION_TRANSIT maneuver types (by converting it to LANE_FOLLOW)
maneuvers | The list of maneuvers to convert to geometry points and calculate associated raw speed limits |
max_starting_downtrack | The maximum downtrack that is allowed for the first maneuver. This should be set to the vehicle position or earlier. If the first maneuver exceeds this then it's downtrack will be shifted to this value. |
wm | Pointer to intialized world model for semantic map access |
ending_state_before_buffer | reference to Vehicle state, which is state before applying extra points for curvature calculation that are removed later |
state | The vehicle state at the time the function is called |
general_config | Basic autonomy struct defined to load general config parameters from tactical plugins |
detailed_config | Basic autonomy struct defined to load detailed config parameters from tactical plugins |
Definition at line 564 of file light_controlled_intersection_tactical_plugin.cpp.
References basic_autonomy::waypoint_generation::add_lanefollow_buffer(), basic_autonomy::waypoint_generation::create_lanefollow_geometry(), GET_MANEUVER_PROPERTY, and LCI_TACTICAL_LOGGER.
Referenced by generateNewTrajectory().
|
private |
Given a Lanelet, find its associated Speed Limit.
llt | Constant Lanelet object. |
wm | World model pointer to query additional information. |
std::invalid_argument | if the speed limit could not be retrieved. |
Definition at line 551 of file light_controlled_intersection_tactical_plugin.cpp.
Referenced by planTrajectorySmoothing().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Generates a new trajectory plan based on the provided maneuver plan and request. NOTE: This function plans for the entire maneuver input and doesn't time bound it.
maneuver_plan | A vector of maneuver messages defining the planned maneuvers. The first maneuver is expected to have all the necessary TS parameters. |
req | Shared pointer to the trajectory planning request message. |
final_speeds | A vector that will be populated with the final speeds for each point as it is useful for late operations or debugging |
Definition at line 105 of file light_controlled_intersection_tactical_plugin.cpp.
References applyOptimizedTargetSpeedProfile(), light_controlled_intersection_tactical_plugin::Config::back_distance, light_controlled_intersection_tactical_plugin::Config::buffer_ending_downtrack, basic_autonomy::waypoint_generation::compose_detailed_trajectory_config(), basic_autonomy::waypoint_generation::compose_general_trajectory_config(), basic_autonomy::waypoint_generation::compose_lanefollow_trajectory_from_path(), config_, createGeometryProfile(), current_downtrack_, light_controlled_intersection_tactical_plugin::Config::curvature_moving_average_window_size, light_controlled_intersection_tactical_plugin::Config::curve_resample_step_size, debug_msg_, light_controlled_intersection_tactical_plugin::Config::default_downsample_ratio, ending_state_before_buffer_, light_controlled_intersection_tactical_plugin::Config::lateral_accel_limit, light_controlled_intersection_tactical_plugin::Config::minimum_speed, light_controlled_intersection_tactical_plugin::Config::speed_moving_average_window_size, carma_cooperative_perception::to_string(), light_controlled_intersection_tactical_plugin::Config::turn_downsample_ratio, light_controlled_intersection_tactical_plugin::Config::vehicle_accel_limit, and wm_.
Referenced by planTrajectorySmoothing().
|
private |
Checks if the last trajectory plan remains valid based on the current time.
This function verifies that the previously generated trajectory still meets timing and duration requirements. It can also enforce a minimum remaining duration if specified.
current_time | The current time stamp. |
min_remaining_time_seconds | Optional parameter specifying the minimum required remaining time (in seconds) for the trajectory to be considered valid. |
Definition at line 34 of file light_controlled_intersection_tactical_plugin.cpp.
References is_last_case_successful_, last_case_, last_speeds_time_unbound_, and last_trajectory_time_unbound_.
Referenced by shouldUseLastTrajectory().
|
private |
Logs debug information about the previously planned trajectory.
This helper function outputs detailed internal state and trajectory information that can be used for debugging trajectory planning issues.
Definition at line 158 of file light_controlled_intersection_tactical_plugin.cpp.
References current_downtrack_, is_last_case_successful_, last_case_, last_speeds_time_unbound_, last_successful_ending_downtrack_, last_successful_scheduled_entry_time_, last_trajectory_time_unbound_, latest_traj_request_header_stamp_, LCI_TACTICAL_LOGGER, and carma_cooperative_perception::to_string().
Referenced by planTrajectorySmoothing().
void light_controlled_intersection_tactical_plugin::LightControlledIntersectionTacticalPlugin::planTrajectoryCB | ( | carma_planning_msgs::srv::PlanTrajectory::Request::SharedPtr | req, |
carma_planning_msgs::srv::PlanTrajectory::Response::SharedPtr | resp | ||
) |
Function to process the light controlled intersection tactical plugin service call for trajectory planning.
req | The service request |
resp | The service response |
Definition at line 400 of file light_controlled_intersection_tactical_plugin.cpp.
References config_, light_controlled_intersection_tactical_plugin::Config::enable_object_avoidance, latest_traj_request_header_stamp_, LCI_TACTICAL_LOGGER, basic_autonomy::waypoint_generation::modify_trajectory_to_yield_to_obstacles(), nh_, planTrajectorySmoothing(), light_controlled_intersection_tactical_plugin::Config::tactical_plugin_service_call_timeout, and yield_client_.
|
private |
Smooths the trajectory as part of the trajectory planning process.
This function takes a trajectory planning request, applies smoothing algorithms to refine the trajectory, and populates the response with the smoothed trajectory. NOTE: Function is called by planTrajectoryCB and doesn't use yield client
req | Shared pointer to the trajectory planning request message. |
resp | Shared pointer to the trajectory planning response message to be filled. |
Definition at line 183 of file light_controlled_intersection_tactical_plugin.cpp.
References config_, basic_autonomy::waypoint_generation::constrain_to_time_boundary(), current_downtrack_, debug_msg_, debug_publisher_, findSpeedLimit(), generateNewTrajectory(), GET_MANEUVER_PROPERTY, basic_autonomy::waypoint_generation::get_nearest_point_index(), is_last_case_successful_, last_case_, last_speeds_time_unbound_, last_successful_ending_downtrack_, last_successful_scheduled_entry_time_, last_trajectory_time_unbound_, LCI_TACTICAL_LOGGER, light_controlled_intersection_strategy_, logDebugInfoAboutPreviousTrajectory(), plugin_name_, shouldUseLastTrajectory(), speed_limit_, carma_cooperative_perception::to_string(), light_controlled_intersection_tactical_plugin::Config::trajectory_time_length, and wm_.
Referenced by planTrajectoryCB().
void light_controlled_intersection_tactical_plugin::LightControlledIntersectionTacticalPlugin::set_yield_client | ( | carma_ros2_utils::ClientPtr< carma_planning_msgs::srv::PlanTrajectory > | client | ) |
set the yield service
yield_srv | input yield service |
Definition at line 616 of file light_controlled_intersection_tactical_plugin.cpp.
References yield_client_.
void light_controlled_intersection_tactical_plugin::LightControlledIntersectionTacticalPlugin::setConfig | ( | const Config & | config | ) |
Setter function to set a new config for this object.
config | The new config to be used by this object |
Definition at line 611 of file light_controlled_intersection_tactical_plugin.cpp.
References config_.
|
private |
Determines whether the last trajectory should be reused based on the planning case. Should use last case if 1) last traj is valid AND last case is the same as new case, OR 2) last traj is valid AND within certain evaluation zone before the intersection where the new case is not successful but last case is.
new_case | An enumerated type representing the new trajectory planning case. |
is_new_case_successful | A boolean flag indicating if the new trajectory planning was successful. |
current_time | The current time stamp. |
Definition at line 70 of file light_controlled_intersection_tactical_plugin.cpp.
References config_, current_downtrack_, light_controlled_intersection_tactical_plugin::Config::dist_before_intersection_to_force_last_traj, is_last_case_successful_, isLastTrajectoryValid(), last_case_, last_successful_ending_downtrack_, last_successful_scheduled_entry_time_, light_controlled_intersection_tactical_plugin::Config::period_before_intersection_to_force_last_traj, and light_controlled_intersection_tactical_plugin::Config::vehicle_response_lag.
Referenced by planTrajectorySmoothing().
|
private |
Definition at line 113 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by applyTrajectorySmoothingAlgorithm(), generateNewTrajectory(), planTrajectoryCB(), planTrajectorySmoothing(), setConfig(), and shouldUseLastTrajectory().
|
private |
Definition at line 142 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by generateNewTrajectory(), logDebugInfoAboutPreviousTrajectory(), planTrajectorySmoothing(), and shouldUseLastTrajectory().
|
private |
Definition at line 149 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by generateNewTrajectory(), and planTrajectorySmoothing().
|
private |
Definition at line 148 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by planTrajectorySmoothing().
|
private |
Definition at line 137 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by generateNewTrajectory().
|
private |
Definition at line 139 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by applyTrajectorySmoothingAlgorithm().
|
private |
Definition at line 129 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 133 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by isLastTrajectoryValid(), logDebugInfoAboutPreviousTrajectory(), planTrajectorySmoothing(), and shouldUseLastTrajectory().
|
private |
Definition at line 132 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by isLastTrajectoryValid(), logDebugInfoAboutPreviousTrajectory(), planTrajectorySmoothing(), and shouldUseLastTrajectory().
|
private |
Definition at line 150 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by isLastTrajectoryValid(), logDebugInfoAboutPreviousTrajectory(), and planTrajectorySmoothing().
|
private |
Definition at line 144 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by logDebugInfoAboutPreviousTrajectory(), planTrajectorySmoothing(), and shouldUseLastTrajectory().
|
private |
Definition at line 145 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by logDebugInfoAboutPreviousTrajectory(), planTrajectorySmoothing(), and shouldUseLastTrajectory().
|
private |
Definition at line 134 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by isLastTrajectoryValid(), logDebugInfoAboutPreviousTrajectory(), and planTrajectorySmoothing().
|
private |
Definition at line 138 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by logDebugInfoAboutPreviousTrajectory(), and planTrajectoryCB().
|
private |
Definition at line 136 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by applyTrajectorySmoothingAlgorithm(), createGeometryProfile(), logDebugInfoAboutPreviousTrajectory(), planTrajectoryCB(), and planTrajectorySmoothing().
|
private |
Definition at line 152 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by planTrajectorySmoothing().
|
private |
Definition at line 115 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by planTrajectoryCB().
|
private |
Definition at line 147 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by planTrajectorySmoothing().
|
private |
Definition at line 125 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 123 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 127 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 121 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 131 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by applyTrajectorySmoothingAlgorithm(), and planTrajectorySmoothing().
|
private |
Definition at line 119 of file light_controlled_intersection_tactical_plugin.hpp.
|
private |
Definition at line 110 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by applyOptimizedTargetSpeedProfile(), generateNewTrajectory(), and planTrajectorySmoothing().
|
private |
Definition at line 135 of file light_controlled_intersection_tactical_plugin.hpp.
Referenced by planTrajectoryCB(), and set_yield_client().