Skip to content

Commit

Permalink
dshot: only publish when all motor RPM is there
Browse files Browse the repository at this point in the history
Otherwise we publish a lot of duplicate data for little gain.

Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes committed Apr 27, 2023
1 parent 0e4159b commit 647bd84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ void process_capture_results(void *arg)
}

if (_erpm_callback != NULL) {
_erpm_callback(_erpms, 4, _erpm_callback_context);
// Only publish every 4th time once all measurements have come in.
if (_motor_to_capture == 3) {
_erpm_callback(_erpms, 4, _erpm_callback_context);
}
}

_motor_to_capture = (_motor_to_capture + 1) % 4;
Expand Down
1 change: 1 addition & 0 deletions src/drivers/dshot/DShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ void DShot::erpm_trampoline(uint32_t erpms[], size_t num_erpms, void *context)

void DShot::erpm(uint32_t erpms[], size_t num_erpms)
{
// TODO: this is hard-coded to 4 motors
esc_status_s &esc_status = _esc_status_pub.get();
esc_status = {};
esc_status.timestamp = hrt_absolute_time();
Expand Down

0 comments on commit 647bd84

Please sign in to comment.