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_VectorNav.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.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/14/*15support for serial connected AHRS systems16*/1718#pragma once1920#include "AP_ExternalAHRS_config.h"2122#if AP_EXTERNAL_AHRS_VECTORNAV_ENABLED2324#include "AP_ExternalAHRS_backend.h"2526class AP_ExternalAHRS_VectorNav : public AP_ExternalAHRS_backend {2728public:29AP_ExternalAHRS_VectorNav(AP_ExternalAHRS *frontend, AP_ExternalAHRS::state_t &state);3031// get serial port number, -1 for not enabled32int8_t get_port(void) const override;3334// accessors for AP_AHRS35bool healthy(void) const override;36bool initialised(void) const override;37bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const override;38void get_filter_status(nav_filter_status &status) const override;39bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const override;4041// check for new data42void update() override {43check_uart();44}4546// Get model/type name47const char* get_name() const override;4849protected:5051uint8_t num_gps_sensors(void) const override {52return 1;53}54private:55AP_HAL::UARTDriver *uart;56int8_t port_num;57bool setup_complete;58uint32_t baudrate;5960void update_thread();61bool check_uart();6263void initialize();6465void run_command(const char *fmt, ...);6667struct VNAT;68void write_vnat(const VNAT& data_to_log) const;69void process_imu_packet(const uint8_t *b);70void process_ahrs_ekf_packet(const uint8_t *b);71void process_ins_ekf_packet(const uint8_t *b);72void process_ins_gnss_packet(const uint8_t *b);737475uint8_t *pktbuf;76uint16_t pktoffset;77uint16_t bufsize;7879struct VN_imu_packet *latest_imu_packet;80struct VN_INS_ekf_packet *latest_ins_ekf_packet;81struct VN_INS_gnss_packet *latest_ins_gnss_packet;8283uint32_t last_pkt1_ms;84uint32_t last_pkt2_ms;85uint32_t last_pkt3_ms;8687enum class TYPE {88VN_INS, // Full INS mode, requiring GNSS. Used by VN-2X0 and VN-3X089VN_AHRS, // IMU-only mode, used by VN-1X090} type;9192bool has_dual_gnss = false;9394char model_name[20];9596char message_to_send[50];97// NMEA parsing for setup98bool decode(char c);99bool decode_latest_term();100struct NMEA_parser {101char term[20]; // buffer for the current term within the current sentence102uint8_t term_offset; // offset within the _term buffer where the next character should be placed103uint8_t term_number; // term index within the current sentence104uint8_t checksum; // checksum accumulator105bool term_is_checksum; // current term is the checksum106bool sentence_valid; // is current sentence valid so far107bool sentence_done; // true if this sentence has already been decoded108bool error_response; // true if received a VNERR response109} nmea;110};111112#endif // AP_EXTERNAL_AHRS_VECTORNAV_ENABLED113114115