Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : This program is distributed in the hope that it will be useful, 7 : but WITHOUT ANY WARRANTY; without even the implied warranty of 8 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 : GNU General Public License for more details. 10 : You should have received a copy of the GNU General Public License 11 : along with this program. If not, see <http://www.gnu.org/licenses/>. 12 : */ 13 : /* 14 : support for MicroStrain CX5/GX5-45 serially connected AHRS Systems 15 : */ 16 : 17 : #pragma once 18 : 19 : #include "AP_ExternalAHRS_config.h" 20 : 21 : #if AP_EXTERNAL_AHRS_MICROSTRAIN5_ENABLED 22 : 23 : #include "AP_ExternalAHRS_backend.h" 24 : #include <AP_GPS/AP_GPS.h> 25 : #include <AP_HAL/AP_HAL.h> 26 : #include "MicroStrain_common.h" 27 : 28 : class AP_ExternalAHRS_MicroStrain5: public AP_ExternalAHRS_backend, public AP_MicroStrain 29 : { 30 : public: 31 : 32 : AP_ExternalAHRS_MicroStrain5(AP_ExternalAHRS *frontend, AP_ExternalAHRS::state_t &state); 33 : 34 : // get serial port number, -1 for not enabled 35 : int8_t get_port(void) const override; 36 : 37 : // Get model/type name 38 : const char* get_name() const override; 39 : 40 : // accessors for AP_AHRS 41 : bool healthy(void) const override; 42 : bool initialised(void) const override; 43 : bool pre_arm_check(char *failure_msg, uint8_t failure_msg_len) const override; 44 : void get_filter_status(nav_filter_status &status) const override; 45 : bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const override; 46 : 47 : // check for new data 48 184394 : void update() override { 49 184394 : build_packet(); 50 184394 : }; 51 : 52 : protected: 53 : 54 50 : uint8_t num_gps_sensors(void) const override { 55 50 : return 1; 56 : } 57 : 58 : private: 59 : 60 : uint32_t baudrate; 61 : int8_t port_num; 62 : bool port_open = false; 63 : 64 : 65 : 66 : void build_packet(); 67 : 68 : void post_imu() const; 69 : void post_gnss() const; 70 : void post_filter() const; 71 : 72 : void update_thread(); 73 : 74 : AP_HAL::UARTDriver *uart; 75 : HAL_Semaphore sem; 76 : 77 : }; 78 : 79 : #endif // AP_EXTERNAL_AHRS_MICROSTRAIN5_ENABLED