19 #ifndef STATE_ESTIMATION_NODES__STATE_ESTIMATION_NODE_HPP_
20 #define STATE_ESTIMATION_NODES__STATE_ESTIMATION_NODE_HPP_
24 #include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
25 #include <geometry_msgs/msg/twist_with_covariance_stamped.hpp>
26 #include <geometry_msgs/msg/quaternion_stamped.hpp>
29 #include <nav_msgs/msg/odometry.hpp>
30 #include <rclcpp/publisher.hpp>
31 #include <rclcpp/rclcpp.hpp>
32 #include <rclcpp/subscription.hpp>
37 #include <tf2/buffer_core.h>
38 #include <tf2_ros/transform_listener.h>
39 #include <tf2_ros/transform_broadcaster.h>
41 #include <Eigen/Geometry>
51 namespace state_estimation_nodes
66 const rclcpp::NodeOptions & node_options);
70 using PoseMsgT = geometry_msgs::msg::PoseWithCovarianceStamped;
71 using TwistMsgT = geometry_msgs::msg::TwistWithCovarianceStamped;
74 template<std::
int32_t kDim>
75 using VectorT = Eigen::Matrix<float32_t, kDim, 1>;
81 void odom_callback(
const OdomMsgT::SharedPtr msg);
87 void pose_callback(
const PoseMsgT::SharedPtr msg);
93 void twist_callback(
const TwistMsgT::SharedPtr msg);
96 void predict_and_publish_current_state();
99 void publish_current_state();
102 void update_latest_orientation_if_needed(
const geometry_msgs::msg::QuaternionStamped & rotation);
107 template<
typename MessageT>
110 template<
typename MessageT>
111 void create_subscriptions(
112 const std::vector<std::string> & input_topics,
113 std::vector<
typename rclcpp::Subscription<MessageT>::SharedPtr> * subscribers,
114 CallbackFnT<MessageT> callback);
116 template<std::
int32_t kNumOfStates, std::
int32_t kProcessNoiseDim>
117 static Eigen::Matrix<float32_t, kNumOfStates, kProcessNoiseDim> create_GQ_factor(
118 const std::chrono::nanoseconds & expected_delta_t,
119 const VectorT<kProcessNoiseDim> & process_noise_variances);
121 std::vector<rclcpp::Subscription<OdomMsgT>::SharedPtr> m_odom_subscribers;
122 std::vector<rclcpp::Subscription<PoseMsgT>::SharedPtr> m_pose_subscribers;
123 std::vector<rclcpp::Subscription<TwistMsgT>::SharedPtr> m_twist_subscribers;
125 std::shared_ptr<rclcpp::Publisher<OdomMsgT>> m_publisher{};
126 std::shared_ptr<rclcpp::Publisher<TfMsgT>> m_tf_publisher{};
128 rclcpp::TimerBase::SharedPtr m_wall_timer{};
134 std::string m_frame_id{};
135 std::string m_child_frame_id{};
139 std::unique_ptr<ConstantAccelerationFilter> m_ekf{};
141 tf2::BufferCore m_tf_buffer;
142 tf2_ros::TransformListener m_tf_listener;
144 geometry_msgs::msg::QuaternionStamped m_latest_orientation{};
152 #endif // STATE_ESTIMATION_NODES__STATE_ESTIMATION_NODE_HPP_