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_DAL/AP_DAL_InertialSensor.h
Views: 1798
#pragma once12#include <AP_InertialSensor/AP_InertialSensor.h>34#include <AP_Logger/LogStructure.h>56class AP_DAL_InertialSensor {7public:89// InertialSensor-like methods:1011// return the selected loop rate at which samples are made available12uint16_t get_loop_rate_hz(void) const { return _RISH.loop_rate_hz; }1314const Vector3f &get_imu_pos_offset(uint8_t instance) const {15return pos[instance];16}1718// accel stuff19uint8_t get_accel_count(void) const { return _RISH.accel_count; }20uint8_t get_first_usable_accel(void) const { return _RISH.first_usable_accel; };2122bool use_accel(uint8_t instance) const { return _RISI[instance].use_accel; }23const Vector3f &get_accel(uint8_t i) const { return accel_filtered[i]; }24bool get_delta_velocity(uint8_t i, Vector3f &delta_velocity, float &delta_velocity_dt) const {25delta_velocity = _RISI[i].delta_velocity;26delta_velocity_dt = _RISI[i].delta_velocity_dt;27return _RISI[i].get_delta_velocity_ret;28}2930// gyro stuff31uint8_t get_gyro_count(void) const { return _RISH.gyro_count; }32uint8_t get_first_usable_gyro(void) const { return _RISH.first_usable_gyro; };3334bool use_gyro(uint8_t instance) const { return _RISI[instance].use_gyro; }35const Vector3f &get_gyro(uint8_t i) const { return gyro_filtered[i]; }36const Vector3f &get_gyro() const { return get_gyro(_primary_gyro); }37bool get_delta_angle(uint8_t i, Vector3f &delta_angle, float &delta_angle_dt) const {38delta_angle = _RISI[i].delta_angle;39delta_angle_dt = _RISI[i].delta_angle_dt;40return _RISI[i].get_delta_angle_ret;41}4243// return the main loop delta_t in seconds44float get_loop_delta_t(void) const { return _RISH.loop_delta_t; }4546// AP_DAL methods:47AP_DAL_InertialSensor();4849void start_frame();5051void handle_message(const log_RISH &msg) {52_RISH = msg;53}54void handle_message(const log_RISI &msg) {55_RISI[msg.instance] = msg;56pos[msg.instance] = AP::ins().get_imu_pos_offset(msg.instance);57update_filtered(msg.instance);58}5960private:61struct log_RISH _RISH;62struct log_RISI _RISI[INS_MAX_INSTANCES];63float alpha;6465// sensor positions66Vector3f pos[INS_MAX_INSTANCES];6768Vector3f gyro_filtered[INS_MAX_INSTANCES];69Vector3f accel_filtered[INS_MAX_INSTANCES];7071uint8_t _primary_gyro;7273void update_filtered(uint8_t i);74};757677