SimpleMultirotor
- class SimpleMultirotor(params_file, env=None, effector=None, egm_bin_file=None, library_dir=None, **kwargs)[source]
Bases:
DynamicsBase
Implements functions for a generic multi-rotor.
- env
Environment the vehicle is in.
- Type:
- __init__(params_file, env=None, effector=None, egm_bin_file=None, library_dir=None, **kwargs)[source]
Initialize an object.
- Parameters:
params_file (string) – Full path to the config file.
env (
Environment
, optional) – Environment for the vehicle. The default is None.effector (
Effector
, optional) – Effector for the vehicle. The default is None.egm_bin_file (string, optional) – Full path to the binary file for the EGM model. The default is None.
library_dir (string, optional) – Default directory to look for config files defined by the package. This is useful when extending this class outside of the gncpy package to provide a new default search location. The default of None is good for most other cases.
**kwargs (dict) – Additional arguments for the parent class.
Methods
Initialize an object.
Gets the input matrix, should not be used.
Gets the state matrix, should not be used.
Propagates all internal states forward 1 timestep.
Sets the initial conditions for the state based on a few inputs.
Validate that the parameters file exists.
Attributes
allow_cpp
control_model
List of vehicle state names.
List of vehicle state units.
- state_map
Map of states to indices with units.
alias of
v_smap
- get_input_mat(timestep, *args, **kwargs)[source]
Gets the input matrix, should not be used.
- Parameters:
timestep (float) – Current time.
*args (tuple) – Additional arguments.
**kwargs (dict) – Additional arguments.
- Raises:
RuntimeError – This function should not be used.
- get_state_mat(timestep, *args, **kwargs)[source]
Gets the state matrix, should not be used.
- Parameters:
timestep (float) – Current time.
*args (tuple) – Additional arguments.
**kwargs (dict) – Additional arguments.
- Raises:
RuntimeError – This function should not be used.
- propagate_state(desired_motor_cmds, dt)[source]
Propagates all internal states forward 1 timestep.
- Parameters:
desired_motor_cmds (numpy array) – The desired commands for the motors. Depending on the effectors these may not be fully realized.
dt (float) – Time change since the last update (seconds).
- Returns:
Copy of the internal vehicle state.
- Return type:
numpy array
- set_initial_conditions(ned_pos, body_vel, eul_deg, body_rot_rate, ref_lat_deg, ref_lon_deg, terrain_alt_wgs84, ned_mag_field)[source]
Sets the initial conditions for the state based on a few inputs.
- Parameters:
ned_pos (numpy array) – Body position in NED frame.
body_vel (numpy array) – Velocity of the body in body frame.
eul_deg (numpy array) – Initial attidue in degrees and yaw, pitch, roll order.
body_rot_rate (numpy array) – Initial body rotation rate (rad/s).
ref_lat_deg (float) – Reference latitude in degrees.
ref_lon_deg (float) – Reference longitude in degrees.
terrain_alt_wgs84 (float) – Altitude of the terrain relative to WGS-84 model in meters, and the home altitude for the starting NED positioin.
ned_mag_field (numpy array) – Local magnetic field vector in NED frame and uT.
- validate_params_file(params_file)[source]
Validate that the parameters file exists.
If the path seperator is in the name then it is assumed a full path is given and it is directly checked. Otherwise the current working directory is checked first then if that fails the default library location is checked.
- Parameters:
params_file (string) – Path to config file (with name and extension).
- Raises:
FileNotFoundError – If the file does not exist.
- Returns:
cf – Full path to the config file (with name and extension).
- Return type:
string
- state_names = ('lat', 'lon', 'alt_wgs84', 'alt_msl', 'ned_pos_0', 'ned_pos_1', 'ned_pos_2', 'ned_vel_0', 'ned_vel_1', 'ned_vel_2', 'ned_accel_0', 'ned_accel_1', 'ned_accel_2', 'pitch', 'roll', 'yaw', 'body_vel_0', 'body_vel_1', 'body_vel_2', 'body_accel_0', 'body_accel_1', 'body_accel_2', 'body_rot_rate_0', 'body_rot_rate_1', 'body_rot_rate_2', 'body_rot_accel_0', 'body_rot_accel_1', 'body_rot_accel_2', 'dyn_pres', 'airspeed', 'mach', 'aoa', 'aoa_rate', 'sideslip_ang', 'sideslip_rate', 'gnd_trk', 'fp_ang', 'gnd_speed', 'dcm_earth2body_00', 'dcm_earth2body_01', 'dcm_earth2body_02', 'dcm_earth2body_10', 'dcm_earth2body_11', 'dcm_earth2body_12', 'dcm_earth2body_20', 'dcm_earth2body_21', 'dcm_earth2body_22', 'alt_agl')
List of vehicle state names.
- state_units = ('rad', 'rad', 'm', 'm', 'm', 'm', 'm', 'm/s', 'm/s', 'm/s', 'm/s^2', 'm/s^2', 'm/s^2', 'rad', 'rad', 'rad', 'm/s', 'm/s', 'm/s', 'm/s^2', 'm/s^2', 'm/s^2', 'rad/s', 'rad/s', 'rad/s', 'rad/s^2', 'rad/s^2', 'rad/s^2', 'Pa', 'm/s', '', 'rad', 'rad/s', 'rad', 'rad/s', 'rad', 'rad', 'm/s', '', '', '', '', '', '', '', '', '', 'm')
List of vehicle state units.