mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 05:42:49 +08:00
[ahrs] start getting rid of global ahrs.state
This commit is contained in:
@@ -92,7 +92,10 @@ bool_t autopilot_detect_ground_once;
|
|||||||
#include "subsystems/ahrs.h"
|
#include "subsystems/ahrs.h"
|
||||||
static inline int ahrs_is_aligned(void)
|
static inline int ahrs_is_aligned(void)
|
||||||
{
|
{
|
||||||
return (ahrs.status == AHRS_RUNNING);
|
/* FIXME: proper ahrs status management
|
||||||
|
* maybe use one global AhrsStatus enum again that all implementations need to use
|
||||||
|
*/
|
||||||
|
return (DefaultAhrsImpl.status == AHRS_MLKF_RUNNING);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PRINT_CONFIG_MSG("Using AUTOPILOT_DISABLE_AHRS_KILL")
|
PRINT_CONFIG_MSG("Using AUTOPILOT_DISABLE_AHRS_KILL")
|
||||||
|
|||||||
@@ -374,11 +374,8 @@ static inline void on_gyro_event( void ) {
|
|||||||
AbiSendMsgIMU_GYRO_INT32(1, &now_ts, &imu.gyro_prev);
|
AbiSendMsgIMU_GYRO_INT32(1, &now_ts, &imu.gyro_prev);
|
||||||
|
|
||||||
#if USE_AHRS_ALIGNER
|
#if USE_AHRS_ALIGNER
|
||||||
if (ahrs.status != AHRS_RUNNING) {
|
if (ahrs_aligner.status != AHRS_ALIGNER_LOCKED) {
|
||||||
ahrs_aligner_run();
|
ahrs_aligner_run();
|
||||||
if (ahrs_aligner.status == AHRS_ALIGNER_LOCKED) {
|
|
||||||
ahrs.status = AHRS_RUNNING;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "subsystems/ahrs.h"
|
#include "subsystems/ahrs.h"
|
||||||
#include "subsystems/imu.h"
|
|
||||||
|
|
||||||
struct Ahrs ahrs;
|
struct Ahrs ahrs;
|
||||||
|
|
||||||
@@ -36,20 +35,17 @@ void ahrs_register_impl(AhrsInit init, AhrsUpdateGps update_gps)
|
|||||||
ahrs.update_gps = update_gps;
|
ahrs.update_gps = update_gps;
|
||||||
|
|
||||||
ahrs.init();
|
ahrs.init();
|
||||||
|
|
||||||
ahrs.status = AHRS_REGISTERED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ahrs_init(void)
|
void ahrs_init(void)
|
||||||
{
|
{
|
||||||
ahrs.status = AHRS_UNINIT;
|
|
||||||
ahrs.init = NULL;
|
ahrs.init = NULL;
|
||||||
ahrs.update_gps = NULL;
|
ahrs.update_gps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ahrs_update_gps(void)
|
void ahrs_update_gps(void)
|
||||||
{
|
{
|
||||||
if (ahrs.update_gps != NULL && ahrs.status == AHRS_RUNNING) {
|
if (ahrs.update_gps != NULL) {
|
||||||
ahrs.update_gps();
|
ahrs.update_gps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,6 @@
|
|||||||
#define AHRS_H
|
#define AHRS_H
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "math/pprz_algebra_int.h"
|
|
||||||
#include "math/pprz_algebra_float.h"
|
|
||||||
#include "math/pprz_orientation_conversion.h"
|
|
||||||
|
|
||||||
#define AHRS_UNINIT 0
|
|
||||||
#define AHRS_REGISTERED 1
|
|
||||||
#define AHRS_RUNNING 2
|
|
||||||
|
|
||||||
/* underlying includes (needed for parameters) */
|
/* underlying includes (needed for parameters) */
|
||||||
#ifdef AHRS_TYPE_H
|
#ifdef AHRS_TYPE_H
|
||||||
@@ -46,8 +39,6 @@ typedef void (*AhrsUpdateGps)(void);
|
|||||||
|
|
||||||
/** Attitude and Heading Reference System state */
|
/** Attitude and Heading Reference System state */
|
||||||
struct Ahrs {
|
struct Ahrs {
|
||||||
uint8_t status; ///< status of the AHRS, AHRS_UNINIT or AHRS_RUNNING
|
|
||||||
|
|
||||||
/* function pointers to actual implementation, set by ahrs_register_impl */
|
/* function pointers to actual implementation, set by ahrs_register_impl */
|
||||||
AhrsInit init;
|
AhrsInit init;
|
||||||
AhrsUpdateGps update_gps;
|
AhrsUpdateGps update_gps;
|
||||||
|
|||||||
Reference in New Issue
Block a user