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.
localization_manager_node.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17#pragma once
18
19#include <rclcpp/rclcpp.hpp>
20#include <boost/shared_ptr.hpp>
21#include <functional>
22#include <std_msgs/msg/string.hpp>
23#include <std_srvs/srv/empty.hpp>
24
25#include <carma_ros2_utils/carma_lifecycle_node.hpp>
29#include <message_filters_humble/subscriber.h>
30#include <message_filters_humble/time_synchronizer.h>
31#include <message_filters_humble/sync_policies/exact_time.h>
32
33#include <geometry_msgs/msg/transform_stamped.hpp>
34#include <geometry_msgs/msg/pose_stamped.hpp>
35#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
36#include <boost/optional.hpp>
37#include <autoware_msgs/msg/ndt_stat.hpp>
38
40{
45 class Node : public carma_ros2_utils::CarmaLifecycleNode
46 {
47 private:
48 // Subscribers
49 message_filters::Subscriber<geometry_msgs::msg::PoseStamped, Node> ndt_pose_sub_;
50 message_filters::Subscriber<autoware_msgs::msg::NDTStat, Node> ndt_score_sub_;
51 carma_ros2_utils::SubPtr<geometry_msgs::msg::PoseStamped> gnss_pose_sub_;
52 carma_ros2_utils::SubPtr<geometry_msgs::msg::PoseWithCovarianceStamped> initialpose_sub_;
53 carma_ros2_utils::SubPtr<carma_msgs::msg::SystemAlert> system_alert_sub_;
54
55 // Publishers
56 carma_ros2_utils::PubPtr<geometry_msgs::msg::PoseStamped> pose_pub_;
57 carma_ros2_utils::PubPtr<carma_localization_msgs::msg::LocalizationStatusReport> state_pub_;
58 carma_ros2_utils::PubPtr<geometry_msgs::msg::PoseWithCovarianceStamped> managed_initial_pose_pub_;
59
60 // Timers
61 rclcpp::TimerBase::SharedPtr pose_timer_;
62
63 // Node configuration
65
66 // Worker object
67 std::unique_ptr<LocalizationManager> manager_;
68
69 // Message filters policies (TimeSynchronizer by default uses ExactTime Policy)
70 typedef message_filters::TimeSynchronizer<geometry_msgs::msg::PoseStamped, autoware_msgs::msg::NDTStat> TimeSynchronizer;
71 std::shared_ptr<TimeSynchronizer> pose_stats_synchronizer_;
72
73 public:
77 explicit Node(const rclcpp::NodeOptions &);
78
83 void publishPoseStamped(const geometry_msgs::msg::PoseStamped &msg) const;
84
89 void publishStatus(const carma_localization_msgs::msg::LocalizationStatusReport &msg) const;
90
95 void publishManagedInitialPose(const geometry_msgs::msg::PoseWithCovarianceStamped &msg) const;
96
103 void poseAndStatsCallback(const geometry_msgs::msg::PoseStamped::ConstPtr pose,
104 const autoware_msgs::msg::NDTStat::ConstPtr stats);
105
109 rcl_interfaces::msg::SetParametersResult
110 parameter_update_callback(const std::vector<rclcpp::Parameter> &parameters);
111
113 // Overrides
115 carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &);
116 };
117}
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_
message_filters::TimeSynchronizer< geometry_msgs::msg::PoseStamped, autoware_msgs::msg::NDTStat > TimeSynchronizer
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 > &parameters)
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.