mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 06:54:49 +08:00
[ins] cleaning and dox update to better match what it actually does
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
#include "firmwares/rotorcraft/navigation.h"
|
#include "firmwares/rotorcraft/navigation.h"
|
||||||
|
|
||||||
#include "pprz_debug.h"
|
#include "pprz_debug.h"
|
||||||
#include "subsystems/gps.h"
|
#include "subsystems/gps.h" // needed by auto_nav from the flight plan
|
||||||
#include "subsystems/ins.h"
|
#include "subsystems/ins.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ static inline void nav_set_altitude( void ) {
|
|||||||
|
|
||||||
/** Reset the geographic reference to the current GPS fix */
|
/** Reset the geographic reference to the current GPS fix */
|
||||||
unit_t nav_reset_reference( void ) {
|
unit_t nav_reset_reference( void ) {
|
||||||
ins_reset_ground_ref();
|
ins_reset_local_origin();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
|
|
||||||
/** Inertial Navigation System state */
|
/** Inertial Navigation System state */
|
||||||
struct Ins {
|
struct Ins {
|
||||||
uint8_t status; ///< status of the INS
|
uint8_t status; ///< status of the INS
|
||||||
bool_t hf_realign; ///< realign horizontally if true
|
bool_t hf_realign; ///< flag to request to realign horizontal filter to current position (local origin unchanged)
|
||||||
bool_t vf_realign; ///< realign vertically if true
|
bool_t vf_realign; ///< flag to request to realign vertical filter to ground level (local origin unchanged)
|
||||||
};
|
};
|
||||||
|
|
||||||
/** global INS state */
|
/** global INS state */
|
||||||
@@ -60,11 +60,11 @@ extern void ins_init( void );
|
|||||||
*/
|
*/
|
||||||
extern void ins_periodic( void );
|
extern void ins_periodic( void );
|
||||||
|
|
||||||
/** INS ground reference reset.
|
/** INS local origin reset.
|
||||||
* Reset horizontal and vertical reference to the current position.
|
* Reset horizontal and vertical reference to the current position.
|
||||||
* Needs to be implemented by each INS algorithm.
|
* Needs to be implemented by each INS algorithm.
|
||||||
*/
|
*/
|
||||||
extern void ins_reset_ground_ref( void );
|
extern void ins_reset_local_origin( void );
|
||||||
|
|
||||||
/** INS altitude reference reset.
|
/** INS altitude reference reset.
|
||||||
* Reset only vertical reference to the current altitude.
|
* Reset only vertical reference to the current altitude.
|
||||||
@@ -81,6 +81,7 @@ extern void ins_reset_altitude_ref( void );
|
|||||||
extern void ins_reset_utm_zone(struct UtmCoor_f * utm);
|
extern void ins_reset_utm_zone(struct UtmCoor_f * utm);
|
||||||
|
|
||||||
/** INS horizontal realign.
|
/** INS horizontal realign.
|
||||||
|
* This only reset the filter to a given value, but doesn't change the local reference.
|
||||||
* @param pos new horizontal position to set
|
* @param pos new horizontal position to set
|
||||||
* @param speed new horizontal speed to set
|
* @param speed new horizontal speed to set
|
||||||
* Needs to be implemented by each INS algorithm.
|
* Needs to be implemented by each INS algorithm.
|
||||||
@@ -88,6 +89,7 @@ extern void ins_reset_utm_zone(struct UtmCoor_f * utm);
|
|||||||
extern void ins_realign_h(struct FloatVect2 pos, struct FloatVect2 speed);
|
extern void ins_realign_h(struct FloatVect2 pos, struct FloatVect2 speed);
|
||||||
|
|
||||||
/** INS vertical realign.
|
/** INS vertical realign.
|
||||||
|
* This only reset the filter to a given value, but doesn't change the local reference.
|
||||||
* @param z new altitude to set
|
* @param z new altitude to set
|
||||||
* Needs to be implemented by each INS algorithm.
|
* Needs to be implemented by each INS algorithm.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ void ins_periodic( void ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Reset the geographic reference to the current GPS fix */
|
/** Reset the geographic reference to the current GPS fix */
|
||||||
void ins_reset_ground_ref( void ) {
|
void ins_reset_local_origin( void ) {
|
||||||
struct UtmCoor_f utm;
|
struct UtmCoor_f utm;
|
||||||
#ifdef GPS_USE_LATLONG
|
#ifdef GPS_USE_LATLONG
|
||||||
/* Recompute UTM coordinates in this zone */
|
/* Recompute UTM coordinates in this zone */
|
||||||
@@ -149,6 +149,9 @@ void ins_realign_h(struct FloatVect2 pos __attribute__ ((unused)), struct FloatV
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ins_realign_v(float z __attribute__ ((unused))) {
|
void ins_realign_v(float z __attribute__ ((unused))) {
|
||||||
|
ins_alt = z;
|
||||||
|
ins_alt_dot = 0.;
|
||||||
|
alt_kalman_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_propagate() {
|
void ins_propagate() {
|
||||||
|
|||||||
@@ -42,14 +42,6 @@ extern float ins_baro_alt;
|
|||||||
extern bool_t ins_baro_initialized;
|
extern bool_t ins_baro_initialized;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Reset the UTM zone to the current gps fix
|
|
||||||
*
|
|
||||||
* This function must be called with a valid GPS position
|
|
||||||
*
|
|
||||||
* @param utm initial utm position, returned with a corrected utm zone
|
|
||||||
*/
|
|
||||||
extern void ins_reset_utm_zone(struct UtmCoor_f * utm);
|
|
||||||
|
|
||||||
extern void alt_kalman_reset( void );
|
extern void alt_kalman_reset( void );
|
||||||
extern void alt_kalman_init( void );
|
extern void alt_kalman_init( void );
|
||||||
extern void alt_kalman( float );
|
extern void alt_kalman( float );
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void ins_periodic( void ) {
|
|||||||
ins.status = INS_RUNNING;
|
ins.status = INS_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_reset_ground_ref( void ) {
|
void ins_reset_local_origin( void ) {
|
||||||
ins_impl.ltp_initialized = FALSE;
|
ins_impl.ltp_initialized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ void ins_periodic(void) {}
|
|||||||
void ins_propagate(void) {}
|
void ins_propagate(void) {}
|
||||||
|
|
||||||
|
|
||||||
void ins_reset_ground_ref( void ) {
|
void ins_reset_local_origin( void ) {
|
||||||
#if INS_UPDATE_FW_ESTIMATOR
|
#if INS_UPDATE_FW_ESTIMATOR
|
||||||
struct UtmCoor_f utm;
|
struct UtmCoor_f utm;
|
||||||
#ifdef GPS_USE_LATLONG
|
#ifdef GPS_USE_LATLONG
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void ins_init() {
|
|||||||
void ins_periodic( void ) {
|
void ins_periodic( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_reset_ground_ref( void ) {
|
void ins_reset_local_origin( void ) {
|
||||||
struct UtmCoor_f utm;
|
struct UtmCoor_f utm;
|
||||||
#ifdef GPS_USE_LATLONG
|
#ifdef GPS_USE_LATLONG
|
||||||
/* Recompute UTM coordinates in this zone */
|
/* Recompute UTM coordinates in this zone */
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ static void send_ins_ref(void) {
|
|||||||
|
|
||||||
static void ins_init_origin_from_flightplan(void);
|
static void ins_init_origin_from_flightplan(void);
|
||||||
static void ins_ned_to_state(void);
|
static void ins_ned_to_state(void);
|
||||||
|
static void ins_update_from_vff(void);
|
||||||
#if USE_HFF
|
#if USE_HFF
|
||||||
static void ins_update_from_hff(void);
|
static void ins_update_from_hff(void);
|
||||||
#endif
|
#endif
|
||||||
@@ -170,7 +171,7 @@ void ins_periodic(void) {
|
|||||||
ins.status = INS_RUNNING;
|
ins.status = INS_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_reset_ground_ref( void ) {
|
void ins_reset_local_origin( void ) {
|
||||||
ins_impl.ltp_initialized = FALSE;
|
ins_impl.ltp_initialized = FALSE;
|
||||||
#if USE_HFF
|
#if USE_HFF
|
||||||
ins.hf_realign = TRUE;
|
ins.hf_realign = TRUE;
|
||||||
@@ -190,6 +191,7 @@ void ins_reset_altitude_ref( void ) {
|
|||||||
#if USE_HFF
|
#if USE_HFF
|
||||||
void ins_realign_h(struct FloatVect2 pos, struct FloatVect2 speed) {
|
void ins_realign_h(struct FloatVect2 pos, struct FloatVect2 speed) {
|
||||||
b2_hff_realign(pos, speed);
|
b2_hff_realign(pos, speed);
|
||||||
|
ins_update_from_hff();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void ins_realign_h(struct FloatVect2 pos __attribute__ ((unused)),
|
void ins_realign_h(struct FloatVect2 pos __attribute__ ((unused)),
|
||||||
@@ -199,6 +201,7 @@ void ins_realign_h(struct FloatVect2 pos __attribute__ ((unused)),
|
|||||||
|
|
||||||
void ins_realign_v(float z) {
|
void ins_realign_v(float z) {
|
||||||
vff_realign(z);
|
vff_realign(z);
|
||||||
|
ins_update_from_vff();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_propagate() {
|
void ins_propagate() {
|
||||||
@@ -211,9 +214,7 @@ void ins_propagate() {
|
|||||||
float z_accel_meas_float = ACCEL_FLOAT_OF_BFP(accel_meas_ltp.z);
|
float z_accel_meas_float = ACCEL_FLOAT_OF_BFP(accel_meas_ltp.z);
|
||||||
if (ins_impl.baro_initialized) {
|
if (ins_impl.baro_initialized) {
|
||||||
vff_propagate(z_accel_meas_float);
|
vff_propagate(z_accel_meas_float);
|
||||||
ins_impl.ltp_accel.z = ACCEL_BFP_OF_REAL(vff_zdotdot);
|
ins_update_from_vff();
|
||||||
ins_impl.ltp_speed.z = SPEED_BFP_OF_REAL(vff_zdot);
|
|
||||||
ins_impl.ltp_pos.z = POS_BFP_OF_REAL(vff_z);
|
|
||||||
}
|
}
|
||||||
else { // feed accel from the sensors
|
else { // feed accel from the sensors
|
||||||
// subtract -9.81m/s2 (acceleration measured due to gravity,
|
// subtract -9.81m/s2 (acceleration measured due to gravity,
|
||||||
@@ -243,9 +244,7 @@ static void baro_cb(uint8_t __attribute__((unused)) sender_id, const float *pres
|
|||||||
ins.vf_realign = FALSE;
|
ins.vf_realign = FALSE;
|
||||||
ins_impl.qfe = *pressure;
|
ins_impl.qfe = *pressure;
|
||||||
vff_realign(0.);
|
vff_realign(0.);
|
||||||
ins_impl.ltp_accel.z = ACCEL_BFP_OF_REAL(vff_zdotdot);
|
ins_update_from_vff();
|
||||||
ins_impl.ltp_speed.z = SPEED_BFP_OF_REAL(vff_zdot);
|
|
||||||
ins_impl.ltp_pos.z = POS_BFP_OF_REAL(vff_z);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ins_impl.baro_z = -pprz_isa_height_of_pressure(*pressure, ins_impl.qfe);
|
ins_impl.baro_z = -pprz_isa_height_of_pressure(*pressure, ins_impl.qfe);
|
||||||
@@ -411,6 +410,12 @@ static void ins_ned_to_state(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** update ins state from vertical filter */
|
||||||
|
static void ins_update_from_vff(void) {
|
||||||
|
ins_impl.ltp_accel.z = ACCEL_BFP_OF_REAL(vff_zdotdot);
|
||||||
|
ins_impl.ltp_speed.z = SPEED_BFP_OF_REAL(vff_zdot);
|
||||||
|
ins_impl.ltp_pos.z = POS_BFP_OF_REAL(vff_z);
|
||||||
|
}
|
||||||
|
|
||||||
#if USE_HFF
|
#if USE_HFF
|
||||||
/** update ins state from horizontal filter */
|
/** update ins state from horizontal filter */
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ unit_t nav_reset_utm_zone(void) {
|
|||||||
/** Reset the geographic reference to the current GPS fix */
|
/** Reset the geographic reference to the current GPS fix */
|
||||||
unit_t nav_reset_reference( void ) {
|
unit_t nav_reset_reference( void ) {
|
||||||
/* realign INS */
|
/* realign INS */
|
||||||
ins_reset_ground_ref();
|
ins_reset_local_origin();
|
||||||
|
|
||||||
/* Set nav UTM ref */
|
/* Set nav UTM ref */
|
||||||
nav_utm_east0 = state.utm_origin_f.east;
|
nav_utm_east0 = state.utm_origin_f.east;
|
||||||
|
|||||||
Reference in New Issue
Block a user