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 <array>
19#include <functional>
20
21#include "rclcpp/time.hpp"
22
23#define PLANAR_POINT_DIM 3
24
25namespace mecanum_drive_controller
26{
30{
31public:
33 typedef std::function<void(double, double, double)> IntegrationFunction;
34
38 Odometry();
39
42 void init(const rclcpp::Time & time, std::array<double, PLANAR_POINT_DIM> base_frame_offset);
43
51 bool update(
52 const double wheel_front_left_vel, const double wheel_rear_left_vel,
53 const double wheel_rear_right_vel, const double wheel_front_right_vel, const double dt);
54
56 double getX() const { return position_x_in_base_frame_; }
58 double getY() const { return position_y_in_base_frame_; }
60 double getRz() const { return orientation_z_in_base_frame_; }
62 double getVx() const { return velocity_in_base_frame_linear_x; }
64 double getVy() const { return velocity_in_base_frame_linear_y; }
66 double getWz() const
67 {
68 return velocity_in_base_frame_angular_z;
69 ;
70 }
71
72 const std::array<double, PLANAR_POINT_DIM> & getBaseFrameOffset() const
73 {
74 return base_frame_offset_;
75 }
76
81 void setWheelsParams(
82 const double sum_of_robot_center_projection_on_X_Y_axis, const double wheels_radius);
83
84private:
86 rclcpp::Time timestamp_;
87
89 std::array<double, PLANAR_POINT_DIM> base_frame_offset_;
90
92 double position_x_in_base_frame_; // [m]
93 double position_y_in_base_frame_; // [m]
94 double orientation_z_in_base_frame_; // [rad]
95
96 double velocity_in_base_frame_linear_x; // [m/s]
97 double velocity_in_base_frame_linear_y; // [m/s]
98 double velocity_in_base_frame_angular_z; // [rad/s]
99
104 double sum_of_robot_center_projection_on_X_Y_axis_;
105 double wheels_radius_; // [m]
106};
107
108} // namespace mecanum_drive_controller
109
110#endif // MECANUM_DRIVE_CONTROLLER__ODOMETRY_HPP_ */
The Odometry class handles odometry readings (2D pose and velocity with related timestamp)
Definition odometry.hpp:30
std::function< void(double, double, double)> IntegrationFunction
Integration function, used to integrate the odometry:
Definition odometry.hpp:33
double getVx() const
Definition odometry.hpp:62
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:56
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:60
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:58
double getVy() const
Definition odometry.hpp:64
double getWz() const
Definition odometry.hpp:66
Odometry()
Constructor Timestamp will get the current time value Value will be set to zero.
Definition odometry.cpp:22