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.
|
Primary logic class for the localization manager node. More...
#include <LocalizationManager.hpp>
Public Types | |
using | PosePublisher = std::function< void(const geometry_msgs::msg::PoseStamped &)> |
using | ManagedInitialPosePublisher = std::function< void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> |
using | StatePublisher = std::function< void(const carma_localization_msgs::msg::LocalizationStatusReport &)> |
using | TimerUniquePtr = std::unique_ptr< carma_ros2_utils::timers::Timer > |
Public Member Functions | |
LocalizationManager (PosePublisher pose_pub, StatePublisher state_pub, ManagedInitialPosePublisher initialpose_pub, const LocalizationManagerConfig &config, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger, std::unique_ptr< carma_ros2_utils::timers::TimerFactory > timer_factory) | |
Constructor. More... | |
void | gnssPoseCallback (const geometry_msgs::msg::PoseStamped::SharedPtr msg) |
Callback for new GNSS messages. More... | |
void | poseAndStatsCallback (const geometry_msgs::msg::PoseStamped::ConstPtr pose, const autoware_msgs::msg::NDTStat::ConstPtr stats) |
Synced callback for the NDT reported pose and status messages. More... | |
void | systemAlertCallback (const carma_msgs::msg::SystemAlert::SharedPtr alert) |
Callback for SystemAlert data. Used to check for lidar failure. More... | |
void | initialPoseCallback (const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg) |
Callback for the initial pose provided by Rviz or some external localization initializer. More... | |
void | posePubTick () |
Timer callback that controls the publication of the selected pose and status report. More... | |
void | stateTransitionCallback (LocalizationState prev_state, LocalizationState new_state, LocalizationSignal signal) |
Callback for when a new state was triggered. Allows creation of entry/exit behavior for states. More... | |
void | timerCallback (const LocalizationState origin_state) |
Callback for timeouts. Used to trigger timeout signals for the state machine. More... | |
LocalizationState | getState () const |
Returns the current localization state. More... | |
void | clearTimers () |
Clears the expired timers from the memory of this scheduler. More... | |
void | setConfig (const LocalizationManagerConfig &config) |
Set config. More... | |
Private Member Functions | |
double | computeNDTFreq (const rclcpp::Time &new_stamp) |
Helper function to both compute the NDT Frequency and update the previous pose timestamp. More... | |
double | computeFreq (const rclcpp::Time &old_stamp, const rclcpp::Time &new_stamp) const |
Helper function to compute the instantaneous frequency between two times. More... | |
uint32_t | nextId () |
Generates the next id to be used for a timer. More... | |
Private Attributes | |
PosePublisher | pose_pub_ |
StatePublisher | state_pub_ |
ManagedInitialPosePublisher | initialpose_pub_ |
LocalizationManagerConfig | config_ |
LocalizationTransitionTable | transition_table_ |
boost::optional< rclcpp::Time > | prev_ndt_stamp_ |
int | lidar_init_sequential_timesteps_counter_ = 0 |
bool | is_sequential_ = false |
boost::optional< geometry_msgs::msg::PoseStamped > | last_raw_gnss_value_ |
boost::optional< tf2::Vector3 > | gnss_offset_ |
boost::optional< geometry_msgs::msg::PoseStamped > | current_pose_ |
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr | logger_ |
std::mutex | mutex_ |
std::unique_ptr< carma_ros2_utils::timers::TimerFactory > | timer_factory_ |
std::unordered_map< uint32_t, std::pair< TimerUniquePtr, bool > > | timers_ |
TimerUniquePtr | current_timer_ |
uint32_t | next_id_ = 0 |
uint32_t | current_timer_id_ |
rcl_clock_type_t | timer_clock_type_ = RCL_SYSTEM_TIME |
Static Private Attributes | |
static const std::unordered_set< std::string > | LIDAR_FAILURE_STRINGS |
The set of strings which mark a lidar failure in a system alert message. More... | |
Primary logic class for the localization manager node.
Definition at line 40 of file LocalizationManager.hpp.
using localization_manager::LocalizationManager::ManagedInitialPosePublisher = std::function<void(const geometry_msgs::msg::PoseWithCovarianceStamped &)> |
Definition at line 45 of file LocalizationManager.hpp.
using localization_manager::LocalizationManager::PosePublisher = std::function<void(const geometry_msgs::msg::PoseStamped &)> |
Definition at line 44 of file LocalizationManager.hpp.
using localization_manager::LocalizationManager::StatePublisher = std::function<void(const carma_localization_msgs::msg::LocalizationStatusReport &)> |
Definition at line 46 of file LocalizationManager.hpp.
using localization_manager::LocalizationManager::TimerUniquePtr = std::unique_ptr<carma_ros2_utils::timers::Timer> |
Definition at line 47 of file LocalizationManager.hpp.
localization_manager::LocalizationManager::LocalizationManager | ( | PosePublisher | pose_pub, |
StatePublisher | state_pub, | ||
ManagedInitialPosePublisher | initialpose_pub, | ||
const LocalizationManagerConfig & | config, | ||
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr | logger, | ||
std::unique_ptr< carma_ros2_utils::timers::TimerFactory > | timer_factory | ||
) |
Constructor.
pose_pub | A callback to trigger publication of the selected pose |
state_pub | A callback to trigger publication of the localization state |
initialpose_pub | A callback to trigger publication of the intial pose |
config | The configuration settings to use for this manager |
logger | Logger interface of node calling manager object |
node_timers | Timer interface of node calling manager object |
Definition at line 26 of file LocalizationManager.cpp.
References localization_manager::LocalizationTransitionTable::setTransitionCallback(), stateTransitionCallback(), timer_clock_type_, timer_factory_, and transition_table_.
void localization_manager::LocalizationManager::clearTimers | ( | ) |
Clears the expired timers from the memory of this scheduler.
Definition at line 206 of file LocalizationManager.cpp.
References mutex_, and timers_.
Referenced by posePubTick().
|
private |
Helper function to compute the instantaneous frequency between two times.
old_stamp | The old timestamp |
new_stamp | The new timestamp |
Definition at line 41 of file LocalizationManager.cpp.
Referenced by computeNDTFreq(), and posePubTick().
|
private |
Helper function to both compute the NDT Frequency and update the previous pose timestamp.
new_stamp | The new pose timestamp |
Definition at line 51 of file LocalizationManager.cpp.
References computeFreq(), config_, localization_manager::LocalizationManagerConfig::ndt_frequency_degraded_threshold, localization_manager::LocalizationManagerConfig::ndt_frequency_fault_threshold, prev_ndt_stamp_, and timer_clock_type_.
Referenced by poseAndStatsCallback().
LocalizationState localization_manager::LocalizationManager::getState | ( | ) | const |
Returns the current localization state.
Definition at line 316 of file LocalizationManager.cpp.
References localization_manager::LocalizationTransitionTable::getState(), and transition_table_.
void localization_manager::LocalizationManager::gnssPoseCallback | ( | const geometry_msgs::msg::PoseStamped::SharedPtr | msg | ) |
Callback for new GNSS messages.
msg | The pose of vehicle in map frame provided by GNSS |
Definition at line 143 of file LocalizationManager.cpp.
References current_pose_, localization_manager::DEGRADED_NO_LIDAR_FIX, localization_manager::LocalizationTransitionTable::getState(), gnss_offset_, localization_manager::INITIAL_POSE, initialpose_pub_, last_raw_gnss_value_, lidar_init_sequential_timesteps_counter_, localization_manager::LocalizationTransitionTable::signal(), transition_table_, and localization_manager::UNINITIALIZED.
Referenced by localization_manager::Node::handle_on_configure().
void localization_manager::LocalizationManager::initialPoseCallback | ( | const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr | msg | ) |
Callback for the initial pose provided by Rviz or some external localization initializer.
msg | The initial pose message |
Definition at line 173 of file LocalizationManager.cpp.
References current_pose_, localization_manager::INITIAL_POSE, initialpose_pub_, lidar_init_sequential_timesteps_counter_, localization_manager::LocalizationTransitionTable::signal(), and transition_table_.
Referenced by localization_manager::Node::handle_on_configure().
|
private |
Generates the next id to be used for a timer.
Definition at line 200 of file LocalizationManager.cpp.
References next_id_.
Referenced by stateTransitionCallback().
void localization_manager::LocalizationManager::poseAndStatsCallback | ( | const geometry_msgs::msg::PoseStamped::ConstPtr | pose, |
const autoware_msgs::msg::NDTStat::ConstPtr | stats | ||
) |
Synced callback for the NDT reported pose and status messages.
pose | The pose reported by NDT matching of the vehicle in the map frame |
stats | The stats reported by NDT matching for the accuracy of the provided pose |
Definition at line 70 of file LocalizationManager.cpp.
References computeNDTFreq(), config_, current_pose_, localization_manager::DEGRADED_NO_LIDAR_FIX, localization_manager::LocalizationManagerConfig::fitness_score_degraded_threshold, localization_manager::LocalizationManagerConfig::fitness_score_fault_threshold, localization_manager::LocalizationTransitionTable::getState(), gnss_offset_, localization_manager::GNSS_WITH_NDT_INIT, localization_manager::GOOD_NDT_FREQ_AND_FITNESS_SCORE, is_sequential_, last_raw_gnss_value_, lidar_init_sequential_timesteps_counter_, localization_manager::LIDAR_INITIALIZED_SWITCH_TO_GPS, localization_manager::LocalizationManagerConfig::localization_mode, localization_manager::LocalizationManagerConfig::ndt_frequency_degraded_threshold, localization_manager::LocalizationManagerConfig::ndt_frequency_fault_threshold, localization_manager::OPERATIONAL, localization_manager::POOR_NDT_FREQ_OR_FITNESS_SCORE, prev_ndt_stamp_, localization_manager::LocalizationManagerConfig::sequential_timesteps_until_gps_operation, localization_manager::LocalizationTransitionTable::signal(), timer_clock_type_, transition_table_, and localization_manager::UNUSABLE_NDT_FREQ_OR_FITNESS_SCORE.
void localization_manager::LocalizationManager::posePubTick | ( | ) |
Timer callback that controls the publication of the selected pose and status report.
Definition at line 263 of file LocalizationManager.cpp.
References clearTimers(), computeFreq(), config_, current_pose_, localization_manager::DEGRADED_NO_LIDAR_FIX, localization_manager::LocalizationTransitionTable::getState(), localization_manager::LocalizationManagerConfig::gnss_data_timeout, localization_manager::GNSS_DATA_TIMEOUT, localization_manager::GNSS_WITH_FIXED_OFFSET, last_raw_gnss_value_, lidar_init_sequential_timesteps_counter_, localization_manager::LocalizationManagerConfig::localization_mode, localization_manager::LocalizationManagerConfig::ndt_frequency_degraded_threshold, localization_manager::LocalizationManagerConfig::ndt_frequency_fault_threshold, localization_manager::OPERATIONAL, localization_manager::POOR_NDT_FREQ_OR_FITNESS_SCORE, pose_pub_, prev_ndt_stamp_, localization_manager::LocalizationTransitionTable::signal(), state_pub_, localization_manager::stateToMsg(), timer_clock_type_, timer_factory_, transition_table_, localization_manager::UNUSABLE_NDT_FREQ_OR_FITNESS_SCORE, localization_manager::LocalizationManagerConfig::x_offset, localization_manager::LocalizationManagerConfig::y_offset, and localization_manager::LocalizationManagerConfig::z_offset.
Referenced by localization_manager::Node::handle_on_configure().
void localization_manager::LocalizationManager::setConfig | ( | const LocalizationManagerConfig & | config | ) |
Set config.
config | localization manager config |
Definition at line 46 of file LocalizationManager.cpp.
References config_.
void localization_manager::LocalizationManager::stateTransitionCallback | ( | LocalizationState | prev_state, |
LocalizationState | new_state, | ||
LocalizationSignal | signal | ||
) |
Callback for when a new state was triggered. Allows creation of entry/exit behavior for states.
prev_state | The previous state |
new_state | The new current state. This should never equal prev_state. |
signal | The signal that triggered the state transition |
Definition at line 227 of file LocalizationManager.cpp.
References localization_manager::LocalizationManagerConfig::auto_initialization_timeout, config_, current_timer_, current_timer_id_, localization_manager::DEGRADED_NO_LIDAR_FIX, gnss_offset_, localization_manager::LocalizationManagerConfig::gnss_only_operation_timeout, localization_manager::INITIALIZING, nextId(), prev_ndt_stamp_, timer_factory_, timerCallback(), and timers_.
Referenced by LocalizationManager().
void localization_manager::LocalizationManager::systemAlertCallback | ( | const carma_msgs::msg::SystemAlert::SharedPtr | alert | ) |
Callback for SystemAlert data. Used to check for lidar failure.
alert | The alert message to evaluate |
Definition at line 181 of file LocalizationManager.cpp.
References LIDAR_FAILURE_STRINGS, localization_manager::LIDAR_SENSOR_FAILURE, localization_manager::LocalizationTransitionTable::signal(), and transition_table_.
Referenced by localization_manager::Node::handle_on_configure().
void localization_manager::LocalizationManager::timerCallback | ( | const LocalizationState | origin_state | ) |
Callback for timeouts. Used to trigger timeout signals for the state machine.
origin_state | The state that was the current state when the timer that triggered this callback was setup |
Definition at line 189 of file LocalizationManager.cpp.
References localization_manager::LocalizationTransitionTable::getState(), localization_manager::LocalizationTransitionTable::signal(), localization_manager::TIMEOUT, and transition_table_.
Referenced by stateTransitionCallback().
|
private |
Definition at line 144 of file LocalizationManager.hpp.
Referenced by computeNDTFreq(), poseAndStatsCallback(), posePubTick(), setConfig(), and stateTransitionCallback().
|
private |
Definition at line 154 of file LocalizationManager.hpp.
Referenced by gnssPoseCallback(), initialPoseCallback(), poseAndStatsCallback(), and posePubTick().
|
private |
Definition at line 163 of file LocalizationManager.hpp.
Referenced by stateTransitionCallback().
|
private |
Definition at line 165 of file LocalizationManager.hpp.
Referenced by stateTransitionCallback().
|
private |
Definition at line 153 of file LocalizationManager.hpp.
Referenced by gnssPoseCallback(), poseAndStatsCallback(), and stateTransitionCallback().
|
private |
Definition at line 142 of file LocalizationManager.hpp.
Referenced by gnssPoseCallback(), and initialPoseCallback().
|
private |
Definition at line 151 of file LocalizationManager.hpp.
Referenced by poseAndStatsCallback().
|
private |
Definition at line 152 of file LocalizationManager.hpp.
Referenced by gnssPoseCallback(), poseAndStatsCallback(), and posePubTick().
|
staticprivate |
The set of strings which mark a lidar failure in a system alert message.
Definition at line 138 of file LocalizationManager.hpp.
Referenced by systemAlertCallback().
|
private |
Definition at line 150 of file LocalizationManager.hpp.
Referenced by gnssPoseCallback(), initialPoseCallback(), poseAndStatsCallback(), and posePubTick().
|
private |
Definition at line 157 of file LocalizationManager.hpp.
|
private |
Definition at line 160 of file LocalizationManager.hpp.
Referenced by clearTimers().
|
private |
Definition at line 164 of file LocalizationManager.hpp.
Referenced by nextId().
|
private |
Definition at line 140 of file LocalizationManager.hpp.
Referenced by posePubTick().
|
private |
Definition at line 148 of file LocalizationManager.hpp.
Referenced by computeNDTFreq(), poseAndStatsCallback(), posePubTick(), and stateTransitionCallback().
|
private |
Definition at line 141 of file LocalizationManager.hpp.
Referenced by posePubTick().
|
private |
Definition at line 166 of file LocalizationManager.hpp.
Referenced by LocalizationManager(), computeNDTFreq(), poseAndStatsCallback(), and posePubTick().
|
private |
Definition at line 161 of file LocalizationManager.hpp.
Referenced by LocalizationManager(), posePubTick(), and stateTransitionCallback().
|
private |
Definition at line 162 of file LocalizationManager.hpp.
Referenced by clearTimers(), and stateTransitionCallback().
|
private |
Definition at line 146 of file LocalizationManager.hpp.
Referenced by LocalizationManager(), getState(), gnssPoseCallback(), initialPoseCallback(), poseAndStatsCallback(), posePubTick(), systemAlertCallback(), and timerCallback().