APM:Libraries
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
SITL::Calibration Class Reference

#include <SIM_Calibration.h>

Inheritance diagram for SITL::Calibration:
[legend]
Collaboration diagram for SITL::Calibration:
[legend]

Public Member Functions

 Calibration (const char *home_str, const char *frame_str)
 
void update (const struct sitl_input &input)
 
- Public Member Functions inherited from SITL::Aircraft
 Aircraft (const char *home_str, const char *frame_str)
 
void set_speedup (float speedup)
 
void set_instance (uint8_t _instance)
 
void set_autotest_dir (const char *_autotest_dir)
 
virtual void set_interface_ports (const char *address, const int port_in, const int port_out)
 
void fill_fdm (struct sitl_fdm &fdm)
 
void smooth_sensors (void)
 
float get_rate_hz (void) const
 
const Vector3fget_gyro (void) const
 
const Vector3fget_velocity_ef (void) const
 
const Vector3fget_velocity_air_ef (void) const
 
const Matrix3fget_dcm (void) const
 
const Vector3fget_mag_field_bf (void) const
 
virtual float gross_mass () const
 
const Locationget_location () const
 
const Vector3fget_position () const
 
void get_attitude (Quaternion &attitude) const
 

Static Public Member Functions

static Aircraftcreate (const char *home_str, const char *frame_str)
 
- Static Public Member Functions inherited from SITL::Aircraft
static double rand_normal (double mean, double stddev)
 
static bool parse_home (const char *home_str, Location &loc, float &yaw_degrees)
 

Private Member Functions

void _stop_control (const struct sitl_input &input, Vector3f &rot_accel)
 
void _attitude_set (float desired_roll, float desired_pitch, float desired_yaw, Vector3f &rot_accel)
 
void _attitude_control (const struct sitl_input &input, Vector3f &rot_accel)
 
void _angular_velocity_control (const struct sitl_input &input, Vector3f &rot_accel)
 
void _calibration_poses (Vector3f &rot_accel)
 

Additional Inherited Members

- Protected Types inherited from SITL::Aircraft
enum  { GROUND_BEHAVIOR_NONE = 0, GROUND_BEHAVIOR_NO_MOVEMENT, GROUND_BEHAVIOR_FWD_ONLY, GROUND_BEHAVIOR_TAILSITTER }
 
- Protected Member Functions inherited from SITL::Aircraft
float ground_height_difference () const
 
virtual bool on_ground () const
 
float hagl () const
 
void update_position (void)
 
void update_mag_field_bf (void)
 
void time_advance ()
 
void setup_frame_time (float rate, float speedup)
 
void adjust_frame_time (float rate)
 
void sync_frame_time (void)
 
void add_noise (float throttle)
 
uint64_t get_wall_time_us (void) const
 
void update_dynamics (const Vector3f &rot_accel)
 
void update_wind (const struct sitl_input &input)
 
float filtered_idx (float v, uint8_t idx)
 
float filtered_servo_angle (const struct sitl_input &input, uint8_t idx)
 
float filtered_servo_range (const struct sitl_input &input, uint8_t idx)
 
void extrapolate_sensors (float delta_time)
 
- Protected Attributes inherited from SITL::Aircraft
SITLsitl
 
Location home
 
Location location
 
float ground_level
 
float home_yaw
 
float frame_height
 
Matrix3f dcm
 
Vector3f gyro
 
Vector3f gyro_prev
 
Vector3f ang_accel
 
Vector3f velocity_ef
 
Vector3f wind_ef
 
Vector3f velocity_air_ef
 
Vector3f velocity_air_bf
 
Vector3f position
 
float mass
 
Vector3f accel_body
 
float airspeed
 
float airspeed_pitot
 
float battery_voltage = -1.0f
 
float battery_current = 0.0f
 
float rpm1 = 0
 
float rpm2 = 0
 
uint8_t rcin_chan_count = 0
 
float rcin [8]
 
float range = -1.0f
 
float turbulence_azimuth = 0.0f
 
float turbulence_horizontal_speed = 0.0f
 
float turbulence_vertical_speed = 0.0f
 
Vector3f mag_bf
 
uint64_t time_now_us
 
const float gyro_noise
 
const float accel_noise
 
float rate_hz
 
float achieved_rate_hz
 
float target_speedup
 
uint64_t frame_time_us
 
float scaled_frame_time_us
 
uint64_t last_wall_time_us
 
uint8_t instance
 
const char * autotest_dir
 
const char * frame
 
bool use_time_sync = true
 
float last_speedup = -1.0f
 
AP_Int8 * ahrs_orientation
 
enum SITL::Aircraft:: { ... }  ground_behavior
 
bool use_smoothing
 
AP_Terrain * terrain
 
const float FEET_TO_METERS = 0.3048f
 
const float KNOTS_TO_METERS_PER_SECOND = 0.51444f
 

Detailed Description

Simulation model to simulate calibration of accelerometers and compasses.

The vehicle rotation can be controlled by sending PWM values to the servos input, denoted by PWM[i] for the i-th channel (starting by zero). All PWM values must be in [1000, 2000], otherwise that will cause undefined behavior.

There are four control modes, that are set with PWM[4]:

1) Stop (1000 <= PWM[4] < 1100): Stop the vehicle, i.e., stop the actuation of the other modes.

2) Attitude (1100 <= PWM[4] < 1200): Rotate the vehicle to the specified attitude. The attitude is defined with the PWM channels 5, 6 and 7 for roll, pitch and yaw angles, respectively. The PWM value for a desired angle in radians is given by:

pwm(theta) = 1500 + 500 * round(theta / pi)
where -pi <= theta <= pi

3) Simple autonomous compass calibration (1200 <= PWM[4] < 1300): Move continuously the vehicle through six calibration poses and do a rotation about each pose over a short period of time.

4) Angular Velocity (1300 <= PWM[4] <= 2000): Rotate the vehicle at a desired angular velocity. The angular velocity is specified by a rotation axis and an angular speed.

The x, y and z components of the rotation axis is given, respectively, by the PWM channels 5, 6 and 7 with an offset of 1500. The rotation axis is normalized internally, so that PWM[5,6,7] = [1600, 1300, 0] and PWM[5,6,7] = [1700, 1100, 0] means the same normalized rotation axis.

The angular speed value is specified by PWM[4]. The PWM value for a desired angular speed in radians/s is given by:

pwm(theta) = 1300 + 700 * round(theta / (2 * pi)),
where 0 <= theta <= 2 * pi

Definition at line 65 of file SIM_Calibration.h.

Constructor & Destructor Documentation

◆ Calibration()

SITL::Calibration::Calibration ( const char *  home_str,
const char *  frame_str 
)

Definition at line 27 of file SIM_Calibration.cpp.

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ _angular_velocity_control()

void SITL::Calibration::_angular_velocity_control ( const struct sitl_input input,
Vector3f rot_accel 
)
private

Definition at line 106 of file SIM_Calibration.cpp.

Referenced by create(), and update().

Here is the caller graph for this function:

◆ _attitude_control()

void SITL::Calibration::_attitude_control ( const struct sitl_input input,
Vector3f rot_accel 
)
private

Definition at line 68 of file SIM_Calibration.cpp.

Referenced by create(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _attitude_set()

void SITL::Calibration::_attitude_set ( float  desired_roll,
float  desired_pitch,
float  desired_yaw,
Vector3f rot_accel 
)
private

Definition at line 79 of file SIM_Calibration.cpp.

Referenced by _attitude_control(), and create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _calibration_poses()

void SITL::Calibration::_calibration_poses ( Vector3f rot_accel)
private

Definition at line 131 of file SIM_Calibration.cpp.

Referenced by create(), and update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _stop_control()

void SITL::Calibration::_stop_control ( const struct sitl_input input,
Vector3f rot_accel 
)
private

Definition at line 57 of file SIM_Calibration.cpp.

Referenced by create(), and update().

Here is the caller graph for this function:

◆ create()

static Aircraft* SITL::Calibration::create ( const char *  home_str,
const char *  frame_str 
)
inlinestatic

Definition at line 71 of file SIM_Calibration.h.

Here is the call graph for this function:

◆ update()

void SITL::Calibration::update ( const struct sitl_input input)
virtual

Implements SITL::Aircraft.

Definition at line 33 of file SIM_Calibration.cpp.

Here is the call graph for this function:

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