ros2_control - rolling
Loading...
Searching...
No Matches
steering_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// Authors: dr. sc. Tomislav Petkovic, Dr. Ing. Denis Štogl
16//
17
18#ifndef STEERING_CONTROLLERS_LIBRARY__STEERING_ODOMETRY_HPP_
19#define STEERING_CONTROLLERS_LIBRARY__STEERING_ODOMETRY_HPP_
20
21#ifdef _WIN32
22#pragma message( \
23 "This header is deprecated. Please update your code to use 'steering_kinematics.hpp' header.") // NOLINT
24#else
25#warning \
26 "This header is deprecated. Please update your code to use 'steering_kinematics.hpp' header." //NOLINT
27#endif
28
29#include "steering_controllers_library/steering_kinematics.hpp"
30
31#include <cmath>
32#include <tuple>
33#include <vector>
34
35#include <rclcpp/time.hpp>
36
37// \note The versions conditioning is added here to support the source-compatibility with Humble
38#if RCPPUTILS_VERSION_MAJOR >= 2 && RCPPUTILS_VERSION_MINOR >= 6
39#include "rcpputils/rolling_mean_accumulator.hpp"
40#else
41#include "rcppmath/rolling_mean_accumulator.hpp"
42#endif
43
44namespace steering_odometry
45{
46[[deprecated("Use steering_kinematics::BICYCLE_CONFIG")]] const unsigned int BICYCLE_CONFIG =
47 steering_kinematics::BICYCLE_CONFIG;
48[[deprecated("Use steering_kinematics::TRICYCLE_CONFIG")]] const unsigned int TRICYCLE_CONFIG =
49 steering_kinematics::TRICYCLE_CONFIG;
50[[deprecated("Use steering_kinematics::ACKERMANN_CONFIG")]] const unsigned int ACKERMANN_CONFIG =
51 steering_kinematics::ACKERMANN_CONFIG;
52
53inline bool is_close_to_zero(double val) { return steering_kinematics::is_close_to_zero(val); }
54
60class [[deprecated("Use steering_kinematics::SteeringKinematics instead")]] SteeringOdometry
61{
62public:
63 explicit SteeringOdometry(size_t velocity_rolling_window_size = 10);
64
65 void init(const rclcpp::Time & time);
66
67 bool update_from_position(
68 const double traction_wheel_pos, const double steer_pos, const double dt);
69
70 bool update_from_position(
71 const double right_traction_wheel_pos, const double left_traction_wheel_pos,
72 const double steer_pos, const double dt);
73
74 bool update_from_position(
75 const double right_traction_wheel_pos, const double left_traction_wheel_pos,
76 const double right_steer_pos, const double left_steer_pos, const double dt);
77
78 bool update_from_velocity(
79 const double traction_wheel_vel, const double steer_pos, const double dt);
80
81 bool update_from_velocity(
82 const double right_traction_wheel_vel, const double left_traction_wheel_vel,
83 const double steer_pos, const double dt);
84
85 bool update_from_velocity(
86 const double right_traction_wheel_vel, const double left_traction_wheel_vel,
87 const double right_steer_pos, const double left_steer_pos, const double dt);
88
89 void update_open_loop(const double v_bx, const double omega_bz, const double dt);
90
91 void set_odometry_type(const unsigned int type);
92
93 unsigned int get_odometry_type() const;
94 double get_heading() const;
95
96 double get_x() const;
97
98 double get_y() const;
99
100 double get_linear() const;
101
102 double get_angular() const;
103
104 void set_wheel_params(
105 const double wheel_radius, const double wheel_base, const double wheel_track);
106
107 void set_wheel_params(
108 const double wheel_radius, const double wheel_base, const double wheel_track_steering,
109 const double wheel_track_traction);
110
111 void set_velocity_rolling_window_size(const size_t velocity_rolling_window_size);
112
113 std::tuple<std::vector<double>, std::vector<double>> get_commands(
114 double v_bx, double omega_bz, bool open_loop = true,
115 bool reduce_wheel_speed_until_steering_reached = false);
116
117 void reset_odometry();
118
119private:
121};
122} // namespace steering_odometry
123
124#endif // STEERING_CONTROLLERS_LIBRARY__STEERING_ODOMETRY_HPP_
The SteeringKinematics class handles forward kinematics (odometry calculations) and inverse kinematic...
Definition steering_kinematics.hpp:47
Deprecated Odometry class for backward ABI compatibility. Internally calling steering_kinematics::Ste...
Definition steering_odometry.hpp:61