Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_ExternalAHRS/AP_ExternalAHRS_MicroStrain7.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.5This program is distributed in the hope that it will be useful,6but WITHOUT ANY WARRANTY; without even the implied warranty of7MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8GNU General Public License for more details.9You should have received a copy of the GNU General Public License10along with this program. If not, see <http://www.gnu.org/licenses/>.11*/12/*13support for MicroStrain GQ7 serially connected AHRS Systems14*/1516#pragma once1718#include "AP_ExternalAHRS_config.h"1920#if AP_EXTERNAL_AHRS_MICROSTRAIN7_ENABLED2122#include "AP_ExternalAHRS_backend.h"23#include <AP_GPS/AP_GPS.h>24#include <AP_HAL/AP_HAL.h>25#include "MicroStrain_common.h"2627class AP_ExternalAHRS_MicroStrain7: public AP_ExternalAHRS_backend, public AP_MicroStrain28{29public:3031AP_ExternalAHRS_MicroStrain7(AP_ExternalAHRS *frontend, AP_ExternalAHRS::state_t &state);3233// get serial port number, -1 for not enabled34int8_t get_port(void) const override;3536// Get model/type name37const char* get_name() const override;3839// accessors for AP_AHRS40bool healthy(void) const override;41bool initialised(void) const override;42bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const override;43void get_filter_status(nav_filter_status &status) const override;44bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const override;4546// check for new data47void update() override48{49build_packet();50};5152protected:5354uint8_t num_gps_sensors(void) const override55{56return AP_MicroStrain::NUM_GNSS_INSTANCES;57}5859private:6061// GQ7 Filter States62// https://s3.amazonaws.com/files.microstrain.com/GQ7+User+Manual/external_content/dcp/Data/filter_data/data/mip_field_filter_status.htm63enum class FilterState {64GQ7_INIT = 0x01,65GQ7_VERT_GYRO = 0x02,66GQ7_AHRS = 0x03,67GQ7_FULL_NAV = 0x0468};6970uint32_t baudrate;71int8_t port_num;72bool port_open = false;73747576void build_packet();7778void post_imu() const;79void post_gnss() const;80void post_filter() const;8182void update_thread();83void check_initialise_state();8485// Returns true when data is not stale.86bool times_healthy() const;8788// Returns true when the filter is currently healthy.89bool filter_healthy() const;9091// Only some of the fix types satisfy a healthy filter.92// GQ7_VERT_GYRO is NOT considered healthy for now.93// This may be vehicle-dependent in the future.94static bool filter_state_healthy(FilterState state) WARN_IF_UNUSED;9596AP_HAL::UARTDriver *uart;97HAL_Semaphore sem;9899// Used to monitor initialization state.100bool last_init_state = false;101102};103104#endif // AP_EXTERNAL_AHRS_MICROSTRAIN7_ENABLED105106107