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_Beacon/AP_Beacon_Marvelmind.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/*15Original C Code by Marvelmind (https://github.com/MarvelmindRobotics/marvelmind.c)16Adapted into Ardupilot by Karthik Desai, Amilcar Lucas17April 201718*/1920#pragma once2122#include "AP_Beacon_Backend.h"2324#if AP_BEACON_MARVELMIND_ENABLED2526#define AP_BEACON_MARVELMIND_BUF_SIZE 2552728class AP_Beacon_Marvelmind : public AP_Beacon_Backend29{30public:3132// constructor33using AP_Beacon_Backend::AP_Beacon_Backend;3435// return true if sensor is basically healthy (we are receiving data)36bool healthy() override;3738// update39void update() override;4041private:42// Variables for Marvelmind43struct PositionValue44{45uint8_t address;46uint32_t timestamp;47int32_t x__mm, y__mm, z__mm;48bool high_resolution;49};5051struct StationaryBeaconPosition52{53uint8_t address;54int32_t x__mm, y__mm, z__mm;55bool high_resolution;56float distance__m; // Distance between beacon and hedge57};5859struct StationaryBeaconsPositions60{61uint8_t num_beacons;62StationaryBeaconPosition beacons[AP_BEACON_MAX_BEACONS];63bool updated;64};6566struct MarvelmindHedge67{68StationaryBeaconsPositions positions_beacons;69PositionValue cur_position;70bool _have_new_values;71};7273enum {74RECV_HDR,75RECV_DGRAM76} parse_state = RECV_HDR; // current state of receive data7778MarvelmindHedge hedge;79uint8_t input_buffer[AP_BEACON_MARVELMIND_BUF_SIZE];80uint16_t num_bytes_in_block_received;81uint16_t data_id;8283StationaryBeaconPosition* get_or_alloc_beacon(uint8_t address);84void process_beacons_positions_datagram();85void process_beacons_positions_highres_datagram();86void process_position_highres_datagram();87void process_position_datagram();88void process_beacons_distances_datagram();89void set_stationary_beacons_positions();90void order_stationary_beacons();91int8_t find_beacon_instance(uint8_t address) const;9293// Variables for Ardupilot94uint32_t last_update_ms;9596// cache the vehicle position in NED coordinates [m]97Vector3f vehicle_position_NED__m;98bool vehicle_position_initialized;99100// cache the beacon positions in NED coordinates [m]101Vector3f beacon_position_NED__m[AP_BEACON_MAX_BEACONS];102bool beacon_position_initialized;103};104105#endif // AP_BEACON_MARVELMIND_ENABLED106107108