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_AccelCal/AP_AccelCal.h
Views: 1798
#pragma once12#include <AP_HAL/AP_HAL_Boards.h>3#include <GCS_MAVLink/GCS_config.h>45#ifndef HAL_INS_ACCELCAL_ENABLED6#if HAL_GCS_ENABLED7#include <AP_InertialSensor/AP_InertialSensor_config.h>8#define HAL_INS_ACCELCAL_ENABLED AP_INERTIALSENSOR_ENABLED9#else10#define HAL_INS_ACCELCAL_ENABLED 011#endif12#endif1314#include <GCS_MAVLink/GCS_MAVLink.h>15#include "AccelCalibrator.h"1617#define AP_ACCELCAL_MAX_NUM_CLIENTS 418class GCS_MAVLINK;19class AP_AccelCal_Client;2021class AP_AccelCal {22public:23AP_AccelCal():24_use_gcs_snoop(true),25_started(false),26_saving(false)27{ update_status(); }2829// start all the registered calibrations30void start(GCS_MAVLINK *gcs);3132// called on calibration cancellation33void cancel();3435// Run an iteration of all registered calibrations36void update();3738// get the status of the calibrator server as a whole39accel_cal_status_t get_status() { return _status; }4041// Set vehicle position sent by the GCS42bool gcs_vehicle_position(float position);4344// interface to the clients for registration45static void register_client(AP_AccelCal_Client* client);4647#if HAL_GCS_ENABLED48void handle_command_ack(const mavlink_command_ack_t &packet);49#endif5051// true if we are in a calibration process52bool running(void) const;5354private:55class GCS_MAVLINK *_gcs;56bool _use_gcs_snoop;57bool _waiting_for_mavlink_ack = false;58uint32_t _last_position_request_ms;59uint8_t _step;60accel_cal_status_t _status;61accel_cal_status_t _last_result;6263static uint8_t _num_clients;64static AP_AccelCal_Client* _clients[AP_ACCELCAL_MAX_NUM_CLIENTS];6566// called on calibration success67void success();6869// called on calibration failure70void fail();7172// reset all the calibrators to there pre calibration stage so as to make them ready for next calibration request73void clear();7475// proceed through the collection step for each of the registered calibrators76void collect_sample();7778// update the state of the Accel calibrator server79void update_status();8081// checks if no new sample has been received for considerable amount of time82bool check_for_timeout();8384// check if client's calibrator is active85bool client_active(uint8_t client_num);8687bool _started;88bool _saving;8990uint8_t _num_active_calibrators;9192AccelCalibrator* get_calibrator(uint8_t i);93};9495class AP_AccelCal_Client {96friend class AP_AccelCal;97private:98// getters99virtual bool _acal_get_saving() { return false; }100virtual bool _acal_get_ready_to_sample() { return true; }101virtual bool _acal_get_fail() { return false; }102virtual AccelCalibrator* _acal_get_calibrator(uint8_t instance) = 0;103104// events105virtual void _acal_save_calibrations() = 0;106virtual void _acal_event_success() {};107virtual void _acal_event_cancellation() {};108virtual void _acal_event_failure() {};109};110111112