AP_UAVCAN: support sending pulses as PWM for DroneCAN actuators

This commit is contained in:
Andrew Tridgell 2022-09-12 13:31:04 +10:00
parent 31cac4395f
commit 0d082043ba
2 changed files with 8 additions and 5 deletions

View File

@ -528,11 +528,13 @@ void AP_UAVCAN::SRV_send_actuator(void)
if (_SRV_conf[starting_servo].servo_pending && ((((uint32_t) 1) << starting_servo) & _servo_bm)) { if (_SRV_conf[starting_servo].servo_pending && ((((uint32_t) 1) << starting_servo) & _servo_bm)) {
cmd.actuator_id = starting_servo + 1; cmd.actuator_id = starting_servo + 1;
// TODO: other types if (option_is_set(Options::USE_ACTUATOR_PWM)) {
cmd.command_type = uavcan::equipment::actuator::Command::COMMAND_TYPE_UNITLESS; cmd.command_type = uavcan::equipment::actuator::Command::COMMAND_TYPE_PWM;
cmd.command_value = _SRV_conf[starting_servo].pulse;
// TODO: failsafe, safety } else {
cmd.command_value = constrain_float(((float) _SRV_conf[starting_servo].pulse - 1000.0) / 500.0 - 1.0, -1.0, 1.0); cmd.command_type = uavcan::equipment::actuator::Command::COMMAND_TYPE_UNITLESS;
cmd.command_value = constrain_float(((float) _SRV_conf[starting_servo].pulse - 1000.0) / 500.0 - 1.0, -1.0, 1.0);
}
msg.commands.push_back(cmd); msg.commands.push_back(cmd);

View File

@ -203,6 +203,7 @@ public:
DNA_IGNORE_DUPLICATE_NODE = (1U<<1), DNA_IGNORE_DUPLICATE_NODE = (1U<<1),
CANFD_ENABLED = (1U<<2), CANFD_ENABLED = (1U<<2),
DNA_IGNORE_UNHEALTHY_NODE = (1U<<3), DNA_IGNORE_UNHEALTHY_NODE = (1U<<3),
USE_ACTUATOR_PWM = (1U<<4),
}; };
// check if a option is set // check if a option is set