6#include "utils/ramp.hpp"
7#include "utils/singleton.hpp"
14namespace roboctrl::ctrl{
15using namespace std::chrono_literals;
29 float friction_max_speed {};
30 float trigger_speed {};
31 float friction_ready_speed {1.5f};
32 float jam_current {4000.0f};
33 float jam_speed {1.0f};
34 std::chrono::steady_clock::duration jam_release_time {50ms};
35 std::chrono::steady_clock::duration control_time {1ms};
36 std::string left_friction_motor {
"left_friction"};
37 std::string right_friction_motor {
"right_friction"};
38 std::string trigger_motor {
"trigger"};
39 bool enforce_referee {
false};
40 unsigned int bullet_caliber {17};
43 inline std::string desc()
const{
return "shoot";}
49 bool init(
const info_type& info);
57 void set_fire_permitted(
bool permitted) { fire_permitted_ = permitted; }
58 [[nodiscard]]
bool fire_allowed()
const;
62 inline bool firing()
const{
return firing_;}
65 inline bool friction_enabled()
const{
return friction_enabled_;}
73 bool enabled_ {
false};
74 bool fire_permitted_ {
false};
75 bool initialized_ {
false};
76 bool started_ {
false};
78 bool friction_enabled_ {
false};
79 std::chrono::steady_clock::time_point jam_release_at_ {};
80 device::motor_base* left_friction_motor_ {
nullptr};
81 device::motor_base* right_friction_motor_ {
nullptr};
82 device::motor_base* trigger_motor_ {
nullptr};
86static_assert(utils::singleton<shoot>);
bool friction_ready() const
判断摩擦轮是否达到可发射的准备速度。
void set_firing(bool state)
请求开始或停止拨弹。
roboctrl::awaitable< void > task()
周期更新摩擦轮和拨弹电机输出。
bool init(const info_type &info)
绑定发射器所需电机并初始化内部状态。
void set_friction_enabled(bool state)
请求启用或停止摩擦轮。
void set_enabled(bool enabled)
roboctrl::awaitable< void > update(fp32 dt)
用于提供日志功能的辅助基类 通过CRTP模式实现,要求派生类实现desc()方法以提供描述信息,在继承时传入派生类自身类型作为模板参数。 继承这个类后,派生类可以方便地使用log_debug、log_i...
asio::awaitable< T > awaitable
协程任务类型。
ramp< float > ramp_f
float 精度的 Ramp 控制器别名。