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.
route::Route Class Reference

The route package provides the following functionality: More...

#include <route_node.hpp>

Inheritance diagram for route::Route:
Inheritance graph
Collaboration diagram for route::Route:
Collaboration graph

Public Member Functions

 Route (const rclcpp::NodeOptions &)
 Route constructor. More...
 
rcl_interfaces::msg::SetParametersResult parameter_update_callback (const std::vector< rclcpp::Parameter > &parameters)
 Function callback for dynamic parameter updates. More...
 
carma_ros2_utils::CallbackReturn handle_on_configure (const rclcpp_lifecycle::State &)
 
carma_ros2_utils::CallbackReturn handle_on_activate (const rclcpp_lifecycle::State &)
 

Private Attributes

carma_ros2_utils::SubPtr< geometry_msgs::msg::TwistStamped > twist_sub_
 
carma_ros2_utils::SubPtr< std_msgs::msg::String > geo_sub_
 
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::Route > route_pub_
 
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteState > route_state_pub_
 
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteEvent > route_event_pub_
 
carma_ros2_utils::PubPtr< visualization_msgs::msg::Marker > route_marker_pub_
 
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::GetAvailableRoutes > get_available_route_srv_
 
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::SetActiveRoute > set_active_route_srv_
 
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::AbortActiveRoute > abort_active_route_srv_
 
rclcpp::TimerBase::SharedPtr spin_timer_
 
Config config_
 
tf2_ros::Buffer tf2_buffer_
 
carma_wm::WMListener wml_
 
carma_wm::WorldModelConstPtr wm_
 
RouteGeneratorWorker rg_worker_
 

Detailed Description

The route package provides the following functionality:

  • Route generation which provides the list of available routes and provides vehicle travel route description and management.
  • Route state management which provides the current state of the route following, including tracking vehicle cross track and down track distances along the active route

Definition at line 50 of file route_node.hpp.

Constructor & Destructor Documentation

◆ Route()

route::Route::Route ( const rclcpp::NodeOptions &  options)
explicit

Route constructor.

Definition at line 22 of file route_node.cpp.

23 : carma_ros2_utils::CarmaLifecycleNode(options),
24 tf2_buffer_(this->get_clock()),
25 wml_(this->get_node_base_interface(), this->get_node_logging_interface(),
26 this->get_node_topics_interface(), this->get_node_parameters_interface()),
28 {
29 // Create initial config
30 config_ = Config();
31
32 // Declare parameters
33 config_.max_crosstrack_error = declare_parameter<double>("max_crosstrack_error", config_.max_crosstrack_error);
34 config_.destination_downtrack_range = declare_parameter<double>("destination_downtrack_range", config_.destination_downtrack_range);
35 config_.route_spin_rate = declare_parameter<double>("route_spin_rate", config_.route_spin_rate);
36 config_.cte_max_count = declare_parameter<int>("cte_max_count", config_.cte_max_count);
37 config_.route_file_path = declare_parameter<std::string>("route_file_path", config_.route_file_path);
38 }
RouteGeneratorWorker rg_worker_
Definition: route_node.hpp:83
Config config_
Definition: route_node.hpp:73
tf2_ros::Buffer tf2_buffer_
Definition: route_node.hpp:76
carma_wm::WMListener wml_
Definition: route_node.hpp:79
std::string route_file_path
double destination_downtrack_range
double route_spin_rate
double max_crosstrack_error

References config_, route::Config::cte_max_count, route::Config::destination_downtrack_range, route::Config::max_crosstrack_error, route::Config::route_file_path, and route::Config::route_spin_rate.

Member Function Documentation

◆ handle_on_activate()

carma_ros2_utils::CallbackReturn route::Route::handle_on_activate ( const rclcpp_lifecycle::State &  prev_state)

Definition at line 124 of file route_node.cpp.

125 {
127
128 // Timer for route generator worker's spin callback
129 auto rg_worker_spin_period_ms = int ((1 / config_.route_spin_rate) * 1000); // Conversion from frequency (Hz) to milliseconds time period
130 spin_timer_ = create_timer(get_clock(),
131 std::chrono::milliseconds(rg_worker_spin_period_ms),
133
134 return CallbackReturn::SUCCESS;
135 }
void setRouteFilePath(const std::string &path)
Set method for configurable parameter.
bool spinCallback()
Spin callback which will be called frequently based on spin rate.
rclcpp::TimerBase::SharedPtr spin_timer_
Definition: route_node.hpp:70

References config_, rg_worker_, route::Config::route_file_path, route::Config::route_spin_rate, route::RouteGeneratorWorker::setRouteFilePath(), spin_timer_, and route::RouteGeneratorWorker::spinCallback().

Here is the call graph for this function:

◆ handle_on_configure()

carma_ros2_utils::CallbackReturn route::Route::handle_on_configure ( const rclcpp_lifecycle::State &  )

Definition at line 56 of file route_node.cpp.

57 {
58 RCLCPP_INFO_STREAM(get_logger(), "Route trying to configure");
59
60 // Reset config
61 config_ = Config();
62
63 // Load parameters
64 get_parameter<double>("max_crosstrack_error", config_.max_crosstrack_error);
65 get_parameter<double>("destination_downtrack_range", config_.destination_downtrack_range);
66 get_parameter<double>("route_spin_rate", config_.route_spin_rate);
67 get_parameter<int>("cte_max_count", config_.cte_max_count);
68 get_parameter<std::string>("route_file_path", config_.route_file_path);
69
70 RCLCPP_INFO_STREAM(get_logger(), "Loaded params: " << config_);
71
72 // Register runtime parameter update callback
73 add_on_set_parameters_callback(std::bind(&Route::parameter_update_callback, this, std_ph::_1));
74
75 // Setup subscribers
76 twist_sub_ = create_subscription<geometry_msgs::msg::TwistStamped>("current_velocity", 1,
77 std::bind(&RouteGeneratorWorker::twistCb, &rg_worker_, std_ph::_1));
78 geo_sub_ = create_subscription<std_msgs::msg::String>("georeference", 1,
79 std::bind(&RouteGeneratorWorker::georeferenceCb, &rg_worker_, std_ph::_1));
80
81 // Setup publishers
82 route_pub_ = create_publisher<carma_planning_msgs::msg::Route>("route", 1);
83 route_state_pub_ = create_publisher<carma_planning_msgs::msg::RouteState>("route_state", 1);
84
85 // NOTE: Currently, intra-process comms must be disabled for the following two publishers that are transient_local: https://github.com/ros2/rclcpp/issues/1753
86 rclcpp::PublisherOptions intra_proc_disabled;
87 intra_proc_disabled.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable; // Disable intra-process comms for this PublisherOptions object
88
89 // Create a publisher that will send all previously published messages to late-joining subscribers ONLY If the subscriber is transient_local too
90 auto pub_qos_transient_local = rclcpp::QoS(rclcpp::KeepAll()); // A publisher with this QoS will store all messages that it has sent on the topic
91 pub_qos_transient_local.transient_local(); // A publisher with this QoS will re-send all (when KeepAll is used) messages to all late-joining subscribers
92 // NOTE: The subscriber's QoS must be set to transient_local() as well for earlier messages to be resent to the later-joiner.
93
94 route_event_pub_ = create_publisher<carma_planning_msgs::msg::RouteEvent>("route_event", pub_qos_transient_local, intra_proc_disabled);
95 route_marker_pub_ = create_publisher<visualization_msgs::msg::Marker>("route_marker", 1);
96
97 // Setup service servers
98 get_available_route_srv_ = create_service<carma_planning_msgs::srv::GetAvailableRoutes>("get_available_routes",
99 std::bind(&RouteGeneratorWorker::getAvailableRouteCb, &rg_worker_, std_ph::_1, std_ph::_2, std_ph::_3));
100 set_active_route_srv_ = create_service<carma_planning_msgs::srv::SetActiveRoute>("set_active_route",
101 std::bind(&RouteGeneratorWorker::setActiveRouteCb, &rg_worker_, std_ph::_1, std_ph::_2, std_ph::_3));
102 abort_active_route_srv_ = create_service<carma_planning_msgs::srv::AbortActiveRoute>("abort_active_route",
103 std::bind(&RouteGeneratorWorker::abortActiveRouteCb, &rg_worker_, std_ph::_1, std_ph::_2, std_ph::_3));
104
105 // Set world model pointer from wm listener
108
109 // Configure route generator worker parameters
110 rg_worker_.setClock(get_clock());
111 rg_worker_.setLoggerInterface(get_node_logging_interface());
119
120 // Return success if everthing initialized successfully
121 return CallbackReturn::SUCCESS;
122 }
WorldModelConstPtr getWorldModel()
Returns a pointer to an intialized world model instance.
Definition: WMListener.cpp:184
void enableUpdatesWithoutRouteWL()
Use to allow updates to occur even if they invalidate the current route. This is only meant to be use...
Definition: WMListener.cpp:172
bool checkIfReRoutingNeededWL()
Returns true if a map update has been processed which requires rerouting. This method is meant to be ...
Definition: WMListener.cpp:178
bool setActiveRouteCb(const std::shared_ptr< rmw_request_id_t >, const std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Request > req, std::shared_ptr< carma_planning_msgs::srv::SetActiveRoute::Response > resp)
Set_active_route service callback. User can select a route to start following by calling this service...
void setCrosstrackErrorDistance(double cte_dist)
set the maximum crosstrack error distance
bool getAvailableRouteCb(const std::shared_ptr< rmw_request_id_t >, const std::shared_ptr< carma_planning_msgs::srv::GetAvailableRoutes::Request >, std::shared_ptr< carma_planning_msgs::srv::GetAvailableRoutes::Response > resp)
Get_available_route service callback. Calls to this service will respond with a list of route names f...
void setLoggerInterface(rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger)
Dependency injection for logger interface.
void setWorldModelPtr(carma_wm::WorldModelConstPtr wm)
Dependency injection for world model pointer.
void initializeBumperTransformLookup()
Initialize transform lookup from front bumper to map.
void setClock(rclcpp::Clock::SharedPtr clock)
Dependency injection for clock object.
void setReroutingChecker(const std::function< bool()> inputFunction)
setReroutingChecker function to set the rerouting flag
void setCrosstrackErrorCountMax(int cte_max)
set the crosstrack error counter maximum limit
void setDowntrackDestinationRange(double dt_dest_range)
Set method for configurable parameter.
void twistCb(geometry_msgs::msg::TwistStamped::UniquePtr msg)
Callback for the twist subscriber, which will store latest twist locally.
void setPublishers(const carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteEvent > &route_event_pub, const carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteState > &route_state_pub, const carma_ros2_utils::PubPtr< carma_planning_msgs::msg::Route > &route_pub, const carma_ros2_utils::PubPtr< visualization_msgs::msg::Marker > &route_marker_pub)
Method to pass publishers into worker class.
void georeferenceCb(std_msgs::msg::String::UniquePtr msg)
Callback for the georeference subscriber used to set the map projection.
bool abortActiveRouteCb(const std::shared_ptr< rmw_request_id_t >, const std::shared_ptr< carma_planning_msgs::srv::AbortActiveRoute::Request >, std::shared_ptr< carma_planning_msgs::srv::AbortActiveRoute::Response > resp)
Abort_active_route service callback. User can call this service to abort a current following route an...
carma_wm::WorldModelConstPtr wm_
Definition: route_node.hpp:80
rcl_interfaces::msg::SetParametersResult parameter_update_callback(const std::vector< rclcpp::Parameter > &parameters)
Function callback for dynamic parameter updates.
Definition: route_node.cpp:40
carma_ros2_utils::SubPtr< geometry_msgs::msg::TwistStamped > twist_sub_
Definition: route_node.hpp:55
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::GetAvailableRoutes > get_available_route_srv_
Definition: route_node.hpp:65
carma_ros2_utils::SubPtr< std_msgs::msg::String > geo_sub_
Definition: route_node.hpp:56
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::Route > route_pub_
Definition: route_node.hpp:59
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::SetActiveRoute > set_active_route_srv_
Definition: route_node.hpp:66
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteState > route_state_pub_
Definition: route_node.hpp:60
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::AbortActiveRoute > abort_active_route_srv_
Definition: route_node.hpp:67
carma_ros2_utils::PubPtr< visualization_msgs::msg::Marker > route_marker_pub_
Definition: route_node.hpp:62
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::RouteEvent > route_event_pub_
Definition: route_node.hpp:61

References abort_active_route_srv_, route::RouteGeneratorWorker::abortActiveRouteCb(), carma_wm::WMListener::checkIfReRoutingNeededWL(), config_, route::Config::cte_max_count, route::Config::destination_downtrack_range, carma_wm::WMListener::enableUpdatesWithoutRouteWL(), geo_sub_, route::RouteGeneratorWorker::georeferenceCb(), get_available_route_srv_, route::RouteGeneratorWorker::getAvailableRouteCb(), carma_wm::WMListener::getWorldModel(), route::RouteGeneratorWorker::initializeBumperTransformLookup(), route::Config::max_crosstrack_error, parameter_update_callback(), rg_worker_, route_event_pub_, route::Config::route_file_path, route_marker_pub_, route_pub_, route::Config::route_spin_rate, route_state_pub_, set_active_route_srv_, route::RouteGeneratorWorker::setActiveRouteCb(), route::RouteGeneratorWorker::setClock(), route::RouteGeneratorWorker::setCrosstrackErrorCountMax(), route::RouteGeneratorWorker::setCrosstrackErrorDistance(), route::RouteGeneratorWorker::setDowntrackDestinationRange(), route::RouteGeneratorWorker::setLoggerInterface(), route::RouteGeneratorWorker::setPublishers(), route::RouteGeneratorWorker::setReroutingChecker(), route::RouteGeneratorWorker::setWorldModelPtr(), twist_sub_, route::RouteGeneratorWorker::twistCb(), wm_, and wml_.

Here is the call graph for this function:

◆ parameter_update_callback()

rcl_interfaces::msg::SetParametersResult route::Route::parameter_update_callback ( const std::vector< rclcpp::Parameter > &  parameters)

Function callback for dynamic parameter updates.

Definition at line 40 of file route_node.cpp.

41 {
42 auto error = update_params<double>({
43 {"max_crosstrack_error", config_.max_crosstrack_error},
44 {"destination_downtrack_range", config_.destination_downtrack_range},
45 {"route_spin_rate", config_.route_spin_rate}}, parameters);
46 auto error_2 = update_params<int>({{"cte_max_count", config_.cte_max_count}}, parameters);
47 auto error_3 = update_params<std::string>({{"route_file_path", config_.route_file_path}}, parameters);
48
49 rcl_interfaces::msg::SetParametersResult result;
50
51 result.successful = !error && !error_2 && !error_3;
52
53 return result;
54 }

References config_, route::Config::cte_max_count, route::Config::destination_downtrack_range, route::Config::max_crosstrack_error, route::Config::route_file_path, and route::Config::route_spin_rate.

Referenced by handle_on_configure().

Here is the caller graph for this function:

Member Data Documentation

◆ abort_active_route_srv_

carma_ros2_utils::ServicePtr<carma_planning_msgs::srv::AbortActiveRoute> route::Route::abort_active_route_srv_
private

Definition at line 67 of file route_node.hpp.

Referenced by handle_on_configure().

◆ config_

Config route::Route::config_
private

◆ geo_sub_

carma_ros2_utils::SubPtr<std_msgs::msg::String> route::Route::geo_sub_
private

Definition at line 56 of file route_node.hpp.

Referenced by handle_on_configure().

◆ get_available_route_srv_

carma_ros2_utils::ServicePtr<carma_planning_msgs::srv::GetAvailableRoutes> route::Route::get_available_route_srv_
private

Definition at line 65 of file route_node.hpp.

Referenced by handle_on_configure().

◆ rg_worker_

RouteGeneratorWorker route::Route::rg_worker_
private

Definition at line 83 of file route_node.hpp.

Referenced by handle_on_activate(), and handle_on_configure().

◆ route_event_pub_

carma_ros2_utils::PubPtr<carma_planning_msgs::msg::RouteEvent> route::Route::route_event_pub_
private

Definition at line 61 of file route_node.hpp.

Referenced by handle_on_configure().

◆ route_marker_pub_

carma_ros2_utils::PubPtr<visualization_msgs::msg::Marker> route::Route::route_marker_pub_
private

Definition at line 62 of file route_node.hpp.

Referenced by handle_on_configure().

◆ route_pub_

carma_ros2_utils::PubPtr<carma_planning_msgs::msg::Route> route::Route::route_pub_
private

Definition at line 59 of file route_node.hpp.

Referenced by handle_on_configure().

◆ route_state_pub_

carma_ros2_utils::PubPtr<carma_planning_msgs::msg::RouteState> route::Route::route_state_pub_
private

Definition at line 60 of file route_node.hpp.

Referenced by handle_on_configure().

◆ set_active_route_srv_

carma_ros2_utils::ServicePtr<carma_planning_msgs::srv::SetActiveRoute> route::Route::set_active_route_srv_
private

Definition at line 66 of file route_node.hpp.

Referenced by handle_on_configure().

◆ spin_timer_

rclcpp::TimerBase::SharedPtr route::Route::spin_timer_
private

Definition at line 70 of file route_node.hpp.

Referenced by handle_on_activate().

◆ tf2_buffer_

tf2_ros::Buffer route::Route::tf2_buffer_
private

Definition at line 76 of file route_node.hpp.

◆ twist_sub_

carma_ros2_utils::SubPtr<geometry_msgs::msg::TwistStamped> route::Route::twist_sub_
private

Definition at line 55 of file route_node.hpp.

Referenced by handle_on_configure().

◆ wm_

carma_wm::WorldModelConstPtr route::Route::wm_
private

Definition at line 80 of file route_node.hpp.

Referenced by handle_on_configure().

◆ wml_

carma_wm::WMListener route::Route::wml_
private

Definition at line 79 of file route_node.hpp.

Referenced by handle_on_configure().


The documentation for this class was generated from the following files: