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:
Jacob Dahl
2025-07-11 08:53:52 -06:00
committed by Alex Klimaj
parent 572a06b2f3
commit 6a1cefd7a6
7 changed files with 45 additions and 63 deletions
@@ -68,7 +68,11 @@ public:
float value(OutputFunction func) override { return _data.control[(int)func - (int)OutputFunction::Motor1]; }
#if defined(CONFIG_DRIVERS_UAVCANNODE)
bool allowPrearmControl() const override { return true; }
#else
bool allowPrearmControl() const override { return false; }
#endif
uORB::SubscriptionCallbackWorkItem *subscriptionCallback() override { return &_topic; }
+1 -3
View File
@@ -541,8 +541,6 @@ uint16_t MixingOutput::output_limit_calc_single(int i, float value) const
void
MixingOutput::output_limit_calc(const bool armed, const int num_channels, const float output[MAX_ACTUATORS])
{
const bool pre_armed = armNoThrottle();
// time to slowly ramp up the ESCs
static constexpr hrt_abstime RAMP_TIME_US = 500_ms;
@@ -589,7 +587,7 @@ MixingOutput::output_limit_calc(const bool armed, const int num_channels, const
*/
auto local_limit_state = _output_state;
if (pre_armed) {
if (isPrearmed()) {
local_limit_state = OutputLimitState::ON;
}
+1 -1
View File
@@ -209,7 +209,7 @@ protected:
private:
bool armNoThrottle() const
bool isPrearmed() const
{
return (_armed.prearmed && !_armed.armed) || _armed.in_esc_calibration_mode;
}