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.
driver_manager.hpp
Go to the documentation of this file.
1#pragma once
2
3/*
4 * Copyright (C) 2023 LEIDOS.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy of
8 * the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations under
16 * the License.
17 */
18
19#include <carma_planning_msgs/msg/plugin.hpp>
20#include <carma_planning_msgs/srv/get_plugin_api.hpp>
21#include <carma_planning_msgs/srv/plugin_list.hpp>
22#include <carma_planning_msgs/srv/plugin_activation.hpp>
23#include <ros2_lifecycle_manager/lifecycle_manager_interface.hpp>
24#include <unordered_set>
25#include <functional>
26#include <vector>
27#include <memory>
28#include <chrono>
29#include <rmw/types.h>
30#include <map>
31#include "entry_manager.hpp"
32#include "entry.hpp"
33#include <carma_driver_msgs/msg/driver_status.hpp>
34#include <carma_msgs/msg/system_alert.hpp>
35#include <gtest/gtest_prod.h>
36
37
39{
40
45 {
46 public:
47
52
60 DriverManager(const std::vector<std::string>& critical_driver_names,
61 const std::vector<std::string>& camera_entries,
62 const long driver_timeout);
63
64
68 void update_driver_status(const carma_driver_msgs::msg::DriverStatus::SharedPtr msg, long current_time);
69
73 std::string are_critical_drivers_operational(long current_time);
74
78 void evaluate_sensor(int &sensor_input,bool available,long current_time,long timestamp,long driver_timeout);
79
83 carma_msgs::msg::SystemAlert handle_spin(long time_now,long start_up_timestamp,long startup_duration);
84
85 protected:
86
87 //list of critical drivers
88 std::vector<std::string> critical_drivers_;
89
90 //list of camera entries
91 std::vector<std::string> camera_entries_;
92
94 std::shared_ptr<EntryManager> em_;
95
96 // timeout for critical driver timeout in milliseconds
97 long driver_timeout_ = 1000;
98
99 bool starting_up_ = true;
100
101 FRIEND_TEST(DriverManagerTest, testCarTruckHandleSpinFatalUnknown);
102
103 };
104}
The DriverManager serves as a component to manage CARMA required ROS1 Drivers.
void update_driver_status(const carma_driver_msgs::msg::DriverStatus::SharedPtr msg, long current_time)
Update driver status.
std::string are_critical_drivers_operational(long current_time)
Check if all critical drivers are operational.
FRIEND_TEST(DriverManagerTest, testCarTruckHandleSpinFatalUnknown)
std::vector< std::string > camera_entries_
carma_msgs::msg::SystemAlert handle_spin(long time_now, long start_up_timestamp, long startup_duration)
Handle the spin and publisher.
std::shared_ptr< EntryManager > em_
Entry manager to keep track of detected plugins.
std::vector< std::string > critical_drivers_
void evaluate_sensor(int &sensor_input, bool available, long current_time, long timestamp, long driver_timeout)
Evaluate if the sensor is available.
DriverManager()
Default constructor for DriverManager with driver_timeout_ = 1000ms.