diff --git a/sw/airborne/subsystems/ahrs.h b/sw/airborne/subsystems/ahrs.h index 5a30258d63..158f8a7fd8 100644 --- a/sw/airborne/subsystems/ahrs.h +++ b/sw/airborne/subsystems/ahrs.h @@ -19,6 +19,10 @@ * Boston, MA 02111-1307, USA. */ +/** \file ahrs.h + * \brief Attitude and Heading Reference System interface + */ + #ifndef AHRS_H #define AHRS_H @@ -34,41 +38,44 @@ #include AHRS_TYPE_H #endif - +/** Attitude and Heading Reference System state (fixed point version) */ struct Ahrs { - struct Int32Quat ltp_to_imu_quat; - struct Int32Eulers ltp_to_imu_euler; - struct Int32RMat ltp_to_imu_rmat; - struct Int32Rates imu_rate; + struct Int32Quat ltp_to_imu_quat; ///< Rotation from LocalTangentPlane to IMU frame as unit quaternion + struct Int32Eulers ltp_to_imu_euler; ///< Rotation from LocalTangentPlane to IMU frame as Euler angles + struct Int32RMat ltp_to_imu_rmat; ///< Rotation from LocalTangentPlane to IMU frame as Rotation Matrix + struct Int32Rates imu_rate; ///< Rotational velocity in IMU frame - struct Int32Quat ltp_to_body_quat; - struct Int32Eulers ltp_to_body_euler; - struct Int32RMat ltp_to_body_rmat; - struct Int32Rates body_rate; + struct Int32Quat ltp_to_body_quat; ///< Rotation from LocalTangentPlane to body frame as unit quaternion + struct Int32Eulers ltp_to_body_euler; ///< Rotation from LocalTangentPlane to body frame as Euler angles + struct Int32RMat ltp_to_body_rmat; ///< Rotation from LocalTangentPlane to body frame as Rotation Matrix + struct Int32Rates body_rate; ///< Rotational velocity in body frame - uint8_t status; + uint8_t status; ///< status of the AHRS, AHRS_UNINIT or AHRS_RUNNING }; +/** Attitude and Heading Reference System state (floating point version) */ struct AhrsFloat { - struct FloatQuat ltp_to_imu_quat; - struct FloatEulers ltp_to_imu_euler; - struct FloatRMat ltp_to_imu_rmat; - struct FloatRates imu_rate; + struct FloatQuat ltp_to_imu_quat; ///< Rotation from LocalTangentPlane to IMU frame as unit quaternion + struct FloatEulers ltp_to_imu_euler; ///< Rotation from LocalTangentPlane to IMU frame as Euler angles + struct FloatRMat ltp_to_imu_rmat; ///< Rotation from LocalTangentPlane to IMU frame as Rotation Matrix + struct FloatRates imu_rate; ///< Rotational velocity in IMU frame struct FloatRates imu_rate_previous; struct FloatRates imu_rate_d; - struct FloatQuat ltp_to_body_quat; - struct FloatEulers ltp_to_body_euler; - struct FloatRMat ltp_to_body_rmat; - struct FloatRates body_rate; + struct FloatQuat ltp_to_body_quat; ///< Rotation from LocalTangentPlane to body frame as unit quaternion + struct FloatEulers ltp_to_body_euler; ///< Rotation from LocalTangentPlane to body frame as Euler angles + struct FloatRMat ltp_to_body_rmat; ///< Rotation from LocalTangentPlane to body frame as Rotation Matrix + struct FloatRates body_rate; ///< Rotational velocity in body frame struct FloatRates body_rate_d; // always use status from fixed point ahrs struct for now //uint8_t status; }; +/** global AHRS state (fixed point version) */ extern struct Ahrs ahrs; +/** global AHRS state (floating point version) */ extern struct AhrsFloat ahrs_float; extern float ahrs_mag_offset; @@ -86,10 +93,33 @@ extern float ahrs_mag_offset; RATES_BFP_OF_REAL(ahrs.body_rate, ahrs_float.body_rate); \ } +/** AHRS initialization. Called at startup. + * Needs to be implemented by each AHRS algorithm. + */ extern void ahrs_init(void); + +/** Aligns the AHRS. Called after ahrs_aligner has run to set initial attitude and biases. + * Must set the ahrs status to AHRS_RUNNING. + * Needs to be implemented by each AHRS algorithm. + */ extern void ahrs_align(void); + +/** Propagation. Usually integrates the gyro rates to angles. + * Reads the global #imu data struct. + * Needs to be implemented by each AHRS algorithm. + */ extern void ahrs_propagate(void); + +/** Update AHRS state with accerleration measurements. + * Reads the global #imu data struct. + * Needs to be implemented by each AHRS algorithm. + */ extern void ahrs_update_accel(void); + +/** Update AHRS state with magnetometer measurements. + * Reads the global #imu data struct. + * Needs to be implemented by each AHRS algorithm. + */ extern void ahrs_update_mag(void); #endif /* AHRS_H */ diff --git a/sw/airborne/subsystems/gps.c b/sw/airborne/subsystems/gps.c index 4d50a634dc..0c827a85f2 100644 --- a/sw/airborne/subsystems/gps.c +++ b/sw/airborne/subsystems/gps.c @@ -19,6 +19,11 @@ * Boston, MA 02111-1307, USA. */ +/** @file gps.c + * @brief Device independent GPS code + * + */ + #include "subsystems/gps.h" #include "led.h" diff --git a/sw/airborne/subsystems/gps.h b/sw/airborne/subsystems/gps.h index 2d46b16c0d..64370bb209 100644 --- a/sw/airborne/subsystems/gps.h +++ b/sw/airborne/subsystems/gps.h @@ -20,7 +20,7 @@ */ /** @file gps.h - * @brief Device independent GPS code + * @brief Device independent GPS code (interface) * */ @@ -48,16 +48,17 @@ #define GPS_NB_CHANNELS 1 #endif -/** Space Vehicle Information */ +/** data structure for Space Vehicle Information of a single satellite */ struct SVinfo { - uint8_t svid; - uint8_t flags; - uint8_t qi; - uint8_t cno; - int8_t elev; ///< deg - int16_t azim; ///< deg + uint8_t svid; ///< Satellite ID + uint8_t flags; ///< bitfield with GPS receiver specific flags + uint8_t qi; ///< quality bitfield (GPS receiver specific) + uint8_t cno; ///< Carrier to Noise Ratio (Signal Strength) in dbHz + int8_t elev; ///< elevation in deg + int16_t azim; ///< azimuth in deg }; +/** data structure for GPS information */ struct GpsState { struct EcefCoor_i ecef_pos; ///< position in ECEF in cm struct LlaCoor_i lla_pos; ///< position in LLA (lat,lon: rad*1e7; alt: mm over ellipsoid) @@ -77,7 +78,7 @@ struct GpsState { uint32_t tow; ///< time of week in ms uint8_t nb_channels; ///< Number of scanned satellites - struct SVinfo svinfos[GPS_NB_CHANNELS]; + struct SVinfo svinfos[GPS_NB_CHANNELS]; ///< holds information from the Space Vehicles (Satellites) uint32_t last_fix_ticks; ///< cpu time in ticks at last valid fix uint16_t last_fix_time; ///< cpu time in sec at last valid fix @@ -90,6 +91,7 @@ struct GpsTimeSync { uint32_t t0; ///< for time sync: hw clock ticks when GPS message is received }; +/** global GPS state */ extern struct GpsState gps; diff --git a/sw/airborne/subsystems/imu.c b/sw/airborne/subsystems/imu.c index 515adc6b38..714ce9a049 100644 --- a/sw/airborne/subsystems/imu.c +++ b/sw/airborne/subsystems/imu.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/** \file imu.c + * \brief Inertial Measurement Unit interface + */ + #include "subsystems/imu.h" struct Imu imu; diff --git a/sw/airborne/subsystems/imu.h b/sw/airborne/subsystems/imu.h index 43bf62a56f..f2889e09bf 100644 --- a/sw/airborne/subsystems/imu.h +++ b/sw/airborne/subsystems/imu.h @@ -20,6 +20,9 @@ * the Free Software Foundation, 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +/** \file imu.h + * \brief Inertial Measurement Unit interface + */ #ifndef IMU_H #define IMU_H @@ -32,23 +35,24 @@ extern void imu_impl_init(void); extern void imu_periodic(void); +/** abstract IMU interface providing fixed point interface */ struct Imu { - struct Int32Rates gyro; - struct Int32Vect3 accel; - struct Int32Vect3 mag; - struct Int32Rates gyro_prev; - struct Int32Vect3 accel_prev; - struct Int32Rates gyro_neutral; - struct Int32Vect3 accel_neutral; - struct Int32Vect3 mag_neutral; - struct Int32Rates gyro_unscaled; - struct Int32Vect3 accel_unscaled; - struct Int32Vect3 mag_unscaled; - struct Int32Quat body_to_imu_quat; - struct Int32RMat body_to_imu_rmat; + struct Int32Rates gyro; ///< gyroscope measurements + struct Int32Vect3 accel; ///< accelerometer measurements + struct Int32Vect3 mag; ///< magnetometer measurements + struct Int32Rates gyro_prev; ///< previous gyroscope measurements + struct Int32Vect3 accel_prev; ///< previous accelerometer measurements + struct Int32Rates gyro_neutral; ///< gyroscope bias + struct Int32Vect3 accel_neutral; ///< accelerometer bias + struct Int32Vect3 mag_neutral; ///< magnetometer neutral readings (bias) + struct Int32Rates gyro_unscaled; ///< unscaled gyroscope measurements + struct Int32Vect3 accel_unscaled; ///< unscaled accelerometer measurements + struct Int32Vect3 mag_unscaled; ///< unscaled magnetometer measurements + struct Int32Quat body_to_imu_quat; ///< rotation from body to imu frame as a unit quaternion + struct Int32RMat body_to_imu_rmat; ///< rotation from body to imu frame as a rotation matrix }; -/* abstract IMU interface providing floating point interface */ +/** abstract IMU interface providing floating point interface */ struct ImuFloat { struct FloatRates gyro; struct FloatVect3 accel; @@ -61,6 +65,8 @@ struct ImuFloat { }; extern void imu_float_init(struct ImuFloat* imuf); + +/** global IMU state */ extern struct Imu imu; /* underlying hardware */