GKD.RoboCtrl
RoboMaster Linux 电控:异步 IO、设备驱动与机器人控制
载入中...
搜索中...
未找到
feedback.hpp
1#pragma once
2#include <cmath>
3#include "device/imu/base.hpp"
4
5namespace roboctrl::device {
8 return std::cos(pitch) * gyro.z - std::sin(pitch) * gyro.x;
9}
10
13public:
14 bool update(bool enabled, bool online, fp32 yaw_error, fp32 pitch_error,
15 fp32 tolerance, fp32 settle_seconds, fp32 dt) {
16 const bool within = enabled && online && std::isfinite(yaw_error) &&
17 std::isfinite(pitch_error) && std::abs(yaw_error) <= tolerance &&
18 std::abs(pitch_error) <= tolerance;
19 if (!within) elapsed_ = 0;
20 else if (dt > 0) elapsed_ += dt;
21 return within && elapsed_ >= settle_seconds;
22 }
23 void reset() { elapsed_ = 0; }
24private:
25 fp32 elapsed_{};
26};
27}
IMU 抽象基类。
fp32 compensated_yaw_rate(fp32 pitch, three_axis gyro)
Definition feedback.hpp:7
三轴物理量快照。
Definition base.hpp:17
float fp32
单精度浮点别名。
Definition utils.hpp:22