11 using key_type = std::string;
16 uint16_t master_id {0};
19 fp32 max_speed {45.f};
21 std::chrono::steady_clock::duration control_time {std::chrono::milliseconds{1}};
22 std::chrono::steady_clock::duration offline_timeout {std::chrono::milliseconds{100}};
23 const std::string& key()
const {
return name; }
26 static bool valid_configuration(
const info_type& info) {
27 return !info.name.empty() && !info.can_name.empty() && info.id >= 1 && info.id <= 15
28 && info.master_id <= 0x7ff && std::isfinite(info.radius) && info.radius > 0.f
29 && motor_protocol::valid_ranges(info.feedback_range)
30 && std::isfinite(info.max_speed) && info.max_speed > 0.f
31 && info.max_speed <= info.feedback_range.velocity_max
32 && (info.direction == 1 || info.direction == -1)
33 && info.control_time > std::chrono::steady_clock::duration::zero()
34 && info.offline_timeout >= info.control_time;
36 explicit j6006(
const info_type& info);
39 std::string desc()
const {
return std::format(
"J6006 motor {} on {}", info_.name, info_.can_name); }
47 fp32 target_angle_speed()
const override {
return target_speed_; }
48 uint16_t encoder_raw()
const {
return encoder_raw_; }
49 uint8_t status()
const {
return status_; }
50 bool faulted()
const override {
return fault_latched_ || (status_ >= 8 && status_ <= 14); }
51 fp32 command_speed()
const {
52 return motor_protocol::gated_j6006_velocity(target_speed_, enabled_ && !fault_latched_, !
offline(), status_);
54 fp32 current_feedback_raw()
const override {
return 0.f; }
58 fp32 target_speed_ {0.f};
59 uint16_t encoder_raw_ {0};
60 uint8_t status_ {0xff};
61 bool connected_ {
false};
62 bool started_ {
false};
63 bool enabled_ {
false};
64 bool previous_enabled_ {
false};
65 bool fault_latched_ {
false};