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.
|
A GeofenceScheduler is responsable for notifying the user when a geofence is active or inactive according to its schedule. More...
#include <GeofenceScheduler.hpp>
Public Member Functions | |
GeofenceScheduler (std::shared_ptr< TimerFactory > timerFactory) | |
Constructor which takes in a TimerFactory. Timers from this factory will be used to generate the triggers for goefence activity. More... | |
void | addGeofence (std::shared_ptr< Geofence > gf_ptr) |
Add a geofence to the scheduler. This will cause it to trigger an event when it becomes active or goes inactive according to its schedule. More... | |
void | onGeofenceActive (std::function< void(std::shared_ptr< Geofence >)> active_callback) |
Method which allows the user to set a callback which will be triggered when a geofence becomes active. More... | |
void | onGeofenceInactive (std::function< void(std::shared_ptr< Geofence >)> inactive_callback) |
Method which allows the user to set a callback which will be triggered when a geofence becomes in-active. More... | |
void | clearTimers () |
Clears the expired timers from the memory of this scheduler. More... | |
rcl_clock_type_t | getClockType () |
Get the clock type of the clock being created by the timer factory. More... | |
rclcpp::Time | now () |
Get current time used by scheduler. More... | |
Private Types | |
using | Timer = carma_ros2_utils::timers::Timer |
using | TimerFactory = carma_ros2_utils::timers::TimerFactory |
using | ROSTimerFactory = carma_ros2_utils::timers::ROSTimerFactory |
using | TimerPtr = std::unique_ptr< Timer > |
Private Member Functions | |
uint32_t | nextId () |
Generates the next id to be used for a timer. More... | |
void | startGeofenceCallback (std::shared_ptr< Geofence > gf_ptr, const unsigned int schedule_id, const int32_t timer_id) |
The callback which is triggered when a geofence becomes active This will call the user set active_callback set from the onGeofenceActive function. More... | |
void | endGeofenceCallback (std::shared_ptr< Geofence > gf_ptr, const unsigned int schedule_id, const int32_t timer_id) |
The callback which is triggered when a geofence becomes in-active This will call the user set inactive_callback set from the onGeofenceInactive function. More... | |
Private Attributes | |
std::mutex | mutex_ |
std::shared_ptr< TimerFactory > | timerFactory_ |
std::unordered_map< uint32_t, std::pair< TimerPtr, bool > > | timers_ |
std::unique_ptr< Timer > | deletion_timer_ |
std::function< void(std::shared_ptr< Geofence >)> | active_callback_ |
std::function< void(std::shared_ptr< Geofence >)> | inactive_callback_ |
uint32_t | next_id_ = 0 |
rcl_clock_type_t | clock_type_ = RCL_SYSTEM_TIME |
A GeofenceScheduler is responsable for notifying the user when a geofence is active or inactive according to its schedule.
Definition at line 34 of file GeofenceScheduler.hpp.
|
private |
Definition at line 38 of file GeofenceScheduler.hpp.
|
private |
Definition at line 36 of file GeofenceScheduler.hpp.
|
private |
Definition at line 37 of file GeofenceScheduler.hpp.
|
private |
Definition at line 39 of file GeofenceScheduler.hpp.
carma_wm_ctrl::GeofenceScheduler::GeofenceScheduler | ( | std::shared_ptr< TimerFactory > | timerFactory | ) |
Constructor which takes in a TimerFactory. Timers from this factory will be used to generate the triggers for goefence activity.
timerFactory | A pointer to a TimerFactory which can be used to generate timers for geofence triggers. |
Definition at line 23 of file GeofenceScheduler.cpp.
References clearTimers(), clock_type_, deletion_timer_, nextId(), and timerFactory_.
void carma_wm_ctrl::GeofenceScheduler::addGeofence | ( | std::shared_ptr< Geofence > | gf_ptr | ) |
Add a geofence to the scheduler. This will cause it to trigger an event when it becomes active or goes inactive according to its schedule.
geofence | The geofence to be added |
Definition at line 70 of file GeofenceScheduler.cpp.
References clock_type_, mutex_, nextId(), startGeofenceCallback(), timerFactory_, and timers_.
Referenced by carma_wm_ctrl::WMBroadcaster::scheduleGeofence().
void carma_wm_ctrl::GeofenceScheduler::clearTimers | ( | ) |
Clears the expired timers from the memory of this scheduler.
Definition at line 48 of file GeofenceScheduler.cpp.
References mutex_, and timers_.
Referenced by GeofenceScheduler().
|
private |
The callback which is triggered when a geofence becomes in-active This will call the user set inactive_callback set from the onGeofenceInactive function.
event | The record of the timer event causing this to trigger |
gf | The geofence which is being un-activated |
schedule_id | index number of the schedule being used corresponding to this geofence |
timer_id | The id of the timer which caused this callback to occur |
Definition at line 132 of file GeofenceScheduler.cpp.
References clock_type_, inactive_callback_, mutex_, nextId(), startGeofenceCallback(), timerFactory_, and timers_.
Referenced by startGeofenceCallback().
rcl_clock_type_t carma_wm_ctrl::GeofenceScheduler::getClockType | ( | ) |
Get the clock type of the clock being created by the timer factory.
Definition at line 43 of file GeofenceScheduler.cpp.
References clock_type_.
Referenced by carma_wm_ctrl::WMBroadcaster::addScheduleFromMsg(), and carma_wm_ctrl::WMBroadcaster::controlRequestFromRoute().
|
private |
Generates the next id to be used for a timer.
Definition at line 37 of file GeofenceScheduler.cpp.
References next_id_.
Referenced by GeofenceScheduler(), addGeofence(), endGeofenceCallback(), and startGeofenceCallback().
rclcpp::Time carma_wm_ctrl::GeofenceScheduler::now | ( | ) |
Get current time used by scheduler.
Definition at line 32 of file GeofenceScheduler.cpp.
References timerFactory_.
Referenced by carma_wm_ctrl::WMBroadcaster::pubTCMACK().
void carma_wm_ctrl::GeofenceScheduler::onGeofenceActive | ( | std::function< void(std::shared_ptr< Geofence >)> | active_callback | ) |
Method which allows the user to set a callback which will be triggered when a geofence becomes active.
active_callback | The callback which will be triggered |
Definition at line 169 of file GeofenceScheduler.cpp.
References active_callback_, and mutex_.
Referenced by carma_wm_ctrl::WMBroadcaster::WMBroadcaster().
void carma_wm_ctrl::GeofenceScheduler::onGeofenceInactive | ( | std::function< void(std::shared_ptr< Geofence >)> | inactive_callback | ) |
Method which allows the user to set a callback which will be triggered when a geofence becomes in-active.
inactive_callback | The callback which will be triggered |
Definition at line 175 of file GeofenceScheduler.cpp.
References inactive_callback_, and mutex_.
Referenced by carma_wm_ctrl::WMBroadcaster::WMBroadcaster().
|
private |
The callback which is triggered when a geofence becomes active This will call the user set active_callback set from the onGeofenceActive function.
event | The record of the timer event causing this to trigger |
gf | The geofence which is being activated |
schedule_id | index number of the schedule being used corresponding to this geofence |
timer_id | The id of the timer which caused this callback to occur |
Definition at line 110 of file GeofenceScheduler.cpp.
References active_callback_, endGeofenceCallback(), mutex_, nextId(), timerFactory_, and timers_.
Referenced by addGeofence(), and endGeofenceCallback().
|
private |
Definition at line 45 of file GeofenceScheduler.hpp.
Referenced by onGeofenceActive(), and startGeofenceCallback().
|
private |
Definition at line 48 of file GeofenceScheduler.hpp.
Referenced by GeofenceScheduler(), addGeofence(), endGeofenceCallback(), and getClockType().
|
private |
Definition at line 44 of file GeofenceScheduler.hpp.
Referenced by GeofenceScheduler().
|
private |
Definition at line 46 of file GeofenceScheduler.hpp.
Referenced by endGeofenceCallback(), and onGeofenceInactive().
|
private |
Definition at line 41 of file GeofenceScheduler.hpp.
Referenced by addGeofence(), clearTimers(), endGeofenceCallback(), onGeofenceActive(), onGeofenceInactive(), and startGeofenceCallback().
|
private |
Definition at line 47 of file GeofenceScheduler.hpp.
Referenced by nextId().
|
private |
Definition at line 42 of file GeofenceScheduler.hpp.
Referenced by GeofenceScheduler(), addGeofence(), endGeofenceCallback(), now(), and startGeofenceCallback().
|
private |
Definition at line 43 of file GeofenceScheduler.hpp.
Referenced by addGeofence(), clearTimers(), endGeofenceCallback(), and startGeofenceCallback().