BitbotEncos
Bitbot Encos is a bitbot instance for encos motor.
载入中...
搜索中...
未找到
yesense_imu.h
浏览该文件的文档.
1
10#pragma once
11
12#include "atomic"
13#include "yesense_sdk/analysis_data.h"
14#include "Encos_device.hpp"
15#include <fstream>
16#include <termios.h>
17#include <array>
18
19namespace bitbot
20{
21 class EncosBus;
22
28 {
30 std::atomic<float> roll = 0;
31
33 std::atomic<float> pitch = 0;
34
36 std::atomic<float> yaw = 0;
37
39 std::atomic<float> a_x = 0;
40
42 std::atomic<float> a_y = 0;
43
45 std::atomic<float> a_z = 0;
46
48 std::atomic<float> w_x = 0;
49
51 std::atomic<float> w_y = 0;
52
54 std::atomic<float> w_z = 0;
55
57 std::atomic<float> IMU_temp = 0;
58 };
59
64 struct ImuData
65 {
68 };
69
77 {
78 friend class EncosBus;
79
80 public:
86 YesenseIMU(const pugi::xml_node& imu_node);
87
92 virtual ~YesenseIMU();
93
99 float GetRoll();
100
106 float GetPitch();
107
113 float GetYaw();
114
120 float GetAccX();
121
127 float GetAccY();
128
134 float GetAccZ();
135
141 float GetGyroX();
142
148 float GetGyroY();
149
155 float GetGyroZ();
156
163
164 private:
165 void UpdateRuntimeData() override;
166 void UpdateImuDataFromBus();
167 void ReadOnce(); // call this function in the bus loop
168 void WriteOnce() {};
169
170 std::array<float, 3> cvtEuler(const float* quat);
171
172 private:
173 ImuData imu_data_;
174
175 constexpr static int RX_BUF_LEN = 1024;
176 unsigned char g_recv_buf[RX_BUF_LEN * 2] = { 0 };
177 unsigned short g_recv_buf_idx = 0;
178 protocol_info_t g_output_info = { 0 };
179
180 int fd;
181 int nread;
182 char buffer[RX_BUF_LEN];
183 std::string dev;
184 struct termios newtio;
185 unsigned short cnt = 0;
186 int pos = 0;
187 speed_t speed = B921600;
188
189 constexpr static float r2d = 180.0f / M_PI;
190 constexpr static float d2r = M_PI / 180.0f;
191 };
192}
Bitbot Encos device header file
Encos_VirtualBusDevice(const pugi::xml_node &device_node)
构造函数
定义 Encos_device.hpp:186
Bitbot Encos总线类,继承自BusManagerTpl,该类型仅适用于开发者使用,用户无需关心其实现细节。
定义 Encos_bus.h:29
virtual ~YesenseIMU()
析构IMU对象,该对象由Bitbot Encos内核创建。用户无需关心该对象的析构过程。
float GetAccZ()
获取IMU z轴加速度
float GetGyroY()
获取IMU y轴角速度
float GetGyroX()
获取IMU x轴角速度
float GetPitch()
获取IMU俯仰角度
float GetGyroZ()
获取IMU z轴角速度
YesenseIMU(const pugi::xml_node &imu_node)
构造IMU对象,该对象由Bitbot Encos内核创建。用户无需关心该对象的创建过程。
float GetRoll()
获取IMU滚转角度
float GetIMUTemperature()
获取IMU温度
float GetAccX()
获取IMU x轴加速度
float GetYaw()
获取IMU偏航角度
float GetAccY()
获取IMU y轴加速度
IMU数据结构体
定义 yesense_imu.h:65
ImuRuntimeData runtime
IMU当前姿态数据
定义 yesense_imu.h:67
IMU运行时数据结构体
定义 yesense_imu.h:28
std::atomic< float > IMU_temp
IMU当前温度(°C)
定义 yesense_imu.h:57
std::atomic< float > w_y
IMU当前y轴角速度(rad/s)
定义 yesense_imu.h:51
std::atomic< float > a_x
IMU当前x轴加速度(m/s^2)
定义 yesense_imu.h:39
std::atomic< float > roll
IMU当前滚转角度(rad)
定义 yesense_imu.h:30
std::atomic< float > pitch
IMU当前俯仰角度(rad)
定义 yesense_imu.h:33
std::atomic< float > a_y
IMU当前y轴加速度(m/s^2)
定义 yesense_imu.h:42
std::atomic< float > w_z
IMU当前z轴角速度(rad/s)
定义 yesense_imu.h:54
std::atomic< float > yaw
IMU当前偏航角度(rad)
定义 yesense_imu.h:36
std::atomic< float > a_z
IMU当前z轴加速度(m/s^2)
定义 yesense_imu.h:45
std::atomic< float > w_x
IMU当前x轴角速度(rad/s)
定义 yesense_imu.h:48