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::SSCDriverManager Class Reference

The SSCDriverManager serves as a component to manage ROS1 SSC Driver in CARMA which is primarily in ROS2. More...

#include <ssc_driver_manager.hpp>

Collaboration diagram for subsystem_controllers::SSCDriverManager:
Collaboration graph

Public Member Functions

 SSCDriverManager ()
 Default constructor for SSCDriverManager with driver_timeout_ = 1000ms. More...
 
 SSCDriverManager (const std::string &ssc_driver_name, const long driver_timeout)
 Constructor for SSCDriverManager. More...
 
void update_driver_status (const carma_driver_msgs::msg::DriverStatus::SharedPtr msg, long current_time)
 Update driver status. More...
 
bool is_ssc_driver_operational (long current_time)
 Check if all critical drivers are operational. More...
 
carma_msgs::msg::SystemAlert get_latest_system_alert (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::string ssc_driver_name_ = ""
 
std::shared_ptr< Entrylatest_ssc_status_entry_ = std::make_shared<Entry>()
 Latest SSC Status entry to keep track. More...
 
long driver_timeout_ = 1000
 
bool starting_up_ = true
 

Detailed Description

The SSCDriverManager serves as a component to manage ROS1 SSC Driver in CARMA which is primarily in ROS2.

Definition at line 45 of file ssc_driver_manager.hpp.

Constructor & Destructor Documentation

◆ SSCDriverManager() [1/2]

subsystem_controllers::SSCDriverManager::SSCDriverManager ( )

Default constructor for SSCDriverManager with driver_timeout_ = 1000ms.

Definition at line 29 of file ssc_driver_manager.cpp.

29{}

◆ SSCDriverManager() [2/2]

subsystem_controllers::SSCDriverManager::SSCDriverManager ( const std::string &  ssc_driver_name,
const long  driver_timeout 
)

Constructor for SSCDriverManager.

Parameters
ssc_driver_nameThe driver name which will be treated as required. A failure in this plugin will result in an exception
driver_timeoutThe timeout threshold for the driver

Definition at line 31 of file ssc_driver_manager.cpp.

Member Function Documentation

◆ FRIEND_TEST()

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

◆ get_latest_system_alert()

carma_msgs::msg::SystemAlert subsystem_controllers::SSCDriverManager::get_latest_system_alert ( long  time_now,
long  start_up_timestamp,
long  startup_duration 
)

Handle the spin and publisher.

Definition at line 36 of file ssc_driver_manager.cpp.

38{
39 carma_msgs::msg::SystemAlert alert;
40
41 bool ssc_is_operational = is_ssc_driver_operational(time_now);
42 if (ssc_is_operational) {
43 starting_up_ = false;
44 alert.description = "All essential drivers are ready";
45 alert.type = carma_msgs::msg::SystemAlert::DRIVERS_READY;
46 return alert;
47 } else if (starting_up_ && (time_now - start_up_timestamp <= startup_duration)) {
48 alert.description = "System is starting up...";
49 alert.type = carma_msgs::msg::SystemAlert::NOT_READY;
50 return alert;
51 } else if (!ssc_is_operational) {
52 alert.description = "SSC Failed";
54 return alert;
55 } else {
56 alert.description = "Unknown problem assessing SSC driver availability";
57 alert.type = carma_msgs::msg::SystemAlert::FATAL;
58 return alert;
59 }
60}
bool is_ssc_driver_operational(long current_time)
Check if all critical drivers are operational.

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

Here is the call graph for this function:

◆ is_ssc_driver_operational()

bool subsystem_controllers::SSCDriverManager::is_ssc_driver_operational ( long  current_time)

Check if all critical drivers are operational.

Definition at line 78 of file ssc_driver_manager.cpp.

79{
80 // Manual disable of ssc entry in case ssc wrapper is in ros2
81 if (ssc_driver_name_.empty()) {
82 return true;
83 }
84
85 // No entry recorded, then return false
87 return false;
88 }
89
90 RCLCPP_DEBUG_STREAM(
91 rclcpp::get_logger("subsystem_controller"),
92 "latest_ssc_status_entry_->name_: "
93 << latest_ssc_status_entry_->name_ << ", current_time: " << current_time
94 << ", latest_ssc_status_entry_->timestamp_: " << latest_ssc_status_entry_->timestamp_
95 << ", difference: " << current_time - (latest_ssc_status_entry_->timestamp_));
96
97 // Detect whether if available or timed out
98 if (
99 (!latest_ssc_status_entry_->available_) ||
100 (current_time - latest_ssc_status_entry_->timestamp_ > driver_timeout_)) {
101 return false;
102 } else {
103 return true;
104 }
105}
std::shared_ptr< Entry > latest_ssc_status_entry_
Latest SSC Status entry to keep track.

References driver_timeout_, latest_ssc_status_entry_, and ssc_driver_name_.

Referenced by get_latest_system_alert().

Here is the caller graph for this function:

◆ update_driver_status()

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

Update driver status.

Definition at line 62 of file ssc_driver_manager.cpp.

64{
65 // update driver status is only called in response to a message received on driver_discovery.
66 // This topic is only being published in ros1. Check only SSC
67
68 if (ssc_driver_name_ == msg->name) {
69 Entry driver_status(
70 msg->status == carma_driver_msgs::msg::DriverStatus::OPERATIONAL ||
71 msg->status == carma_driver_msgs::msg::DriverStatus::DEGRADED,
72 msg->name, current_time);
73
74 latest_ssc_status_entry_ = std::make_shared<Entry>(driver_status);
75 }
76}

References latest_ssc_status_entry_, and ssc_driver_name_.

Member Data Documentation

◆ driver_timeout_

long subsystem_controllers::SSCDriverManager::driver_timeout_ = 1000
protected

Definition at line 87 of file ssc_driver_manager.hpp.

Referenced by is_ssc_driver_operational().

◆ latest_ssc_status_entry_

std::shared_ptr<Entry> subsystem_controllers::SSCDriverManager::latest_ssc_status_entry_ = std::make_shared<Entry>()
protected

Latest SSC Status entry to keep track.

Definition at line 84 of file ssc_driver_manager.hpp.

Referenced by is_ssc_driver_operational(), and update_driver_status().

◆ ssc_driver_name_

std::string subsystem_controllers::SSCDriverManager::ssc_driver_name_ = ""
protected

Definition at line 81 of file ssc_driver_manager.hpp.

Referenced by is_ssc_driver_operational(), and update_driver_status().

◆ starting_up_

bool subsystem_controllers::SSCDriverManager::starting_up_ = true
protected

Definition at line 89 of file ssc_driver_manager.hpp.

Referenced by get_latest_system_alert().


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