bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
cart_pole_dynamics.h
Go to the documentation of this file.
1#ifndef BITSIM_DYNAMICS_CART_POLE_DYNAMICS_H
2#define BITSIM_DYNAMICS_CART_POLE_DYNAMICS_H
3
5
6#include <Eigen/Dense>
7
8namespace bitsim
9{
10namespace dynamics
11{
12
26
30
32namespace cart_pole
33{
34constexpr int X = 0;
35constexpr int X_DOT = 1;
36constexpr int THETA = 2;
37constexpr int THETA_DOT = 3;
38} // namespace cart_pole
39
49
70{
71 public:
73 const CartPoleState &state = CartPoleState::Zero());
74
78 void step(real_t force, real_t dt);
79
83 CartPoleState derivative(const CartPoleState &x, real_t force) const;
84
88 CartPoleLinearModel linearise(const CartPoleState &x = CartPoleState::Zero(),
89 real_t force = 0.0) const;
90
94 real_t limit(real_t force) const;
95
99 real_t energy(const CartPoleState &x) const;
100
104 bool off_track() const;
105
106 const CartPoleState &state() const noexcept { return state_; }
107 CartPoleState &state() noexcept { return state_; }
108 const CartPoleParameters &parameters() const noexcept { return p_; }
109 real_t time() const noexcept { return time_; }
110
111 private:
113 CartPoleState state_;
114 real_t time_{0.0};
115};
116
117} // namespace dynamics
118} // namespace bitsim
119
120#endif // BITSIM_DYNAMICS_CART_POLE_DYNAMICS_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
CartPoleState & state() noexcept
Definition cart_pole_dynamics.h:107
const CartPoleParameters & parameters() const noexcept
Definition cart_pole_dynamics.h:108
bool off_track() const
Definition cart_pole_dynamics.cpp:93
CartPoleDynamics(const CartPoleParameters &parameters=CartPoleParameters(), const CartPoleState &state=CartPoleState::Zero())
Definition cart_pole_dynamics.cpp:12
CartPoleLinearModel linearise(const CartPoleState &x=CartPoleState::Zero(), real_t force=0.0) const
Definition cart_pole_dynamics.cpp:59
real_t time() const noexcept
Definition cart_pole_dynamics.h:109
real_t energy(const CartPoleState &x) const
Definition cart_pole_dynamics.cpp:75
CartPoleState derivative(const CartPoleState &x, real_t force) const
Definition cart_pole_dynamics.cpp:23
real_t limit(real_t force) const
Definition cart_pole_dynamics.cpp:43
void step(real_t force, real_t dt)
Advance by dt [s], with the force F [N] held over the step.
Definition cart_pole_dynamics.cpp:48
const CartPoleState & state() const noexcept
Definition cart_pole_dynamics.h:106
Where each value is in a CartPoleState.
Definition cart_pole_dynamics.h:33
constexpr int THETA_DOT
Definition cart_pole_dynamics.h:37
constexpr int X_DOT
Definition cart_pole_dynamics.h:35
constexpr int THETA
Definition cart_pole_dynamics.h:36
constexpr int X
Definition cart_pole_dynamics.h:34
Models of how things move: wheeled robots, a bicycle, a quadrotor and a fixed wing aircraft,...
Definition bicycle_vehicle_model_dynamics.cpp:10
RealColVec4d CartPoleState
The state: the position of the cart [m], its velocity [m/s], the angle of the pole from upright [rad]...
Definition cart_pole_dynamics.h:29
Definition dc_motor_backend_base.h:9
Eigen::Vector4d RealColVec4d
4D column vector
Definition bitsim_types.h:142
double real_t
real_t
Definition bitsim_types.h:20
Eigen::Matrix4< real_t > RealMat4d
4×4 matrix of type double.
Definition bitsim_types.h:91
A model linearised about a state and a force: , for the deviations from them.
Definition cart_pole_dynamics.h:45
RealMat4d A
Definition cart_pole_dynamics.h:46
RealColVec4d B
Definition cart_pole_dynamics.h:47
The cart and the pole. The defaults are those of the classic cart-pole of Barto, Sutton and Anderson ...
Definition cart_pole_dynamics.h:18
real_t gravity
[m/s^2]
Definition cart_pole_dynamics.h:22
real_t track_half_length
the cart must stay within this of the centre [m]
Definition cart_pole_dynamics.h:24
real_t cart_mass
[kg]
Definition cart_pole_dynamics.h:19
real_t pole_half_length
from the pivot to the centre of the pole [m]
Definition cart_pole_dynamics.h:21
real_t pole_mass
[kg]
Definition cart_pole_dynamics.h:20
real_t max_force
the largest push on the cart, either way [N]
Definition cart_pole_dynamics.h:23