bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
diff_drive_dynamics.h
Go to the documentation of this file.
1#ifndef DIFF_DRIVE_DYNAMICS_H
2#define DIFF_DRIVE_DYNAMICS_H
3
4#include "bitrl/bitrl_types.h"
8
9#include <any>
10#include <array>
11#include <map>
12
13namespace bitrl
14{
15namespace dynamics
16{
17
23class DiffDriveDynamics : public MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor,
24 std::map<std::string, std::any>>
25{
26 public:
31 enum class DynamicVersion
32 {
33 V1,
34 V2,
35 V3
36 };
37
42 std::map<std::string, std::any>>::state_type state_type;
43
48 std::map<std::string, std::any>>::input_type input_type;
49
54 std::map<std::string, std::any>>::matrix_type matrix_type;
55
60 std::map<std::string, std::any>>::vector_type vector_type;
61
65 static SysState<3> integrate_state_v1(const SysState<3> &state, real_t tol, real_t dt, real_t v,
66 real_t w, const std::array<real_t, 2> &errors);
67
71 static SysState<3> integrate_state_v2(const SysState<3> &state, real_t dt, real_t v, real_t w,
72 const std::array<real_t, 2> &errors);
73
77 static SysState<3> integrate_state_v3(const SysState<3> &state, real_t r, real_t l, real_t dt,
78 real_t w1, real_t w2,
79 const std::array<real_t, 2> &errors);
80
85 static SysState<3> integrate(const SysState<3> &state, const input_type &input,
86 const DynamicVersion version);
87
92 bool update_description_matrices_on_evaluate = true);
93
97 explicit DiffDriveDynamics(state_type &&state);
98
103 virtual state_type &evaluate(const input_type &input) override;
104
108 void integrate(const input_type &input);
109
113 real_t get_x_position() const { return this->state_.get("X"); }
114
118 void set_x_position(real_t x) { this->state_.set("X", x); }
119
123 real_t get_y_position() const { return this->state_.get("Y"); }
124
128 void set_y_position(real_t y) { this->state_.set("Y", y); }
129
133 real_t get_orientation() const { return this->state_.get("Theta"); }
134
138 void set_orientation(real_t theta) { this->state_.set("Theta", theta); }
139
143 real_t get_velocity() const { return v_; }
144
148 real_t get_angular_velocity() const { return w_; }
149
154 void update_matrices(const input_type &input);
155
160 void initialize_matrices(const input_type &input);
161
162 private:
167 real_t v_;
168
172 real_t w_;
173
177 DynamicVersion type_;
178};
179
180} // namespace dynamics
181
182} // namespace bitrl
183
184#endif // DIFF_DRIVE_DYNAMICS_H
DiffDriveDynamics class. Describes the motion dynamics of a differential drive system....
Definition diff_drive_dynamics.h:25
real_t get_y_position() const
Read the y-coordinate.
Definition diff_drive_dynamics.h:123
void initialize_matrices(const input_type &input)
Initialize the matrices describing the the dynamics.
Definition diff_drive_dynamics.cpp:211
void update_matrices(const input_type &input)
updates the matrices used to describe this motion model
Definition diff_drive_dynamics.cpp:233
void set_orientation(real_t theta)
Set the orientation.
Definition diff_drive_dynamics.h:138
void set_y_position(real_t y)
Set the y-coordinate.
Definition diff_drive_dynamics.h:128
static SysState< 3 > integrate_state_v2(const SysState< 3 > &state, real_t dt, real_t v, real_t w, const std::array< real_t, 2 > &errors)
integrate_state_v2
Definition diff_drive_dynamics.cpp:51
MotionModelDynamicsBase< SysState< 3 >, DynamicsMatrixDescriptor, std::map< std::string, std::any > >::input_type input_type
input_t The type of the input for solving the dynamics
Definition diff_drive_dynamics.h:48
static SysState< 3 > integrate_state_v1(const SysState< 3 > &state, real_t tol, real_t dt, real_t v, real_t w, const std::array< real_t, 2 > &errors)
integrate_state_v1
Definition diff_drive_dynamics.cpp:14
static SysState< 3 > integrate(const SysState< 3 > &state, const input_type &input, const DynamicVersion version)
integrate Factory method to apply the different integration methods
Definition diff_drive_dynamics.cpp:84
static SysState< 3 > integrate_state_v3(const SysState< 3 > &state, real_t r, real_t l, real_t dt, real_t w1, real_t w2, const std::array< real_t, 2 > &errors)
integrate_state_v3
Definition diff_drive_dynamics.cpp:68
virtual state_type & evaluate(const input_type &input) override
Evaluate the new state using the given input it also updates the various matrices if needed.
Definition diff_drive_dynamics.cpp:205
void set_x_position(real_t x)
Set the x-coordinate.
Definition diff_drive_dynamics.h:118
real_t get_orientation() const
Read the y-coordinate.
Definition diff_drive_dynamics.h:133
real_t get_x_position() const
Read the x-coordinate.
Definition diff_drive_dynamics.h:113
DynamicVersion
The DynamicVersion enum. Helper enum to disambiguate the two supplied configurations.
Definition diff_drive_dynamics.h:32
MotionModelDynamicsBase< SysState< 3 >, DynamicsMatrixDescriptor, std::map< std::string, std::any > >::matrix_type matrix_type
matrix_t Matrix type that describes the dynamics
Definition diff_drive_dynamics.h:54
MotionModelDynamicsBase< SysState< 3 >, DynamicsMatrixDescriptor, std::map< std::string, std::any > >::vector_type vector_type
vector_t
Definition diff_drive_dynamics.h:60
real_t get_angular_velocity() const
get_velocity Returns the angular velocity used for integration
Definition diff_drive_dynamics.h:148
real_t get_velocity() const
get_velocity Returns the velocity used for integration
Definition diff_drive_dynamics.h:143
MotionModelDynamicsBase< SysState< 3 >, DynamicsMatrixDescriptor, std::map< std::string, std::any > >::state_type state_type
The type of the state handled by this dynamics object.
Definition diff_drive_dynamics.h:42
The DynamicsMatrixDescriptor class. Helper class to model the matrix representon of dynamical systems...
Definition dynamics_matrix_descriptor.h:19
Base class for deriving motion models. Motion models describe the dynamics or kinematics of a rigid b...
Definition motion_model_base.h:24
state_type state_
The object describing the state of the object of which its dynamics are described/modeled by this Mot...
Definition motion_model_base.h:168
SysState utility class describing the state of a system.
Definition system_state.h:25
real_t get(const std::string &name) const
Returns the value for the variable name.
Definition system_state.h:343
void set(const std::string &name, real_t val)
Set the value for the variable name.
Definition system_state.h:378
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23