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.
mock_drivers::MockRoadwaySensorDriver Class Reference

Mock Roadway Sensor driver. Operates as a passthrough for bag data which updates the timestamps on received messages *‍/. More...

#include <MockRoadwaySensorDriver.h>

Inheritance diagram for mock_drivers::MockRoadwaySensorDriver:
Inheritance graph
Collaboration diagram for mock_drivers::MockRoadwaySensorDriver:
Collaboration graph

Public Member Functions

 MockRoadwaySensorDriver (bool dummy=false)
 
 ~MockRoadwaySensorDriver ()
 
std::vector< DriverTypegetDriverTypes () override
 Pure Virtual method which child classes must override that returns the list of all driver types that class implements. More...
 
uint8_t getDriverStatus () override
 Pure Virtual method. Returns an integer value which corresponds to the cav_msgs/DriverStatus enum felids representing the status of the driver. More...
 
unsigned int getRate () override
 Pure virtual method that returns the desired operational rate of a child class. More...
 
- Public Member Functions inherited from mock_drivers::MockDriver
virtual ~MockDriver ()=0
 
int run ()
 A function to initialize the publishers and subsricers and start the node. In child classes, this function will trigger a call to onRun(). More...
 
virtual std::vector< DriverTypegetDriverTypes ()=0
 Pure Virtual method which child classes must override that returns the list of all driver types that class implements. More...
 
virtual uint8_t getDriverStatus ()=0
 Pure Virtual method. Returns an integer value which corresponds to the cav_msgs/DriverStatus enum felids representing the status of the driver. More...
 
virtual unsigned int getRate ()=0
 Pure virtual method that returns the desired operational rate of a child class. More...
 
bool spinCallback ()
 Callback which will be triggered at the rate specified by getRate(). This callback will also trigger the onSpin() method. More...
 

Protected Member Functions

int onRun () override
 Pure virtual method which must be implemented by child classes. This method will be run once at startup. Child classes should add pub/sub initialization in this method implementation. More...
 
- Protected Member Functions inherited from mock_drivers::MockDriver
virtual bool onSpin ()
 Virtual method which child classes can override to add functionality which will occur during each spin loop. This means this function will be nominally called at the rate specified by getRate() More...
 
virtual int onRun ()=0
 Pure virtual method which must be implemented by child classes. This method will be run once at startup. Child classes should add pub/sub initialization in this method implementation. More...
 
void driverDiscovery ()
 Helper function to publish the driver discovery message. More...
 
MockDriverNode getMockDriverNode () const
 Returns the mock driver node for the mock driver (used for testing) More...
 
template<typename T >
void addPassthroughPub (const std::string &sub_topic, const std::string &pub_topic, bool latch, size_t queue_size)
 Function adds both a publisher and subscriber of the specified type. This means a passthrough subscription has been created. This version of the method should be used for message types which contain a Header at the field "header". The header field will be automatically updated to the current ros::Time::now(). More...
 
template<typename T >
void addPassthroughPubNoHeader (const std::string &sub_topic, const std::string &pub_topic, bool latch, size_t queue_size)
 Function adds both a publisher and subscriber of the specified type. This means a passthrough subscription has been created. This version of the method should be used for message types which does NOT contain a Header at the field "header". More...
 

Private Attributes

const std::string detected_objects_topic_ = "roadway_sensor/detected_objects"
 
const std::string lane_models_topics_ = "roadway_sensor/lane_models"
 

Additional Inherited Members

- Protected Types inherited from mock_drivers::MockDriver
template<class T >
using ConstPtr = boost::shared_ptr< const T >
 
template<class T >
using ConstPtrRef = const ConstPtr< T > &
 
template<class T >
using ROSCommsPtr = boost::shared_ptr< ROSComms< T > >
 
template<class T >
using ConstPtrRefROSComms = ROSComms< ConstPtrRef< T > >
 
template<class T >
using ConstPtrRefROSCommsPtr = ROSCommsPtr< ConstPtrRef< T > >
 
- Protected Attributes inherited from mock_drivers::MockDriver
MockDriverNode mock_driver_node_
 
const std::string bag_prefix_ = "/bag/hardware_interface/"
 
const std::string driver_discovery_topic_ = "driver_discovery"
 
ROSCommsPtr< cav_msgs::DriverStatus > driver_discovery_pub_ptr_
 
ros::Time last_discovery_pub_ = ros::Time(0)
 

Detailed Description

Mock Roadway Sensor driver. Operates as a passthrough for bag data which updates the timestamps on received messages *‍/.

Definition at line 26 of file MockRoadwaySensorDriver.h.

Constructor & Destructor Documentation

◆ MockRoadwaySensorDriver()

mock_drivers::MockRoadwaySensorDriver::MockRoadwaySensorDriver ( bool  dummy = false)

Definition at line 31 of file MockRoadwaySensorDriver.cpp.

32{
33 mock_driver_node_ = MockDriverNode(dummy);
34}
MockDriverNode mock_driver_node_
Definition: MockDriver.h:59

References mock_drivers::MockDriver::mock_driver_node_.

◆ ~MockRoadwaySensorDriver()

mock_drivers::MockRoadwaySensorDriver::~MockRoadwaySensorDriver ( )
inline

Definition at line 37 of file MockRoadwaySensorDriver.h.

37{};

Member Function Documentation

◆ getDriverStatus()

uint8_t mock_drivers::MockRoadwaySensorDriver::getDriverStatus ( )
overridevirtual

Pure Virtual method. Returns an integer value which corresponds to the cav_msgs/DriverStatus enum felids representing the status of the driver.

Returns
Integer value which must match one of the enum fields in cav_msgs/DriverStatus

Implements mock_drivers::MockDriver.

Definition at line 26 of file MockRoadwaySensorDriver.cpp.

27{
28 return cav_msgs::DriverStatus::OPERATIONAL;
29}

◆ getDriverTypes()

std::vector< DriverType > mock_drivers::MockRoadwaySensorDriver::getDriverTypes ( )
overridevirtual

Pure Virtual method which child classes must override that returns the list of all driver types that class implements.

Returns
A list of DriverType that defines the interfaces the implementing class provides

Implements mock_drivers::MockDriver.

Definition at line 21 of file MockRoadwaySensorDriver.cpp.

22{
24}

References ROADWAY_SENSOR.

◆ getRate()

unsigned int mock_drivers::MockRoadwaySensorDriver::getRate ( )
overridevirtual

Pure virtual method that returns the desired operational rate of a child class.

Returns
Spin rate in Hz

Implements mock_drivers::MockDriver.

Definition at line 36 of file MockRoadwaySensorDriver.cpp.

37{
38 return 20; // 20 Hz as default spin rate to match expected roadway data rate
39}

◆ onRun()

int mock_drivers::MockRoadwaySensorDriver::onRun ( )
overrideprotectedvirtual

Pure virtual method which must be implemented by child classes. This method will be run once at startup. Child classes should add pub/sub initialization in this method implementation.

Returns
An integer error code. A non-zero value will indicate an initialization failure and result in node shutdown.

Implements mock_drivers::MockDriver.

Definition at line 41 of file MockRoadwaySensorDriver.cpp.

42{
43 // driver publishers
44 addPassthroughPub<derived_object_msgs::ObjectWithCovariance>(bag_prefix_ + detected_objects_topic_,
45 detected_objects_topic_, false, 10);
46 addPassthroughPub<derived_object_msgs::LaneModels>(bag_prefix_ + lane_models_topics_, lane_models_topics_, false, 10);
47
48 return 0;
49}
const std::string bag_prefix_
Definition: MockDriver.h:63

References mock_drivers::MockDriver::bag_prefix_, detected_objects_topic_, and lane_models_topics_.

Member Data Documentation

◆ detected_objects_topic_

const std::string mock_drivers::MockRoadwaySensorDriver::detected_objects_topic_ = "roadway_sensor/detected_objects"
private

Definition at line 29 of file MockRoadwaySensorDriver.h.

Referenced by onRun().

◆ lane_models_topics_

const std::string mock_drivers::MockRoadwaySensorDriver::lane_models_topics_ = "roadway_sensor/lane_models"
private

Definition at line 30 of file MockRoadwaySensorDriver.h.

Referenced by onRun().


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