62 using key_type = std::string;
71 std::chrono::steady_clock::duration control_time {};
72 inline const std::string& key()
const{
return name;}
78 inline std::string
desc()
const{
79 return std::format(
"Dji motor {}",info_.name);
93 bool supports_current_control()
const override {
return true; }
94 fp32 requested_current()
const override {
return enabled_ && target_fresh_since_enable_ && !
offline() ? current_ : 0.f; }
95 fp32 max_current()
const override {
return std::min(info_.pid_params.max_out,
command_current_limit(info_.type_)); }
96 fp32 target_angle_speed()
const override {
return mode_ == control_mode::linear ? pid_.target() / radius_ : pid_.target(); }
97 void set_output_scale(fp32 scale)
override { output_scale_ = scale; }
98 void set_current_limit(fp32 limit)
override { current_limit_ = limit; }
99 awaitable<void> task();
104 inline int16_t current()
const {
105 return motor_protocol::gated_current(current_, output_scale_, std::min(current_limit_, max_current()), enabled_ && target_fresh_since_enable_, !
offline());
108 std::pair<uint16_t,uint16_t> can_pkg_id()
const;
110 friend dji_motor_group;
112 enum class control_mode { linear, angular, current };
113 control_mode mode_ {control_mode::linear};
115 fp32 output_scale_ {1.f};
116 fp32 current_limit_ {std::numeric_limits<fp32>::infinity()};
117 fp32 reduction_ratio_ {1.0f};
119 bool connected_ {
false};
120 bool started_ {
false};
121 bool enabled_ {
false};
122 bool target_fresh_since_enable_ {
false};
123 std::chrono::steady_clock::time_point last_control_at_ {};