mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 01:53:34 +08:00
uavcan: esc: fix uavcan ESC control
This fixes a number of issues with uavcan ESC control. - Motor Testing when using a CANnode as a PWM expander now works by allowing the FunctionMotors class to perform prearm control - The esc.RawCommand message is now always published for configured uavcan ESC outputs. Previously prior to arming the message would be published empty, which causes certain ESCs to enter an error state. - Useless and redundant code has been removed and small name changes have been applied.
This commit is contained in:
@@ -80,9 +80,7 @@ public:
|
||||
private:
|
||||
void callback(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::RawCommand> &msg)
|
||||
{
|
||||
|
||||
actuator_motors_s actuator_motors;
|
||||
|
||||
actuator_motors_s actuator_motors = {};
|
||||
actuator_motors.timestamp = hrt_absolute_time();
|
||||
actuator_motors.timestamp_sample = actuator_motors.timestamp;
|
||||
|
||||
@@ -91,13 +89,18 @@ private:
|
||||
break;
|
||||
}
|
||||
|
||||
// Normalized to -8192, 8191 in uavcan. actuator_motors is -1 to 1
|
||||
actuator_motors.control[i] = msg.cmd[i] / 8192.f;
|
||||
// Treat zero as disarmed value
|
||||
if (msg.cmd[i] == 0) {
|
||||
// NAN maps to disarmed
|
||||
actuator_motors.control[i] = NAN;
|
||||
|
||||
} else {
|
||||
// Normalized to -8192, 8191 in uavcan. actuator_motors is -1 to 1
|
||||
actuator_motors.control[i] = msg.cmd[i] / 8192.f;
|
||||
}
|
||||
}
|
||||
|
||||
_actuator_motors_pub.publish(actuator_motors);
|
||||
|
||||
}
|
||||
|
||||
uORB::Publication<actuator_motors_s> _actuator_motors_pub{ORB_ID(actuator_motors)};
|
||||
|
||||
Reference in New Issue
Block a user