Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_ExternalAHRS: added ANU CINS state estimator #24747

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Aug 24, 2023

This is the ANU CINS estimator worked on by @patwilt and @pvangoor
This is still experimental but is giving promising results in test flights

remaining issues:

  • using std::queue, should use ArduPilot queue APIs
  • should support baro for height for handling GPS outage
  • add option to not use compass

@tridge tridge added the WIP label Aug 24, 2023
@tridge tridge force-pushed the pr-AHRS_CINS branch 2 times, most recently from 451699b to 6dbce7b Compare November 24, 2023 03:36
@tridge tridge force-pushed the pr-AHRS_CINS branch 3 times, most recently from c9e1e57 to 0b2dc4e Compare May 10, 2024 08:25
@tridge tridge changed the title AP_ExternalAHRS: added ANU CINS state estimator (WIP) AP_ExternalAHRS: added ANU CINS state estimator Sep 11, 2024
@tridge tridge removed the WIP label Sep 11, 2024
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stack-frame-too-big on CubeOrange

libraries/AP_CINS/AP_CINS.h Outdated Show resolved Hide resolved
@@ -0,0 +1,173 @@
#include "AP_Math.h"
#include "LieGroups.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links to papers required!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we upload them to the repo so if hosting goes down, we still have access?

libraries/AP_Math/LieGroups.h Outdated Show resolved Hide resolved
libraries/AP_Math/matrix3.cpp Outdated Show resolved Hide resolved
libraries/AP_Math/matrix3.cpp Outdated Show resolved Hide resolved
@tridge
Copy link
Contributor Author

tridge commented Oct 30, 2024

@peterbarker stack size issues fixed

@tridge tridge force-pushed the pr-AHRS_CINS branch 2 times, most recently from aba5014 to 38a09b8 Compare October 31, 2024 22:30
Comment on lines +192 to +193
state.XHat = Gal3F::identity();
state.ZHat = SIM23::identity();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we'd do state.XHat.identity()

Comment on lines +201 to +203
state.acc_bias_gain_mat.rot.zero();
state.acc_bias_gain_mat.vel.zero();
state.acc_bias_gain_mat.pos.zero();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all implicitly zero; if this was a reset we'd need these.

// see if we have new GPS data
const auto &gps = dal.gps();
if (gps.status() >= AP_DAL_GPS::GPS_OK_FIX_3D) {
const uint32_t last_gps_fix_ms = gps.last_message_time_ms(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mismatch between this and the gps.location() line

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should run this through the code formatter before putting it in.

@@ -167,6 +167,12 @@ def srcpath(path):
disable_option = "disable_" + enable_option[len("enable-"):]
if getattr(cfg.options, enable_option, False):
env.CXXFLAGS += ['-D%s=1' % opt.define]
if opt.dependency:
for d in opt.dependency.split(','):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lift method from build_options.py?

Feature('AHRS', 'EKF3_WINDEST', 'EK3_FEATURE_DRAG_FUSION', 'Enable Wind estimation for EKF3', 0, 'EKF3'),
Feature('AHRS', 'EKF3_OPTFLOW', 'EK3_FEATURE_OPTFLOW_FUSION', 'Enable OpticalFlow fusion for EKF3', 0, 'EKF3,OPTICALFLOW'),
Feature('AHRS', 'BARO_WIND_COMP', 'HAL_BARO_WIND_COMP_ENABLED', 'Enable Baro wind compensation', 0, None),
Feature('AHRS', 'EKF3_EXTNAV', 'EK3_FEATURE_EXTERNAL_NAV', 'Enable External Navigation for EKF3', 0, 'EKF3'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case problems

@@ -0,0 +1,801 @@
/*
CINS state estimator for AP_AHRS, developed by Mr Patrick Wiltshire and Dr Pieter Van Goor
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright/license required?

CINS state estimator for AP_AHRS, developed by Mr Patrick Wiltshire and Dr Pieter Van Goor
*/

#include "AP_CINS.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "AP_CINS.h"
#include "AP_CINS_config.h"

#include <GCS_MAVLink/GCS.h>

// gains tested for 5Hz GPS
#define CINS_GAIN_GPSPOS_ATT (1.0E-5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just inline these into the parameter definitions?

// The key point is that Omega changes R which changes Omega.
// We use a first order expansion to capture this effect here.

const Vector3F omega1 = - Matrix3F::skew_symmetric(v1) * v2 * gain;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Vector3F omega1 = - Matrix3F::skew_symmetric(v1) * v2 * gain;
const auto skewed_v1 = Matrix3F::skew_symmetric(v1);
const Vector3F omega1 = - skewed_v1 * v2 * gain;

and use this elsewhere.

similarly for skewed omega1

const Vector3F omega2 = - Matrix3F::skew_symmetric(v1) * Matrix3F::skew_symmetric(omega1) * v2 * gain;
const Vector3F omega3 = - Matrix3F::skew_symmetric(v1) * Matrix3F::skew_symmetric(omega2) * v2 * gain
- Matrix3F::skew_symmetric(v1) * Matrix3F::skew_symmetric(omega1) * Matrix3F::skew_symmetric(omega1) * v2 * gain;
return omega1 + omega2*dt + omega3*0.5*dt*dt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return omega1 + omega2*dt + omega3*0.5*dt*dt;
return omega1 + omega2*dt + omega3*0.5*sq(dt);

ftype magTest;
} variances;

} state;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we have a state structure


// accessors for AP_AHRS
bool healthy(void) const override {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do better than this?!

return true;
}
bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const override {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we have never had a GPS measurement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants