bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
cart_pole_lqr_mpc Namespace Reference

Classes

struct  Run
class  CartPoleDynamics
 A cart on a straight track, pushed by a horizontal force F, with a pole hinged on it. More...
struct  CartPoleParameters
 The cart and the pole. The defaults are those of the classic cart-pole of Barto, Sutton and Anderson (1983), which Gymnasium's CartPole uses too. More...

Typedefs

using real_t
 real_t
using RealColVec4d
 4D column vector
using uint_t
 uint_t
using Matrix
 The matrices of the linear models and the controllers.
using Vector
 The vectors of the linear models and the controllers: states, inputs.
using CartPoleState
 The state: the position of the cart [m], its velocity [m/s], the angle of the pole from upright [rad], positive when it leans towards +x, and its rate [rad/s].

Functions

Matrix state_weights ()
Matrix input_weights ()
CartPoleState start ()
template<typename Controller>
Run simulate (const std::string &name, Controller &&controller)
void print (const Run &run)
cv::Mat draw (const std::vector< Run > &runs, uint_t k, const CartPoleParameters &p)
void record (const std::vector< Run > &runs, const std::string &directory)

Variables

const real_t DT = 0.02
const real_t DURATION = 6.0
const real_t X0 = 1.5
const real_t THETA0 = 0.4
const real_t TRACK_BOUND = 2.3
const uint_t HORIZON = 40
const real_t PENALTY = 1000.0
const real_t RECORD_RATE = 25.0

Typedef Documentation

◆ CartPoleState

The state: the position of the cart [m], its velocity [m/s], the angle of the pole from upright [rad], positive when it leans towards +x, and its rate [rad/s].

◆ Matrix

The matrices of the linear models and the controllers.

◆ real_t

◆ RealColVec4d

4D column vector

◆ uint_t

◆ Vector

The vectors of the linear models and the controllers: states, inputs.

Function Documentation

◆ draw()

cv::Mat cart_pole_lqr_mpc::draw ( const std::vector< Run > & runs,
uint_t k,
const CartPoleParameters & p )

◆ input_weights()

Matrix cart_pole_lqr_mpc::input_weights ( )

◆ print()

void cart_pole_lqr_mpc::print ( const Run & run)

◆ record()

void cart_pole_lqr_mpc::record ( const std::vector< Run > & runs,
const std::string & directory )

◆ simulate()

template<typename Controller>
Run cart_pole_lqr_mpc::simulate ( const std::string & name,
Controller && controller )

◆ start()

CartPoleState cart_pole_lqr_mpc::start ( )

◆ state_weights()

Matrix cart_pole_lqr_mpc::state_weights ( )

Variable Documentation

◆ DT

const real_t cart_pole_lqr_mpc::DT = 0.02

◆ DURATION

const real_t cart_pole_lqr_mpc::DURATION = 6.0

◆ HORIZON

const uint_t cart_pole_lqr_mpc::HORIZON = 40

◆ PENALTY

const real_t cart_pole_lqr_mpc::PENALTY = 1000.0

◆ RECORD_RATE

const real_t cart_pole_lqr_mpc::RECORD_RATE = 25.0

◆ THETA0

const real_t cart_pole_lqr_mpc::THETA0 = 0.4

◆ TRACK_BOUND

const real_t cart_pole_lqr_mpc::TRACK_BOUND = 2.3

◆ X0

const real_t cart_pole_lqr_mpc::X0 = 1.5