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.
motion_computation::MotionComputationNode Class Reference

The class responsible for publishing external object predictions. More...

#include <motion_computation_node.hpp>

Inheritance diagram for motion_computation::MotionComputationNode:
Inheritance graph
Collaboration diagram for motion_computation::MotionComputationNode:
Collaboration graph

Public Member Functions

 MotionComputationNode (const rclcpp::NodeOptions &)
 MotionComputationNode constructor. More...
 
rcl_interfaces::msg::SetParametersResult parameter_update_callback (const std::vector< rclcpp::Parameter > &parameters)
 Function callback for dynamic parameter updates. More...
 
void publishObject (const carma_perception_msgs::msg::ExternalObjectList &obj_pred_msg) const
 Function to publish ExternalObjectList. More...
 
carma_ros2_utils::CallbackReturn handle_on_configure (const rclcpp_lifecycle::State &)
 

Private Attributes

carma_ros2_utils::SubPtr< carma_perception_msgs::msg::ExternalObjectList > motion_comp_sub_
 
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::MobilityPath > mobility_path_sub_
 
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::BSM > bsm_sub_
 
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::PSM > psm_sub_
 
carma_ros2_utils::SubPtr< std_msgs::msg::String > georeference_sub_
 
carma_ros2_utils::PubPtr< carma_perception_msgs::msg::ExternalObjectList > carma_obj_pub_
 
MotionComputationWorker motion_worker_
 
Config config_
 

Detailed Description

The class responsible for publishing external object predictions.

Definition at line 39 of file motion_computation_node.hpp.

Constructor & Destructor Documentation

◆ MotionComputationNode()

motion_computation::MotionComputationNode::MotionComputationNode ( const rclcpp::NodeOptions &  options)
explicit

MotionComputationNode constructor.

Definition at line 21 of file motion_computation_node.cpp.

22: carma_ros2_utils::CarmaLifecycleNode(options),
24 std::bind(&MotionComputationNode::publishObject, this, std_ph::_1),
25 get_node_logging_interface(), get_node_clock_interface())
26{
27 // Create initial config
28 config_ = Config();
29
30 // Declare parameters
32 declare_parameter<double>("prediction_time_step", config_.prediction_time_step);
34 declare_parameter<double>("prediction_period", config_.prediction_period);
36 declare_parameter<double>("cv_x_accel_noise", config_.cv_x_accel_noise);
38 declare_parameter<double>("cv_y_accel_noise", config_.cv_y_accel_noise);
40 declare_parameter<double>("prediction_process_noise_max", config_.prediction_process_noise_max);
41 config_.prediction_confidence_drop_rate = declare_parameter<double>(
42 "prediction_confidence_drop_rate", config_.prediction_confidence_drop_rate);
44 declare_parameter<bool>("enable_bsm_processing", config_.enable_bsm_processing);
46 declare_parameter<bool>("enable_psm_processing", config_.enable_psm_processing);
47 config_.enable_mobility_path_processing = declare_parameter<bool>(
48 "enable_mobility_path_processing", config_.enable_mobility_path_processing);
50 declare_parameter<bool>("enable_sensor_processing", config_.enable_sensor_processing);
52 declare_parameter<bool>("enable_ctrv_for_unknown_obj", config_.enable_ctrv_for_unknown_obj);
53 config_.enable_ctrv_for_motorcycle_obj = declare_parameter<bool>(
54 "enable_ctrv_for_motorcycle_obj", config_.enable_ctrv_for_motorcycle_obj);
55 config_.enable_ctrv_for_small_vehicle_obj = declare_parameter<bool>(
56 "enable_ctrv_for_small_vehicle_obj", config_.enable_ctrv_for_small_vehicle_obj);
57 config_.enable_ctrv_for_large_vehicle_obj = declare_parameter<bool>(
58 "enable_ctrv_for_large_vehicle_obj", config_.enable_ctrv_for_large_vehicle_obj);
59 config_.enable_ctrv_for_pedestrian_obj = declare_parameter<bool>(
60 "enable_ctrv_for_pedestrian_obj", config_.enable_ctrv_for_pedestrian_obj);
61}
void publishObject(const carma_perception_msgs::msg::ExternalObjectList &obj_pred_msg) const
Function to publish ExternalObjectList.

References config_, motion_computation::Config::cv_x_accel_noise, motion_computation::Config::cv_y_accel_noise, motion_computation::Config::enable_bsm_processing, motion_computation::Config::enable_ctrv_for_large_vehicle_obj, motion_computation::Config::enable_ctrv_for_motorcycle_obj, motion_computation::Config::enable_ctrv_for_pedestrian_obj, motion_computation::Config::enable_ctrv_for_small_vehicle_obj, motion_computation::Config::enable_ctrv_for_unknown_obj, motion_computation::Config::enable_mobility_path_processing, motion_computation::Config::enable_psm_processing, motion_computation::Config::enable_sensor_processing, motion_computation::Config::prediction_confidence_drop_rate, motion_computation::Config::prediction_period, motion_computation::Config::prediction_process_noise_max, and motion_computation::Config::prediction_time_step.

Member Function Documentation

◆ handle_on_configure()

carma_ros2_utils::CallbackReturn motion_computation::MotionComputationNode::handle_on_configure ( const rclcpp_lifecycle::State &  )

Definition at line 111 of file motion_computation_node.cpp.

113{
114 RCLCPP_INFO_STREAM(get_logger(), "MotionComputationNode trying to configure");
115
116 // Reset config
117 config_ = Config();
118
119 // Load parameters
120 get_parameter<double>("prediction_time_step", config_.prediction_time_step);
121 get_parameter<double>("prediction_period", config_.prediction_period);
122 get_parameter<double>("cv_x_accel_noise", config_.cv_x_accel_noise);
123 get_parameter<double>("cv_y_accel_noise", config_.cv_y_accel_noise);
124 get_parameter<double>("prediction_process_noise_max", config_.prediction_process_noise_max);
125 get_parameter<double>("prediction_confidence_drop_rate", config_.prediction_confidence_drop_rate);
126 get_parameter<bool>("enable_bsm_processing", config_.enable_bsm_processing);
127 get_parameter<bool>("enable_psm_processing", config_.enable_psm_processing);
128 get_parameter<bool>("enable_mobility_path_processing", config_.enable_mobility_path_processing);
129 get_parameter<bool>("enable_sensor_processing", config_.enable_sensor_processing);
130 get_parameter<bool>("enable_ctrv_for_unknown_obj", config_.enable_ctrv_for_unknown_obj);
131 get_parameter<bool>("enable_ctrv_for_motorcycle_obj", config_.enable_ctrv_for_motorcycle_obj);
132 get_parameter<bool>(
133 "enable_ctrv_for_small_vehicle_obj", config_.enable_ctrv_for_small_vehicle_obj);
134 get_parameter<bool>(
135 "enable_ctrv_for_large_vehicle_obj", config_.enable_ctrv_for_large_vehicle_obj);
136 get_parameter<bool>("enable_ctrv_for_pedestrian_obj", config_.enable_ctrv_for_pedestrian_obj);
137
138 RCLCPP_INFO_STREAM(get_logger(), "Loaded params: " << config_);
139
140 // Register runtime parameter update callback
141 add_on_set_parameters_callback(
142 std::bind(&MotionComputationNode::parameter_update_callback, this, std_ph::_1));
143
144 // Setup subscribers
145 motion_comp_sub_ = create_subscription<carma_perception_msgs::msg::ExternalObjectList>(
146 "external_objects", 1,
148
149 mobility_path_sub_ = create_subscription<carma_v2x_msgs::msg::MobilityPath>(
150 "incoming_mobility_path", 100,
152
153 bsm_sub_ = create_subscription<carma_v2x_msgs::msg::BSM>(
154 "incoming_bsm", 100,
155 std::bind(&MotionComputationWorker::bsmCallback, &motion_worker_, std_ph::_1));
156
157 psm_sub_ = create_subscription<carma_v2x_msgs::msg::PSM>(
158 "incoming_psm", 100,
159 std::bind(&MotionComputationWorker::psmCallback, &motion_worker_, std_ph::_1));
160
161 georeference_sub_ = create_subscription<std_msgs::msg::String>(
162 "georeference", 1,
164
165 // Setup publishers
166 carma_obj_pub_ = create_publisher<carma_perception_msgs::msg::ExternalObjectList>(
167 "external_object_predictions", 2);
168
169 // Set motion_worker_'s prediction parameters
179
180 // Return success if everything initialized successfully
181 return CallbackReturn::SUCCESS;
182}
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::BSM > bsm_sub_
carma_ros2_utils::SubPtr< std_msgs::msg::String > georeference_sub_
carma_ros2_utils::SubPtr< carma_perception_msgs::msg::ExternalObjectList > motion_comp_sub_
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::MobilityPath > mobility_path_sub_
rcl_interfaces::msg::SetParametersResult parameter_update_callback(const std::vector< rclcpp::Parameter > &parameters)
Function callback for dynamic parameter updates.
carma_ros2_utils::PubPtr< carma_perception_msgs::msg::ExternalObjectList > carma_obj_pub_
carma_ros2_utils::SubPtr< carma_v2x_msgs::msg::PSM > psm_sub_
void georeferenceCallback(const std_msgs::msg::String::UniquePtr msg)
Callback for map projection string to define lat/lon -> map conversion.
void predictionLogic(carma_perception_msgs::msg::ExternalObjectList::UniquePtr obj_list)
Function to populate duplicated detected objects along with their velocity, yaw, yaw_rate and static/...
void psmCallback(const carma_v2x_msgs::msg::PSM::UniquePtr msg)
void bsmCallback(const carma_v2x_msgs::msg::BSM::UniquePtr msg)
void setDetectionInputFlags(bool enable_sensor_processing, bool enable_bsm_processing, bool enable_psm_processing, bool enable_mobility_path_processing)
void mobilityPathCallback(const carma_v2x_msgs::msg::MobilityPath::UniquePtr msg)

References bsm_sub_, motion_computation::MotionComputationWorker::bsmCallback(), carma_obj_pub_, config_, motion_computation::Config::cv_x_accel_noise, motion_computation::Config::cv_y_accel_noise, motion_computation::Config::enable_bsm_processing, motion_computation::Config::enable_ctrv_for_large_vehicle_obj, motion_computation::Config::enable_ctrv_for_motorcycle_obj, motion_computation::Config::enable_ctrv_for_pedestrian_obj, motion_computation::Config::enable_ctrv_for_small_vehicle_obj, motion_computation::Config::enable_ctrv_for_unknown_obj, motion_computation::Config::enable_mobility_path_processing, motion_computation::Config::enable_psm_processing, motion_computation::Config::enable_sensor_processing, georeference_sub_, motion_computation::MotionComputationWorker::georeferenceCallback(), mobility_path_sub_, motion_computation::MotionComputationWorker::mobilityPathCallback(), motion_comp_sub_, motion_worker_, parameter_update_callback(), motion_computation::Config::prediction_confidence_drop_rate, motion_computation::Config::prediction_period, motion_computation::Config::prediction_process_noise_max, motion_computation::Config::prediction_time_step, motion_computation::MotionComputationWorker::predictionLogic(), psm_sub_, motion_computation::MotionComputationWorker::psmCallback(), motion_computation::MotionComputationWorker::setConfidenceDropRate(), motion_computation::MotionComputationWorker::setDetectionInputFlags(), motion_computation::MotionComputationWorker::setPredictionPeriod(), motion_computation::MotionComputationWorker::setPredictionTimeStep(), motion_computation::MotionComputationWorker::setProcessNoiseMax(), motion_computation::MotionComputationWorker::setXAccelerationNoise(), and motion_computation::MotionComputationWorker::setYAccelerationNoise().

Here is the call graph for this function:

◆ parameter_update_callback()

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

Function callback for dynamic parameter updates.

Definition at line 63 of file motion_computation_node.cpp.

65{
66 auto error = update_params<double>(
67 {{"prediction_time_step", config_.prediction_time_step},
68 {"prediction_period", config_.prediction_period},
69 {"cv_x_accel_noise", config_.cv_x_accel_noise},
70 {"cv_y_accel_noise", config_.cv_y_accel_noise},
71 {"prediction_process_noise_max", config_.prediction_process_noise_max},
72 {"prediction_confidence_drop_rate", config_.prediction_confidence_drop_rate}},
73 parameters);
74
75 auto error_2 = update_params<bool>(
76 {{"enable_bsm_processing", config_.enable_bsm_processing},
77 {"enable_psm_processing", config_.enable_psm_processing},
78 {"enable_mobility_path_processing", config_.enable_mobility_path_processing},
79 {"enable_sensor_processing", config_.enable_sensor_processing},
80 {"enable_ctrv_for_unknown_obj", config_.enable_ctrv_for_unknown_obj},
81 {"enable_ctrv_for_motorcycle_obj", config_.enable_ctrv_for_motorcycle_obj},
82 {"enable_ctrv_for_small_vehicle_obj", config_.enable_ctrv_for_small_vehicle_obj},
83 {"enable_ctrv_for_large_vehicle_obj", config_.enable_ctrv_for_large_vehicle_obj},
84 {"enable_ctrv_for_pedestrian_obj", config_.enable_ctrv_for_pedestrian_obj}},
85 parameters);
86
87 rcl_interfaces::msg::SetParametersResult result;
88
89 result.successful = !error && !error_2;
90
91 if (result.successful) {
92 // Set motion_worker_'s prediction parameters
106 }
107
108 return result;
109}
void setDetectionMotionModelFlags(bool enable_ctrv_for_unknown_obj, bool enable_ctrv_for_motorcycle_obj, bool enable_ctrv_for_small_vehicle_obj, bool enable_ctrv_for_large_vehicle_obj, bool enable_ctrv_for_pedestrian_obj)

References config_, motion_computation::Config::cv_x_accel_noise, motion_computation::Config::cv_y_accel_noise, motion_computation::Config::enable_bsm_processing, motion_computation::Config::enable_ctrv_for_large_vehicle_obj, motion_computation::Config::enable_ctrv_for_motorcycle_obj, motion_computation::Config::enable_ctrv_for_pedestrian_obj, motion_computation::Config::enable_ctrv_for_small_vehicle_obj, motion_computation::Config::enable_ctrv_for_unknown_obj, motion_computation::Config::enable_mobility_path_processing, motion_computation::Config::enable_psm_processing, motion_computation::Config::enable_sensor_processing, motion_worker_, motion_computation::Config::prediction_confidence_drop_rate, motion_computation::Config::prediction_period, motion_computation::Config::prediction_process_noise_max, motion_computation::Config::prediction_time_step, motion_computation::MotionComputationWorker::setConfidenceDropRate(), motion_computation::MotionComputationWorker::setDetectionInputFlags(), motion_computation::MotionComputationWorker::setDetectionMotionModelFlags(), motion_computation::MotionComputationWorker::setPredictionPeriod(), motion_computation::MotionComputationWorker::setPredictionTimeStep(), motion_computation::MotionComputationWorker::setProcessNoiseMax(), motion_computation::MotionComputationWorker::setXAccelerationNoise(), and motion_computation::MotionComputationWorker::setYAccelerationNoise().

Referenced by handle_on_configure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishObject()

void motion_computation::MotionComputationNode::publishObject ( const carma_perception_msgs::msg::ExternalObjectList &  obj_pred_msg) const

Function to publish ExternalObjectList.

Parameters
obj_pred_msgExternalObjectList message to be published

Definition at line 184 of file motion_computation_node.cpp.

186{
187 carma_obj_pub_->publish(obj_pred_msg);
188}

References carma_obj_pub_.

Member Data Documentation

◆ bsm_sub_

carma_ros2_utils::SubPtr<carma_v2x_msgs::msg::BSM> motion_computation::MotionComputationNode::bsm_sub_
private

Definition at line 45 of file motion_computation_node.hpp.

Referenced by handle_on_configure().

◆ carma_obj_pub_

carma_ros2_utils::PubPtr<carma_perception_msgs::msg::ExternalObjectList> motion_computation::MotionComputationNode::carma_obj_pub_
private

Definition at line 50 of file motion_computation_node.hpp.

Referenced by handle_on_configure(), and publishObject().

◆ config_

Config motion_computation::MotionComputationNode::config_
private

◆ georeference_sub_

carma_ros2_utils::SubPtr<std_msgs::msg::String> motion_computation::MotionComputationNode::georeference_sub_
private

Definition at line 47 of file motion_computation_node.hpp.

Referenced by handle_on_configure().

◆ mobility_path_sub_

carma_ros2_utils::SubPtr<carma_v2x_msgs::msg::MobilityPath> motion_computation::MotionComputationNode::mobility_path_sub_
private

Definition at line 44 of file motion_computation_node.hpp.

Referenced by handle_on_configure().

◆ motion_comp_sub_

carma_ros2_utils::SubPtr<carma_perception_msgs::msg::ExternalObjectList> motion_computation::MotionComputationNode::motion_comp_sub_
private

Definition at line 43 of file motion_computation_node.hpp.

Referenced by handle_on_configure().

◆ motion_worker_

MotionComputationWorker motion_computation::MotionComputationNode::motion_worker_
private

Definition at line 53 of file motion_computation_node.hpp.

Referenced by handle_on_configure(), and parameter_update_callback().

◆ psm_sub_

carma_ros2_utils::SubPtr<carma_v2x_msgs::msg::PSM> motion_computation::MotionComputationNode::psm_sub_
private

Definition at line 46 of file motion_computation_node.hpp.

Referenced by handle_on_configure().


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