16#include "<SUB><package_name>/<SUB><package_name>_node.hpp
"
18namespace <SUB><package_name>
20 namespace std_ph = std::placeholders;
22 Node::Node(const rclcpp::NodeOptions &options)
23 : carma_guidance_plugins::StrategicPlugin(options)
25 // Create initial config
29 config_.example_param = declare_parameter<std::string>("example_param
", config_.example_param);
32 rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(const std::vector<rclcpp::Parameter> ¶meters)
34 // TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this method
35 auto error = update_params<std::string>({{"example_param
", config_.example_param}}, parameters);
37 rcl_interfaces::msg::SetParametersResult result;
39 result.successful = !error;
44 carma_ros2_utils::CallbackReturn Node::on_configure_plugin()
50 get_parameter<std::string>("example_param
", config_.example_param);
52 // Register runtime parameter update callback
53 add_on_set_parameters_callback(std::bind(&Node::parameter_update_callback, this, std_ph::_1));
56 example_sub_ = create_subscription<std_msgs::msg::String>("example_input_topic
", 10,
57 std::bind(&Node::example_callback, this, std_ph::_1));
60 example_pub_ = create_publisher<std_msgs::msg::String>("example_output_topic
", 10);
62 // Setup service clients
63 example_client_ = create_client<std_srvs::srv::Empty>("example_used_service
");
65 // Setup service servers
66 example_service_ = create_service<std_srvs::srv::Empty>("example_provided_service
",
67 std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));
70 // NOTE: You will not be able to actually publish until in the ACTIVE state
71 // so it may often make more sense for timers to be created in handle_on_activate
72 example_timer_ = create_timer(
74 std::chrono::milliseconds(1000),
75 std::bind(&Node::example_timer_callback, this));
77 // Return success if everything initialized successfully
78 return CallbackReturn::SUCCESS;
81 // Parameter names not shown to prevent unused compile warning. The user may add them back
82 void Node::example_service_callback(const std::shared_ptr<rmw_request_id_t>,
83 const std::shared_ptr<std_srvs::srv::Empty::Request>,
84 std::shared_ptr<std_srvs::srv::Empty::Response>)
86 RCLCPP_INFO( get_logger(), "Example service
callback");
89 void Node::example_timer_callback()
91 RCLCPP_DEBUG(get_logger(), "Example timer
callback");
92 std_msgs::msg::String msg;
93 msg.data = "Hello World!
";
94 example_pub_->publish(msg);
97 void Node::example_callback(std_msgs::msg::String::UniquePtr msg)
99 RCLCPP_INFO_STREAM( get_logger(), "example_sub_
callback called with value:
" << msg->data);
102 void Node::plan_maneuvers_callback(
103 std::shared_ptr<rmw_request_id_t>,
104 carma_planning_msgs::srv::PlanManeuvers::Request::SharedPtr req,
105 carma_planning_msgs::srv::PlanManeuvers::Response::SharedPtr resp)
107 // TODO for user: Implement maneuver planning logic here to populate resp based on req.
110 bool Node::get_availability() {
111 return true; // TODO for user implement actual check on availability if applicable to plugin
114 std::string Node::get_version_id() {
115 return "TODO
for user specify plugin version
id here
";
118} // <SUB><package_name>
120#include "rclcpp_components/register_node_macro.hpp
"
122// Register the component with class_loader
123RCLCPP_COMPONENTS_REGISTER_NODE(<SUB><package_name>::Node)
bool callback(cav_srvs::PlanTrajectory::Request &req, cav_srvs::PlanTrajectory::Response &res)