Common
common packages for kyubic
 
Loading...
Searching...
No Matches
localization_component.hpp
Go to the documentation of this file.
1
10#ifndef _LOCALIZATIN_COMPONENT_HPP
11#define _LOCALIZATIN_COMPONENT_HPP
12
13#include <atomic>
14#include <driver_msgs/msg/gnss.hpp>
15#include <driver_msgs/msg/imu.hpp>
17#include <localization_msgs/msg/odometry.hpp>
18#include <localization_msgs/srv/reset.hpp>
19#include <rclcpp/rclcpp.hpp>
20#include <std_srvs/srv/trigger.hpp>
21#include <visualization_msgs/msg/marker_array.hpp>
22
27namespace localization
28{
29
30const std::array<std::array<double, 3>, 2> ANCHOR_POINTS_DMS[4] = {
31 {{{33, 59, 14.8}, {132, 12, 5.4}}}, // I系: 33°00′00″N, 129°30′00″E
32 {{{33, 59, 14.6}, {132, 12, 6.4}}}, // II系: 33°00′00″N, 131°00′00″E
33 {{{33, 59, 15.2}, {132, 12, 6.4}}}, // III系: 36°00′00″N, 132°10′30″E
34 {{{33, 59, 15.5}, {132, 12, 5.7}}}, // IV系: 33°00′00″N, 133°00′00″E
35};
36
38using FutureAndRequestId = rclcpp::Client<std_srvs::srv::Trigger>::SharedFuture;
39
43class Localization : public rclcpp::Node
44{
45private:
46 uint8_t coord_system_id;
47 rclcpp::CallbackGroup::SharedPtr client_cb_group_;
48 rclcpp::CallbackGroup::SharedPtr gnss_cb_group_;
49 rclcpp::Publisher<localization_msgs::msg::Odometry>::SharedPtr pub_odom_;
50 rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr marker_pub_;
51 rclcpp::Subscription<localization_msgs::msg::Odometry>::SharedPtr sub_depth_;
52 rclcpp::Subscription<localization_msgs::msg::Odometry>::SharedPtr sub_imu_;
53 rclcpp::Subscription<localization_msgs::msg::Odometry>::SharedPtr sub_dvl_;
54 rclcpp::Subscription<driver_msgs::msg::Gnss>::SharedPtr sub_gnss_;
55 rclcpp::Subscription<driver_msgs::msg::IMU>::SharedPtr sub_imu_raw_;
56 rclcpp::Service<localization_msgs::srv::Reset>::SharedPtr srv_;
57 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr client_depth_;
58 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr client_imu_;
59 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr client_dvl_;
60
61 rclcpp::TimerBase::SharedPtr timer_;
62
63 std::shared_ptr<common::GeodeticConverter> geo_converter_;
64 std::shared_ptr<localization_msgs::msg::Odometry> odom_msg_;
65 std::shared_ptr<driver_msgs::msg::Gnss> gnss_msg_;
66 std::shared_ptr<driver_msgs::msg::IMU> imu_raw_msg_;
67 common::Geodetic origin_geodetic;
68 common::Geodetic reference_geodetic;
69 common::PlaneXY reference_plane;
70 double azimuth;
71
72 std::atomic<bool> gnss_updated{false};
73
74 bool gnss_enable = false;
75 uint8_t enabled_sensor = 0b11111000;
76 uint8_t all_updated = 0b11111000;
77
82 void depth_callback(const localization_msgs::msg::Odometry::UniquePtr msg);
83
88 void imu_callback(const localization_msgs::msg::Odometry::UniquePtr msg);
89
94 void dvl_callback(const localization_msgs::msg::Odometry::UniquePtr msg);
95
100 void gnss_callback(const driver_msgs::msg::Gnss::UniquePtr msg);
101
106 void imu_raw_callback(const driver_msgs::msg::IMU::UniquePtr msg);
107
112 void _calc_global_pos(const localization_msgs::msg::Odometry::SharedPtr odom_);
113
118 void publisher();
119
124 void reset_callback(
125 const localization_msgs::srv::Reset::Request::SharedPtr request,
126 const localization_msgs::srv::Reset::Response::SharedPtr response);
127
131 bool _is_server_active(const rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr client_);
132
136 FutureAndRequestId _reset_request(
137 const rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr client_);
138
142 bool _reset_response(
143 FutureAndRequestId future, std::chrono::duration<long, std::ratio<1, 1000>> dulation,
144 std::string service_name);
145
146public:
152 explicit Localization(const rclcpp::NodeOptions & options);
153
157 int reset();
158};
159
160} // namespace localization
161
162#endif
Localization class.
Definition: localization_component.hpp:44
int reset()
Reset each odometry and imu transformed node.
Definition: localization_component.cpp:351
geodetic to plane converter library
localization
rclcpp::Client< std_srvs::srv::Trigger >::SharedFuture FutureAndRequestId
Definition: localization_component.hpp:38
const std::array< std::array< double, 3 >, 2 > ANCHOR_POINTS_DMS[4]
Definition: localization_component.hpp:30
Structure of latitude longitude.
Definition: geodetic_converter.hpp:52
Structure of Cartesian coordinate system.
Definition: geodetic_converter.hpp:63