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.
subsystem_controllers::DriverManager Class Reference

The DriverManager serves as a component to manage CARMA required ROS1 Drivers. More...

#include <driver_manager.hpp>

Collaboration diagram for subsystem_controllers::DriverManager:
Collaboration graph

Public Member Functions

 DriverManager ()
 Default constructor for DriverManager with driver_timeout_ = 1000ms. More...
 
 DriverManager (const std::vector< std::string > &critical_driver_names, const std::vector< std::string > &camera_entries, const long driver_timeout)
 Constructor for DriverManager. More...
 
void update_driver_status (const carma_driver_msgs::msg::DriverStatus::SharedPtr msg, long current_time)
 Update driver status. More...
 
std::string are_critical_drivers_operational (long current_time)
 Check if all critical drivers are operational. More...
 
void evaluate_sensor (int &sensor_input, bool available, long current_time, long timestamp, long driver_timeout)
 Evaluate if the sensor is available. More...
 
carma_msgs::msg::SystemAlert handle_spin (long time_now, long start_up_timestamp, long startup_duration)
 Handle the spin and publisher. More...
 

Protected Member Functions

 FRIEND_TEST (DriverManagerTest, testCarTruckHandleSpinFatalUnknown)
 

Protected Attributes

std::vector< std::string > critical_drivers_
 
std::vector< std::string > camera_entries_
 
std::shared_ptr< EntryManagerem_
 Entry manager to keep track of detected plugins. More...
 
long driver_timeout_ = 1000
 
bool starting_up_ = true
 

Detailed Description

The DriverManager serves as a component to manage CARMA required ROS1 Drivers.

Definition at line 44 of file driver_manager.hpp.

Constructor & Destructor Documentation

◆ DriverManager() [1/2]

subsystem_controllers::DriverManager::DriverManager ( )

Default constructor for DriverManager with driver_timeout_ = 1000ms.

Definition at line 29 of file driver_manager.cpp.

29{}

◆ DriverManager() [2/2]

subsystem_controllers::DriverManager::DriverManager ( const std::vector< std::string > &  critical_driver_names,
const std::vector< std::string > &  camera_entries,
const long  driver_timeout 
)

Constructor for DriverManager.

Parameters
critical_driver_namesThe set of drivers which will be treated as required. A failure in these plugins will result in an exception
camera_entriesThe set of camera drivers.
driver_timeoutThe timeout threshold for essential drivers

Definition at line 31 of file driver_manager.cpp.

34 : critical_drivers_(critical_driver_names.begin(), critical_driver_names.end()),
35 camera_entries_(camera_entries.begin(), camera_entries.end()),
36 driver_timeout_(driver_timeout)
37 {
38 // Intialize entry manager
39 em_ = std::make_shared<EntryManager>(critical_driver_names, camera_entries);
40
41 }
std::vector< std::string > camera_entries_
std::shared_ptr< EntryManager > em_
Entry manager to keep track of detected plugins.
std::vector< std::string > critical_drivers_

References em_.

Member Function Documentation

◆ are_critical_drivers_operational()

std::string subsystem_controllers::DriverManager::are_critical_drivers_operational ( long  current_time)

Check if all critical drivers are operational.

Definition at line 108 of file driver_manager.cpp.

109 {
110 int ssc=0;
111 int camera=0;
112
113 std::vector<Entry> driver_list = em_->get_entries(); //Real time driver list from driver status
114 for(auto i = driver_list.begin(); i < driver_list.end(); ++i)
115 {
116 RCLCPP_DEBUG_STREAM(rclcpp::get_logger("subsystem_controller"), "i->name_: " << i->name_
117 << ", current_time: " << current_time
118 << ", i->timestamp_: " << i->timestamp_
119 << ", difference: " << current_time-(i->timestamp_) );
120 if(em_->is_entry_required(i->name_))
121 {
122 evaluate_sensor(ssc,i->available_,current_time,i->timestamp_,driver_timeout_);
123 }
124 else if(em_->is_camera_entry_required(i->name_)==0)
125 {
126 evaluate_sensor(camera,i->available_,current_time,i->timestamp_,driver_timeout_);
127 }
128 }
129
130 // Manual disable of ssc entry in case ssc wrapper is in ros2
131 if (critical_drivers_.empty())
132 {
133 ssc = 1;
134 }
135
137 //Decision making
138 if (ssc == 1 && camera == 1)
139 {
140 return "s_1_c_1";
141 }
142 else if (ssc == 1 && camera == 0)
143 {
144 return "s_1_c_0";
145 }
146 else{
147 return "s_0";
148 }
149
150
151 }
void evaluate_sensor(int &sensor_input, bool available, long current_time, long timestamp, long driver_timeout)
Evaluate if the sensor is available.

References critical_drivers_, driver_timeout_, em_, evaluate_sensor(), and process_bag::i.

Referenced by handle_spin().

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

◆ evaluate_sensor()

void subsystem_controllers::DriverManager::evaluate_sensor ( int &  sensor_input,
bool  available,
long  current_time,
long  timestamp,
long  driver_timeout 
)

Evaluate if the sensor is available.

Definition at line 94 of file driver_manager.cpp.

95 {
96
97 if((!available) || (current_time-timestamp > driver_timeout))
98 {
99 sensor_input=0;
100 }
101 else
102 {
103 sensor_input=1;
104 }
105
106 }

Referenced by are_critical_drivers_operational().

Here is the caller graph for this function:

◆ FRIEND_TEST()

subsystem_controllers::DriverManager::FRIEND_TEST ( DriverManagerTest  ,
testCarTruckHandleSpinFatalUnknown   
)
protected

◆ handle_spin()

carma_msgs::msg::SystemAlert subsystem_controllers::DriverManager::handle_spin ( long  time_now,
long  start_up_timestamp,
long  startup_duration 
)

Handle the spin and publisher.

Definition at line 44 of file driver_manager.cpp.

45 {
46 carma_msgs::msg::SystemAlert alert;
47
48 std::string status = are_critical_drivers_operational(time_now);
49 if(status.compare("s_1_c_1") == 0)
50 {
51 starting_up_ = false;
52 alert.description = "All essential drivers are ready";
53 alert.type = carma_msgs::msg::SystemAlert::DRIVERS_READY;
54 return alert;
55 }
56 else if(starting_up_ && (time_now - start_up_timestamp <= startup_duration))
57 {
58 alert.description = "System is starting up...";
59 alert.type = carma_msgs::msg::SystemAlert::NOT_READY;
60 return alert;
61 }
62 else if(status.compare("s_1_c_0")==0)
63 {
64 alert.description = "Camera Failed";
66 return alert;
67 }
68 else if(status.compare("s_0") == 0)
69 {
70 alert.description = "SSC Failed";
72 return alert;
73 }
74 else
75 {
76 alert.description = "Unknown problem assessing essential driver availability";
77 alert.type = carma_msgs::msg::SystemAlert::FATAL;
78 return alert;
79 }
80
81 }
std::string are_critical_drivers_operational(long current_time)
Check if all critical drivers are operational.

References are_critical_drivers_operational(), arbitrator::SHUTDOWN, and starting_up_.

Here is the call graph for this function:

◆ update_driver_status()

void subsystem_controllers::DriverManager::update_driver_status ( const carma_driver_msgs::msg::DriverStatus::SharedPtr  msg,
long  current_time 
)

Update driver status.

Definition at line 84 of file driver_manager.cpp.

85 {
86 // update driver status is only called in response to a message received on driver_discovery. This topic is only being published in ros1
87 Entry driver_status(msg->status == carma_driver_msgs::msg::DriverStatus::OPERATIONAL || msg->status == carma_driver_msgs::msg::DriverStatus::DEGRADED,
88 msg->name,current_time);
89
90 em_->update_entry(driver_status);
91 }

References em_.

Member Data Documentation

◆ camera_entries_

std::vector<std::string> subsystem_controllers::DriverManager::camera_entries_
protected

Definition at line 91 of file driver_manager.hpp.

◆ critical_drivers_

std::vector<std::string> subsystem_controllers::DriverManager::critical_drivers_
protected

Definition at line 88 of file driver_manager.hpp.

Referenced by are_critical_drivers_operational().

◆ driver_timeout_

long subsystem_controllers::DriverManager::driver_timeout_ = 1000
protected

Definition at line 97 of file driver_manager.hpp.

Referenced by are_critical_drivers_operational().

◆ em_

std::shared_ptr<EntryManager> subsystem_controllers::DriverManager::em_
protected

Entry manager to keep track of detected plugins.

Definition at line 94 of file driver_manager.hpp.

Referenced by DriverManager(), are_critical_drivers_operational(), and update_driver_status().

◆ starting_up_

bool subsystem_controllers::DriverManager::starting_up_ = true
protected

Definition at line 99 of file driver_manager.hpp.

Referenced by handle_spin().


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