bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::dynamics::QuadrotorDynamics Class Reference

The QuadrotorDynamics class. Implements quadrotor dynamics The implementation of this class follows the System Modeling section at https://wilselby.com/research/arducopter/modeling/ and https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=2324&context=facpub The quadrotor is assumed to have four rotors Each rotor consists of a brushless DC motor and rotor with a fixed pitch. It is assumed that the quadrotor can move in 6 degrees of freedom; 3-translational and 3-rotational, The motion of the quadrotor is controlled via 4 inputs namely the speeds of the 4 motors. The quadrotor model that this class implements assumes the following: More...

#include <quadrotor_dynamics.h>

Inheritance diagram for bitrl::dynamics::QuadrotorDynamics:
Collaboration diagram for bitrl::dynamics::QuadrotorDynamics:

Public Types

typedef MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVecbase_type
 
typedef base_type::state_type state_type
 The type of the state handled by this dynamics object.
 
typedef base_type::input_type input_type
 input_t The type of the input for solving the dynamics
 
typedef base_type::matrix_type matrix_type
 matrix_t Matrix type that describes the dynamics
 
typedef base_type::vector_type vector_type
 vector_t
 
- Public Types inherited from bitrl::dynamics::MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVec >
typedef SysState< 12 > state_type
 
typedef state_type output_type
 
typedef RealVec input_type
 
typedef DynamicsMatrixDescriptor matrix_descriptor_type
 
typedef matrix_descriptor_type::matrix_type matrix_type
 
typedef matrix_descriptor_type::vector_type vector_type
 

Public Member Functions

 QuadrotorDynamics (QuadrotorDynamicsConfig config, SysState< 12 > &state)
 QuadrotorDynamics Constructor. Specify the configuration parameters of the simulated quadrotor. It is assumed that the mass of the quadrotor remains fixed and the system state to be tracked.
 
virtual state_typeevaluate (const input_type &input) override
 Evaluate the new state using the given input it also updates the various matrices if needed.
 
void integrate (const RealVec &motor_w)
 Integrate the new state. It also uses error terms.
 
void translational_dynamics (const RealVec &motor_w)
 Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.
 
void rotational_dynamics (const RealVec &motor_w)
 Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.
 
RealColVec3d get_position () const
 Returns the current position NED frame. Note that the z-coordinate has to be multiplied with -1 in order to represent an upwards looking z-axis.
 
RealColVec3d get_velocity () const
 Returns the current linear velocity (body frame)
 
RealColVec3d get_angular_velocity () const
 Returns the current angular velocity (body frame)
 
RealColVec3d get_euler_angles () const
 Returns the Euler angles (0: phi, 1: theta, 2:psi)
 
real_t phi () const noexcept
 The phi Euler angle in rad.
 
real_t theta () const noexcept
 The theta Euler angle in rad.
 
real_t psi () const noexcept
 The psi Euler angle in rad.
 
- Public Member Functions inherited from bitrl::dynamics::MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVec >
virtual ~MotionModelDynamicsBase ()=default
 Destructor.
 
virtual state_typeevaluate (const input_type &input)=0
 Updates and returns the value of the state given the input.
 
const state_typeget_state () const
 Read access to the state.
 
state_typeget_state ()
 Read/write access to the state.
 
std::vector< std::string_view > get_state_variables_names () const
 get_state_variables_names. Returns the name of the variables in the state
 
matrix_typeget_matrix (const std::string &name)
 
const matrix_typeget_matrix (const std::string &name) const
 
void set_matrix (const std::string &name, const matrix_type &mat)
 
vector_typeget_vector (const std::string &name)
 
const vector_typeget_vector (const std::string &name) const
 
void set_vector (const std::string &name, const vector_type &vec)
 
void set_matrix_update_flag (bool f)
 set the matrix update flag
 
bool allows_matrix_updates () const
 Set the flag for updating or not the matrices describing the model.
 
bool has_matrix (const std::string &name) const
 Returns true if the matrix with the given name already exists.
 
real_t get_state_property (const std::string &name) const
 Returns the state property with the given name.
 
void set_state_property (const std::string &name, real_t value)
 Set the name-th value of the state.
 
void set_state_name_value (uint_t i, const std::string &name, real_t val)
 Set the state names.
 
void set_state_name_value (uint_t i, const std::pair< std::string, real_t > &val)
 Set the state names.
 
void set_time_step (real_t dt)
 Set the time step.
 
real_t get_time_step () const
 get_time_step Returns the sampling time the dynamics model is using
 
real_t get_tolerance () const
 get_tolerance Returns the general tolerance used in the calculations
 
void set_tolerance (real_t tol)
 set_tolerance Set the general tolerance used in the calculations. Default is KernelConsts::tolerance()
 

Additional Inherited Members

- Static Public Attributes inherited from bitrl::dynamics::MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVec >
static const uint_t state_dimension
 The dimension of the state.
 
- Protected Member Functions inherited from bitrl::dynamics::MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVec >
 MotionModelDynamicsBase (bool update_description_matrices_on_evaluate=true)
 Constructor.
 
 MotionModelDynamicsBase (const state_type &init_state, bool update_description_matrices_on_evaluate=true)
 Constructor.
 
- Protected Attributes inherited from bitrl::dynamics::MotionModelDynamicsBase< SysState< 12 >, DynamicsMatrixDescriptor, RealVec >
state_type state_
 The object describing the state of the object of which its dynamics are described/modeled by this MotionModel.
 
matrix_descriptor_type matrix_description_
 matrix descriptor
 
bool update_description_matrices_on_evaluate_
 flag indicating the update of the matrices the model is using to describe itself
 
real_t dt_
 The time step the integrator uses.
 
real_t tol_
 tolerance
 

Detailed Description

The QuadrotorDynamics class. Implements quadrotor dynamics The implementation of this class follows the System Modeling section at https://wilselby.com/research/arducopter/modeling/ and https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=2324&context=facpub The quadrotor is assumed to have four rotors Each rotor consists of a brushless DC motor and rotor with a fixed pitch. It is assumed that the quadrotor can move in 6 degrees of freedom; 3-translational and 3-rotational, The motion of the quadrotor is controlled via 4 inputs namely the speeds of the 4 motors. The quadrotor model that this class implements assumes the following:

  • The quadrotor structure is rigid and symmetrical with a center of mass aligned with the center of the body frame of the vehicle.
  • The thrust and drag of each motor is proportional to the square of the motor velocity.
  • The propellers are considered to be rigid and therefore blade flapping is negligible (deformation of propeller blades due to high velocities and flexible material).
  • The Earth is flat and non-rotating (difference of gravity by altitude or the spin of the earth is negligible)
  • Surrounding fluid velocities (wind) are negligible.
  • Ground effect is negligible

The class integrates the translational and rotational dynamics equations on the body frame

Member Typedef Documentation

◆ base_type

◆ input_type

typedef base_type::input_type bitrl::dynamics::QuadrotorDynamics::input_type

input_t The type of the input for solving the dynamics

◆ matrix_type

matrix_t Matrix type that describes the dynamics

◆ state_type

The type of the state handled by this dynamics object.

◆ vector_type

Constructor & Destructor Documentation

◆ QuadrotorDynamics()

bitrl::dynamics::QuadrotorDynamics::QuadrotorDynamics ( QuadrotorDynamicsConfig  config,
SysState< 12 > &  state 
)

QuadrotorDynamics Constructor. Specify the configuration parameters of the simulated quadrotor. It is assumed that the mass of the quadrotor remains fixed and the system state to be tracked.

Member Function Documentation

◆ evaluate()

QuadrotorDynamics::state_type & bitrl::dynamics::QuadrotorDynamics::evaluate ( const input_type input)
overridevirtual

Evaluate the new state using the given input it also updates the various matrices if needed.

◆ get_angular_velocity()

RealColVec3d bitrl::dynamics::QuadrotorDynamics::get_angular_velocity ( ) const
inline

Returns the current angular velocity (body frame)

◆ get_euler_angles()

RealColVec3d bitrl::dynamics::QuadrotorDynamics::get_euler_angles ( ) const
inline

Returns the Euler angles (0: phi, 1: theta, 2:psi)

◆ get_position()

RealColVec3d bitrl::dynamics::QuadrotorDynamics::get_position ( ) const
inline

Returns the current position NED frame. Note that the z-coordinate has to be multiplied with -1 in order to represent an upwards looking z-axis.

◆ get_velocity()

RealColVec3d bitrl::dynamics::QuadrotorDynamics::get_velocity ( ) const
inline

Returns the current linear velocity (body frame)

◆ integrate()

void bitrl::dynamics::QuadrotorDynamics::integrate ( const RealVec motor_w)

Integrate the new state. It also uses error terms.

◆ phi()

real_t bitrl::dynamics::QuadrotorDynamics::phi ( ) const
inlinenoexcept

The phi Euler angle in rad.

◆ psi()

real_t bitrl::dynamics::QuadrotorDynamics::psi ( ) const
inlinenoexcept

The psi Euler angle in rad.

◆ rotational_dynamics()

void bitrl::dynamics::QuadrotorDynamics::rotational_dynamics ( const RealVec motor_w)

Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.

◆ theta()

real_t bitrl::dynamics::QuadrotorDynamics::theta ( ) const
inlinenoexcept

The theta Euler angle in rad.

◆ translational_dynamics()

void bitrl::dynamics::QuadrotorDynamics::translational_dynamics ( const RealVec motor_w)

Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.


The documentation for this class was generated from the following files: