mirs_esp_pio
読み取り中…
検索中…
一致する文字列を見つけられません
RobotController.hpp
[詳解]
1
5
6#ifndef ROBOT_CONTROLLER_HPP
7#define ROBOT_CONTROLLER_HPP
8
9#include <stdint.h>
10
11namespace application {
12
15 float left = 0.0f;
16 float mode_switch = 0.0f;
17 float right = 0.0f;
18 bool left_valid = false;
19 bool mode_switch_valid = false;
20 bool right_valid = false;
21};
22
25public:
27 enum ControlMode : uint8_t {
30 };
31
40 double wheel_base,
41 float max_linear_speed,
42 float max_angular_speed,
43 uint32_t watchdog_timeout
44 );
45
50 void setWheelBase(double wheel_base);
51
56 ControlMode getControlMode() const { return control_mode_; }
57
63 void setControlMode(ControlMode mode) { control_mode_ = mode; }
64
73 void updateRos2Command(float linear_x, float angular_z, uint32_t stamp_ms);
74
85 void update(const RcControlInput &rc, uint32_t now_ms);
86
91 double getLeftVelCmd() const { return l_vel_cmd_; }
92
97 double getRightVelCmd() const { return r_vel_cmd_; }
98
99private:
100 double wheel_base_;
101 float max_linear_speed_;
102 float max_angular_speed_;
103 uint32_t watchdog_timeout_;
104
105 ControlMode control_mode_;
106 float linear_x_;
107 float angular_z_;
108 double l_vel_cmd_;
109 double r_vel_cmd_;
110 uint32_t last_ros2_cmd_time_;
111 bool prev_sw_high_;
112
117 void updateManualCommand(const RcControlInput &rc);
118
124 void updateRos2WheelCommands();
125
127 double clampWheelCmd(double vel_cmd) const;
128
136 bool checkWatchdog(uint32_t now_ms);
137};
138
139} // namespace application
140
141#endif // ROBOT_CONTROLLER_HPP
void setControlMode(ControlMode mode)
制御モードを設定
void update(const RcControlInput &rc, uint32_t now_ms)
RC入力とモード切替を処理して速度指令を更新
void updateRos2Command(float linear_x, float angular_z, uint32_t stamp_ms)
ROS2からの速度指令を更新
ControlMode getControlMode() const
制御モードを取得
double getRightVelCmd() const
右輪速度指令を取得
@ MODE_MANUAL
手動制御モード(RC入力)
RobotController(double wheel_base, float max_linear_speed, float max_angular_speed, uint32_t watchdog_timeout)
コンストラクタ
void setWheelBase(double wheel_base)
車輪間距離を設定
double getLeftVelCmd() const
左輪速度指令を取得
正規化済みRC入力と各チャンネルの有効状態。