OutputModuleInterface::updateOutputs return bool to control actuator_outputs pub

Required for pwm_out_sim: only publish actuator_outputs when we get
actuator_controls. Otherwise lockstep startup does not work.
The issue was there before but hidden, due to a long poll timeout.

Works with HIL too.
This commit is contained in:
Beat Küng
2019-10-21 09:42:08 +02:00
parent 380247168d
commit a8f6622831
6 changed files with 36 additions and 20 deletions
+11 -10
View File
@@ -308,9 +308,11 @@ bool MixingOutput::update()
unsigned num_motor_test = motorTest();
if (num_motor_test > 0) {
_interface.updateOutputs(false, _current_output_value, num_motor_test, 1);
actuator_outputs_s actuator_outputs{};
setAndPublishActuatorOutputs(num_motor_test, actuator_outputs);
if (_interface.updateOutputs(false, _current_output_value, num_motor_test, 1)) {
actuator_outputs_s actuator_outputs{};
setAndPublishActuatorOutputs(num_motor_test, actuator_outputs);
}
checkSafetyButton();
handleCommands();
return true;
@@ -375,14 +377,13 @@ bool MixingOutput::update()
reorderOutputs(_current_output_value);
/* now return the outputs to the driver */
_interface.updateOutputs(stop_motors, _current_output_value, mixed_num_outputs, n_updates);
if (_interface.updateOutputs(stop_motors, _current_output_value, mixed_num_outputs, n_updates)) {
actuator_outputs_s actuator_outputs{};
setAndPublishActuatorOutputs(mixed_num_outputs, actuator_outputs);
actuator_outputs_s actuator_outputs{};
setAndPublishActuatorOutputs(mixed_num_outputs, actuator_outputs);
publishMixerStatus(actuator_outputs);
updateLatencyPerfCounter(actuator_outputs);
publishMixerStatus(actuator_outputs);
updateLatencyPerfCounter(actuator_outputs);
}
checkSafetyButton();
handleCommands();
+10 -1
View File
@@ -66,7 +66,16 @@ public:
OutputModuleInterface(const char *name, const px4::wq_config_t &config)
: px4::ScheduledWorkItem(name, config), ModuleParams(nullptr) {}
virtual void updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],
/**
* Callback to update the (physical) actuator outputs in the driver
* @param stop_motors if true, all motors must be stopped (if false, individual motors
* might still be stopped via outputs[i] == disarmed_value)
* @param outputs individual actuator outputs in range [min, max] or failsafe/disarmed value
* @param num_outputs number of outputs (<= max_num_outputs)
* @param num_control_groups_updated number of actuator_control groups updated
* @return if true, the update got handled, and actuator_outputs can be published
*/
virtual bool updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],
unsigned num_outputs, unsigned num_control_groups_updated) = 0;
/** called whenever the mixer gets updated/reset */