|
16 | 16 |
|
17 | 17 | #pragma once
|
18 | 18 |
|
| 19 | +#include <memory> |
19 | 20 | #include <string>
|
20 | 21 |
|
21 |
| -#include <ros/ros.h> |
| 22 | +#include <rclcpp/rclcpp.hpp> |
22 | 23 |
|
23 | 24 | #include <tf2/transform_datatypes.h>
|
24 | 25 | #include <tf2_ros/transform_listener.h>
|
25 | 26 |
|
26 |
| -#include <geometry_msgs/PoseWithCovarianceStamped.h> |
27 |
| -#include <sensor_msgs/PointCloud2.h> |
28 |
| - |
29 |
| -#include <dynamic_reconfigure/server.h> |
| 27 | +#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp> |
| 28 | +#include <sensor_msgs/msg/point_cloud2.hpp> |
30 | 29 |
|
31 | 30 | #include <pcl/point_cloud.h>
|
32 | 31 | #include <pcl/point_types.h>
|
33 | 32 |
|
34 |
| -#include "autoware_localization_srvs/PoseWithCovarianceStamped.h" |
| 33 | +#include "autoware_localization_srvs/srv/pose_with_covariance_stamped.hpp" |
35 | 34 |
|
36 |
| -class PoseInitializer |
| 35 | +class PoseInitializer : public rclcpp::Node |
37 | 36 | {
|
38 | 37 | public:
|
39 |
| - PoseInitializer(ros::NodeHandle nh, ros::NodeHandle private_nh); |
| 38 | + PoseInitializer(); |
40 | 39 | ~PoseInitializer();
|
41 | 40 |
|
42 | 41 | private:
|
43 |
| - void callbackMapPoints(const sensor_msgs::PointCloud2::ConstPtr & pointcloud2_msg_ptr); |
44 |
| - bool serviceInitial( |
45 |
| - autoware_localization_srvs::PoseWithCovarianceStamped::Request & req, |
46 |
| - autoware_localization_srvs::PoseWithCovarianceStamped::Response & res); |
| 42 | + void callbackMapPoints(sensor_msgs::msg::PointCloud2::ConstSharedPtr pointcloud2_msg_ptr); |
| 43 | + void serviceInitial( |
| 44 | + const std::shared_ptr<autoware_localization_srvs::srv::PoseWithCovarianceStamped::Request> req, |
| 45 | + std::shared_ptr<autoware_localization_srvs::srv::PoseWithCovarianceStamped::Response> res); |
47 | 46 | void callbackInitialPose(
|
48 |
| - const geometry_msgs::PoseWithCovarianceStamped::ConstPtr & pose_cov_msg_ptr); |
| 47 | + geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr pose_cov_msg_ptr); |
49 | 48 | void callbackGNSSPoseCov(
|
50 |
| - const geometry_msgs::PoseWithCovarianceStamped::ConstPtr & pose_cov_msg_ptr); |
| 49 | + geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr pose_cov_msg_ptr); |
51 | 50 |
|
52 | 51 | bool getHeight(
|
53 |
| - const geometry_msgs::PoseWithCovarianceStamped & input_pose_msg, |
54 |
| - const geometry_msgs::PoseWithCovarianceStamped::Ptr & output_pose_msg_ptr); |
55 |
| - bool callAlignService( |
56 |
| - const geometry_msgs::PoseWithCovarianceStamped & msg, |
57 |
| - const geometry_msgs::PoseWithCovarianceStamped::Ptr & output_pose_msg_ptr); |
58 |
| - |
59 |
| - ros::NodeHandle nh_; |
60 |
| - ros::NodeHandle private_nh_; |
| 52 | + const geometry_msgs::msg::PoseWithCovarianceStamped & input_pose_msg, |
| 53 | + const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr output_pose_msg_ptr); |
| 54 | + void callAlignServiceAndPublishResult( |
| 55 | + const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg); |
61 | 56 |
|
62 |
| - ros::Subscriber initial_pose_sub_; |
63 |
| - ros::Subscriber gnss_pose_sub_; |
64 |
| - ros::Subscriber map_points_sub_; |
| 57 | + rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr initial_pose_sub_; |
| 58 | + rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr gnss_pose_sub_; |
| 59 | + rclcpp::Subscription<sensor_msgs::msg::PointCloud2>::SharedPtr map_points_sub_; |
65 | 60 |
|
66 |
| - ros::Publisher initial_pose_pub_; |
| 61 | + rclcpp::Publisher<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr initial_pose_pub_; |
67 | 62 |
|
68 |
| - ros::ServiceClient ndt_client_; |
| 63 | + rclcpp::Client<autoware_localization_srvs::srv::PoseWithCovarianceStamped>::SharedPtr ndt_client_; |
69 | 64 |
|
70 |
| - ros::ServiceServer gnss_service_; |
| 65 | + rclcpp::Service<autoware_localization_srvs::srv::PoseWithCovarianceStamped>::SharedPtr |
| 66 | + gnss_service_; |
71 | 67 |
|
72 |
| - tf2_ros::Buffer tf2_buffer_; |
| 68 | + tf2::BufferCore tf2_buffer_; |
73 | 69 | tf2_ros::TransformListener tf2_listener_;
|
74 | 70 |
|
75 | 71 | pcl::PointCloud<pcl::PointXYZ>::Ptr map_ptr_;
|
76 | 72 | std::string map_frame_;
|
| 73 | + |
| 74 | + // With the currently available facilities for calling a service, there is no |
| 75 | + // easy way of detecting whether an answer was received within a reasonable |
| 76 | + // amount of time. So, as a sanity check, we check whether a response for the |
| 77 | + // previous request was received when a new request is sent. |
| 78 | + uint32_t request_id_ = 0; |
| 79 | + uint32_t response_id_ = 0; |
77 | 80 | };
|
0 commit comments