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.
guidance_worker.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17#pragma once
18
19#include <rclcpp/rclcpp.hpp>
20#include <functional>
21#include <carma_planning_msgs/srv/set_guidance_active.hpp>
22#include <carma_driver_msgs/srv/set_enable_robotic.hpp>
23#include <carma_planning_msgs/msg/guidance_state.hpp>
24#include <carma_driver_msgs/msg/robot_enabled.hpp>
25#include <carma_planning_msgs/msg/route_event.hpp>
26#include <autoware_msgs/msg/vehicle_status.hpp>
28
29#include <carma_ros2_utils/carma_lifecycle_node.hpp>
31
32namespace guidance
33{
34
39 class GuidanceWorker : public carma_ros2_utils::CarmaLifecycleNode
40 {
41
42 private:
43 // Subscribers
44 carma_ros2_utils::SubPtr<carma_driver_msgs::msg::RobotEnabled> robot_status_subscriber_;
45 carma_ros2_utils::SubPtr<carma_planning_msgs::msg::RouteEvent> route_event_subscriber_;
46 carma_ros2_utils::SubPtr<autoware_msgs::msg::VehicleStatus> vehicle_status_subscriber_;
47
48 // Publishers
49 carma_ros2_utils::PubPtr<carma_planning_msgs::msg::GuidanceState> state_publisher_;
50
51 // Service Clients
52 carma_ros2_utils::ClientPtr<carma_driver_msgs::srv::SetEnableRobotic> enable_client_;
53
54 // Service Servers
55 carma_ros2_utils::ServicePtr<carma_planning_msgs::srv::SetGuidanceActive> guidance_activate_service_server_;
56
57 // Timers
58 rclcpp::TimerBase::SharedPtr spin_timer_;
59
60 // Node configuration
62
63 // Guidance state machine
65
66 public:
70 explicit GuidanceWorker(const rclcpp::NodeOptions &);
71
75 rcl_interfaces::msg::SetParametersResult
76 parameter_update_callback(const std::vector<rclcpp::Parameter> &parameters);
77
81 bool spin_cb();
82
87 void route_event_cb(carma_planning_msgs::msg::RouteEvent::UniquePtr msg);
88
93 void robot_status_cb(carma_driver_msgs::msg::RobotEnabled::UniquePtr msg);
94
99 void vehicle_status_cb(const autoware_msgs::msg::VehicleStatus::UniquePtr msg);
100
106 bool guidance_activation_cb(const std::shared_ptr<rmw_request_id_t>,
107 const std::shared_ptr<carma_planning_msgs::srv::SetGuidanceActive::Request> req,
108 std::shared_ptr<carma_planning_msgs::srv::SetGuidanceActive::Response> resp);
109
111 // Overrides
113 carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &prev_state);
114 carma_ros2_utils::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &);
115 carma_ros2_utils::CallbackReturn handle_on_shutdown(const rclcpp_lifecycle::State &prev_state);
116 };
117
118} // guidance
Worker class for the Guidance node.
bool spin_cb()
Timer callback.
void route_event_cb(carma_planning_msgs::msg::RouteEvent::UniquePtr msg)
Callback for route event messages.
rclcpp::TimerBase::SharedPtr spin_timer_
carma_ros2_utils::SubPtr< autoware_msgs::msg::VehicleStatus > vehicle_status_subscriber_
carma_ros2_utils::CallbackReturn handle_on_activate(const rclcpp_lifecycle::State &)
carma_ros2_utils::SubPtr< carma_driver_msgs::msg::RobotEnabled > robot_status_subscriber_
carma_ros2_utils::ServicePtr< carma_planning_msgs::srv::SetGuidanceActive > guidance_activate_service_server_
GuidanceStateMachine gsm_
carma_ros2_utils::CallbackReturn handle_on_shutdown(const rclcpp_lifecycle::State &prev_state)
GuidanceWorker(const rclcpp::NodeOptions &)
GuidanceWorker constructor.
void robot_status_cb(carma_driver_msgs::msg::RobotEnabled::UniquePtr msg)
Callback for robot enabled messages.
rcl_interfaces::msg::SetParametersResult parameter_update_callback(const std::vector< rclcpp::Parameter > &parameters)
Callback for dynamic parameter updates.
carma_ros2_utils::ClientPtr< carma_driver_msgs::srv::SetEnableRobotic > enable_client_
carma_ros2_utils::PubPtr< carma_planning_msgs::msg::GuidanceState > state_publisher_
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &prev_state)
carma_ros2_utils::SubPtr< carma_planning_msgs::msg::RouteEvent > route_event_subscriber_
void vehicle_status_cb(const autoware_msgs::msg::VehicleStatus::UniquePtr msg)
Callback for vehicle status messages.
bool guidance_activation_cb(const std::shared_ptr< rmw_request_id_t >, const std::shared_ptr< carma_planning_msgs::srv::SetGuidanceActive::Request > req, std::shared_ptr< carma_planning_msgs::srv::SetGuidanceActive::Response > resp)
Set_guidance_active service callback. User can attempt to activate the guidance system by calling thi...
Stuct containing the algorithm configuration values for GuidanceWorker.