APM:Libraries
AP_Beacon_Marvelmind.h
Go to the documentation of this file.
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 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 /*
16  Original C Code by Marvelmind (https://github.com/MarvelmindRobotics/marvelmind.c)
17  Adapted into Ardupilot by Karthik Desai, Amilcar Lucas
18  April 2017
19  */
20 
21 #pragma once
22 
23 #include "AP_Beacon_Backend.h"
24 
25 #define AP_BEACON_MARVELMIND_BUF_SIZE 255
26 
28 {
29 public:
30 
31  // constructor
33 
34  // return true if sensor is basically healthy (we are receiving data)
35  bool healthy();
36 
37  // update
38  void update();
39 
40 private:
41  // Variables for Marvelmind
43  {
44  uint8_t address;
45  uint32_t timestamp;
46  int32_t x__mm, y__mm, z__mm;
48  };
49 
51  {
52  uint8_t address;
53  int32_t x__mm, y__mm, z__mm;
55  float distance__m; // Distance between beacon and hedge
56  };
57 
59  {
60  uint8_t num_beacons;
62  bool updated;
63  };
64 
66  {
70  };
71 
72  enum {
75  } parse_state; // current state of receive data
76 
80  uint16_t data_id;
81 
82  uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len);
91  int8_t find_beacon_instance(uint8_t address) const;
92 
93  // Variables for Ardupilot
95  uint32_t last_update_ms;
96 
97  // cache the vehicle position in NED coordinates [m]
100 
101  // cache the beacon positions in NED coordinates [m]
104 };
105 
uint8_t input_buffer[AP_BEACON_MARVELMIND_BUF_SIZE]
uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len)
static AP_SerialManager serial_manager
Definition: AHRS_Test.cpp:24
enum AP_Beacon_Marvelmind::@13 parse_state
AP_Beacon_Marvelmind(AP_Beacon &frontend, AP_SerialManager &serial_manager)
#define AP_BEACON_MAX_BEACONS
Definition: AP_Beacon.h:25
StationaryBeaconPosition * get_or_alloc_beacon(uint8_t address)
#define AP_BEACON_MARVELMIND_BUF_SIZE
Vector3f beacon_position_NED__m[AP_BEACON_MAX_BEACONS]
AP_HAL::UARTDriver * uart
StationaryBeaconsPositions positions_beacons
int8_t find_beacon_instance(uint8_t address) const