ros2_control - rolling
Loading...
Searching...
No Matches
odometry.hpp
1// Copyright (c) 2023, Stogl Robotics Consulting UG (haftungsbeschränkt)
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_
16#define MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_
17
18#include "geometry_msgs/msg/twist.hpp"
19#include "realtime_tools/realtime_buffer.hpp"
20#include "realtime_tools/realtime_publisher.hpp"
21
22#define PLANAR_POINT_DIM 3
23
24namespace mecanum_drive_controller
25{
29{
30public:
32 typedef std::function<void(double, double, double)> IntegrationFunction;
33
37 Odometry();
38
41 void init(const rclcpp::Time & time, std::array<double, PLANAR_POINT_DIM> base_frame_offset);
42
50 bool update(
51 const double wheel_front_left_vel, const double wheel_rear_left_vel,
52 const double wheel_rear_right_vel, const double wheel_front_right_vel, const double dt);
53
55 double getX() const { return position_x_in_base_frame_; }
57 double getY() const { return position_y_in_base_frame_; }
59 double getRz() const { return orientation_z_in_base_frame_; }
61 double getVx() const { return velocity_in_base_frame_linear_x; }
63 double getVy() const { return velocity_in_base_frame_linear_y; }
65 double getWz() const
66 {
67 return velocity_in_base_frame_angular_z;
68 ;
69 }
70
75 void setWheelsParams(
76 const double sum_of_robot_center_projection_on_X_Y_axis, const double wheels_radius);
77
78private:
80 rclcpp::Time timestamp_;
81
83 std::array<double, PLANAR_POINT_DIM> base_frame_offset_;
84
86 double position_x_in_base_frame_; // [m]
87 double position_y_in_base_frame_; // [m]
88 double orientation_z_in_base_frame_; // [rad]
89
90 double velocity_in_base_frame_linear_x; // [m/s]
91 double velocity_in_base_frame_linear_y; // [m/s]
92 double velocity_in_base_frame_angular_z; // [rad/s]
93
98 double sum_of_robot_center_projection_on_X_Y_axis_;
99 double wheels_radius_; // [m]
100};
101
102} // namespace mecanum_drive_controller
103
104#endif // MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_ */
The Odometry class handles odometry readings (2D pose and velocity with related timestamp)
Definition odometry.hpp:29
std::function< void(double, double, double)> IntegrationFunction
Integration function, used to integrate the odometry:
Definition odometry.hpp:32
double getVx() const
Definition odometry.hpp:61
void init(const rclcpp::Time &time, std::array< double, PLANAR_POINT_DIM > base_frame_offset)
Initialize the odometry.
Definition odometry.cpp:35
double getX() const
Definition odometry.hpp:55
bool update(const double wheel_front_left_vel, const double wheel_rear_left_vel, const double wheel_rear_right_vel, const double wheel_front_right_vel, const double dt)
Updates the odometry class with latest wheels position.
Definition odometry.cpp:47
double getRz() const
Definition odometry.hpp:59
void setWheelsParams(const double sum_of_robot_center_projection_on_X_Y_axis, const double wheels_radius)
Sets the wheels parameters: mecanum geometric param and radius.
Definition odometry.cpp:117
double getY() const
Definition odometry.hpp:57
double getVy() const
Definition odometry.hpp:63
double getWz() const
Definition odometry.hpp:65
Odometry()
Constructor Timestamp will get the current time value Value will be set to zero.
Definition odometry.cpp:22