17#include <boost/bind.hpp>
18#include <boost/bind/placeholders.hpp>
19#include <carma_ros2_utils/timers/ROSTimerFactory.hpp>
23 namespace std_ph = std::placeholders;
26 : carma_ros2_utils::CarmaLifecycleNode(options)
68 RCLCPP_INFO_STREAM(rclcpp::get_logger(
"localization_manager"),
"Loaded params: ");
75 get_node_logging_interface(),
76 std::make_unique<carma_ros2_utils::timers::ROSTimerFactory>(shared_from_this())));
82 gnss_pose_sub_ = create_subscription<geometry_msgs::msg::PoseStamped>(
"gnss_pose", 5,
84 initialpose_sub_ = create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"initialpose", 1,
89 ndt_pose_sub_.subscribe(
this,
"ndt_pose", qos.get_rmw_qos_profile());
90 ndt_score_sub_.subscribe(
this,
"ndt_stat", qos.get_rmw_qos_profile());
96 system_alert_sub_ = create_subscription<carma_msgs::msg::SystemAlert>(system_alert_topic_, 1,
99 pose_pub_ = create_publisher<geometry_msgs::msg::PoseStamped>(
"selected_pose", 5);
100 state_pub_ = create_publisher<carma_localization_msgs::msg::LocalizationStatusReport>(
"localization_status", 5);
103 rclcpp::PublisherOptions intra_proc_disabled;
104 intra_proc_disabled.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable;
106 auto pub_qos_transient_local = rclcpp::QoS(rclcpp::KeepLast(1));
107 pub_qos_transient_local.transient_local();
109 managed_initial_pose_pub_ = create_publisher<geometry_msgs::msg::PoseWithCovarianceStamped>(
"managed_initialpose", pub_qos_transient_local, intra_proc_disabled);
116 return CallbackReturn::SUCCESS;
131 auto error = update_params<double>(
141 auto error_2 = update_params<int>(
148 rcl_interfaces::msg::SetParametersResult result;
150 result.successful = !error && !error_2;
152 if (result.successful)
166 const autoware_msgs::msg::NDTStat::ConstPtr stats)
170 manager_->poseAndStatsCallback(pose, stats);
172 catch (
const std::exception &e)
174 RCLCPP_ERROR_STREAM(rclcpp::get_logger(
"localization_manager"),
"Uncaught Exception in localization_manager. Exception: " << e.what());
175 handle_primary_state_exception(e);
180#include "rclcpp_components/register_node_macro.hpp"
Primary logic class for the localization manager node.
void posePubTick()
Timer callback that controls the publication of the selected pose and status report.
void gnssPoseCallback(const geometry_msgs::msg::PoseStamped::SharedPtr msg)
Callback for new GNSS messages.
void initialPoseCallback(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg)
Callback for the initial pose provided by Rviz or some external localization initializer.
void systemAlertCallback(const carma_msgs::msg::SystemAlert::SharedPtr alert)
Callback for SystemAlert data. Used to check for lidar failure.
Core execution node for this package.
LocalizationManagerConfig config_
void publishStatus(const carma_localization_msgs::msg::LocalizationStatusReport &msg) const
Callback to publish the provided localization status report.
std::unique_ptr< LocalizationManager > manager_
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseStamped > gnss_pose_sub_
Node(const rclcpp::NodeOptions &)
Node constructor.
carma_ros2_utils::PubPtr< geometry_msgs::msg::PoseStamped > pose_pub_
rcl_interfaces::msg::SetParametersResult parameter_update_callback(const std::vector< rclcpp::Parameter > ¶meters)
Callback for dynamic parameter updates.
carma_ros2_utils::PubPtr< carma_localization_msgs::msg::LocalizationStatusReport > state_pub_
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseWithCovarianceStamped > initialpose_sub_
void publishPoseStamped(const geometry_msgs::msg::PoseStamped &msg) const
Callback to publish the selected pose.
message_filters::Subscriber< geometry_msgs::msg::PoseStamped, Node > ndt_pose_sub_
void publishManagedInitialPose(const geometry_msgs::msg::PoseWithCovarianceStamped &msg) const
Callback to publish the initial pose deemed suitable to intialize NDT.
carma_ros2_utils::SubPtr< carma_msgs::msg::SystemAlert > system_alert_sub_
rclcpp::TimerBase::SharedPtr pose_timer_
message_filters::Subscriber< autoware_msgs::msg::NDTStat, Node > ndt_score_sub_
void poseAndStatsCallback(const geometry_msgs::msg::PoseStamped::ConstPtr pose, const autoware_msgs::msg::NDTStat::ConstPtr stats)
Synchronized callback for pose and stats data for usage with message_filters. Provides exception hand...
carma_ros2_utils::PubPtr< geometry_msgs::msg::PoseWithCovarianceStamped > managed_initial_pose_pub_
std::shared_ptr< TimeSynchronizer > pose_stats_synchronizer_
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &)
Struct to store the configuration settings for the LocalizationManager class.
int gnss_only_operation_timeout
Timeout in ms for GNSS only operation. Ignored when in GNSS mode.
double fitness_score_fault_threshold
double fitness_score_degraded_threshold
NDT Fitness score above which the localization is considered in a degraded state.
int localization_mode
Localization mode to use.
double pose_pub_rate
Selected pose publication rate.
int auto_initialization_timeout
double x_offset
GPS Offset to apply if that mode is enabled.
int gnss_data_timeout
GNSS Data timeout. If exceeded the system will assume the GNSS is no longer functional....
double ndt_frequency_fault_threshold
double ndt_frequency_degraded_threshold
NDT solution frequency below which the localization is considered in a degraded state.
int sequential_timesteps_until_gps_operation