2012-11-05 00:31:02 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2012-11-07 09:24:00 -04:00
|
|
|
#ifndef __AP_INERTIALNAV_H__
|
|
|
|
#define __AP_INERTIALNAV_H__
|
2012-11-05 00:31:02 -04:00
|
|
|
|
|
|
|
#include <AP_AHRS.h>
|
|
|
|
#include <AP_InertialSensor.h> // ArduPilot Mega IMU Library
|
|
|
|
#include <AP_Baro.h> // ArduPilot Mega Barometer Library
|
2012-12-09 11:43:11 -04:00
|
|
|
#include <AP_Buffer.h> // FIFO buffer library
|
2015-02-08 22:09:02 -04:00
|
|
|
#include "../AP_NavEKF/AP_Nav_Common.h" // definitions shared by inertial and ekf nav filters
|
2012-11-05 00:31:02 -04:00
|
|
|
|
|
|
|
/*
|
2013-10-25 10:55:31 -03:00
|
|
|
* AP_InertialNav blends accelerometer data with gps and barometer data to improve altitude and position hold.
|
|
|
|
*
|
|
|
|
* Most of the functions have to be called at 100Hz. (see defines above)
|
|
|
|
*
|
|
|
|
* The accelerometer values are integrated over time to approximate velocity and position.
|
|
|
|
* The inaccurcy of these estimates grows over time due to noisy sensor data.
|
|
|
|
* To improve the accuracy, baro and gps readings are used:
|
|
|
|
* An error value is calculated as the difference between the sensor's measurement and the last position estimation.
|
|
|
|
* This value is weighted with a gain factor and incorporated into the new estimation
|
2014-08-31 01:23:03 -03:00
|
|
|
*
|
|
|
|
* Special thanks to Tony Lambregts (FAA) for advice which contributed to the development of this filter.
|
|
|
|
*
|
2012-11-05 00:31:02 -04:00
|
|
|
*/
|
2012-11-07 09:24:00 -04:00
|
|
|
class AP_InertialNav
|
2012-11-05 00:31:02 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
2015-03-12 23:02:01 -03:00
|
|
|
AP_InertialNav() {}
|
2012-11-05 00:31:02 -04:00
|
|
|
|
2013-10-25 10:55:31 -03:00
|
|
|
/**
|
|
|
|
* update - updates velocity and position estimates using latest info from accelerometers
|
|
|
|
* augmented with gps and baro readings
|
|
|
|
*
|
|
|
|
* @param dt : time since last update in seconds
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual void update(float dt) = 0;
|
2012-11-05 00:31:02 -04:00
|
|
|
|
2015-01-02 04:05:49 -04:00
|
|
|
/**
|
|
|
|
* get_filter_status : returns filter status as a series of flags
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual nav_filter_status get_filter_status() const = 0;
|
2015-01-02 04:05:49 -04:00
|
|
|
|
2015-02-02 22:11:48 -04:00
|
|
|
/**
|
|
|
|
* get_origin - returns the inertial navigation origin in lat/lon/alt
|
|
|
|
*
|
|
|
|
* @return origin Location
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual struct Location get_origin() const = 0;
|
2015-02-02 22:11:48 -04:00
|
|
|
|
2012-12-09 11:43:11 -04:00
|
|
|
//
|
|
|
|
// XY Axis specific methods
|
|
|
|
//
|
2012-11-05 00:31:02 -04:00
|
|
|
|
2013-10-25 10:55:31 -03:00
|
|
|
/**
|
|
|
|
* get_position - returns the current position relative to the home location in cm.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual const Vector3f& get_position() const = 0;
|
2013-10-25 10:55:31 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get_latitude - returns the latitude of the current position estimation in 100 nano degrees (i.e. degree value multiplied by 10,000,000)
|
|
|
|
* @return
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual int32_t get_latitude() const = 0;
|
2013-10-25 10:55:31 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get_longitude - returns the longitude of the current position estimation in 100 nano degrees (i.e. degree value multiplied by 10,000,000)
|
|
|
|
* @return
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual int32_t get_longitude() const = 0;
|
2013-03-27 02:09:04 -03:00
|
|
|
|
2013-10-25 10:55:31 -03:00
|
|
|
/**
|
|
|
|
* get_velocity - returns the current velocity in cm/s
|
|
|
|
*
|
|
|
|
* @return velocity vector:
|
|
|
|
* .x : latitude velocity in cm/s
|
|
|
|
* .y : longitude velocity in cm/s
|
|
|
|
* .z : vertical velocity in cm/s
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual const Vector3f& get_velocity() const = 0;
|
2013-10-25 10:55:31 -03:00
|
|
|
|
2013-10-29 01:25:14 -03:00
|
|
|
/**
|
|
|
|
* get_velocity_xy - returns the current horizontal velocity in cm/s
|
|
|
|
*
|
|
|
|
* @returns the current horizontal velocity in cm/s
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual float get_velocity_xy() const = 0;
|
2014-01-03 07:41:03 -04:00
|
|
|
|
2012-12-09 11:43:11 -04:00
|
|
|
//
|
|
|
|
// Z Axis methods
|
|
|
|
//
|
2012-11-05 00:31:02 -04:00
|
|
|
|
2013-10-25 10:55:31 -03:00
|
|
|
/**
|
2014-01-03 20:16:07 -04:00
|
|
|
* get_altitude - get latest altitude estimate in cm above the
|
|
|
|
* reference position
|
2013-10-25 10:55:31 -03:00
|
|
|
* @return
|
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual float get_altitude() const = 0;
|
2012-12-09 11:43:11 -04:00
|
|
|
|
2013-10-25 10:55:31 -03:00
|
|
|
/**
|
|
|
|
* get_velocity_z - returns the current climbrate.
|
|
|
|
*
|
|
|
|
* @see get_velocity().z
|
|
|
|
*
|
2014-01-03 20:16:07 -04:00
|
|
|
* @return climbrate in cm/s (positive up)
|
2013-10-25 10:55:31 -03:00
|
|
|
*/
|
2015-03-12 10:21:08 -03:00
|
|
|
virtual float get_velocity_z() const = 0;
|
2012-11-05 00:31:02 -04:00
|
|
|
};
|
|
|
|
|
2014-01-03 07:57:50 -04:00
|
|
|
#if AP_AHRS_NAVEKF_AVAILABLE
|
|
|
|
#include "AP_InertialNav_NavEKF.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-07 09:24:00 -04:00
|
|
|
#endif // __AP_INERTIALNAV_H__
|