Skip to content

Commit

Permalink
mavlink: Fix ESC_STATUS sending for batches > 1
Browse files Browse the repository at this point in the history
The indexing was wrong for esc_status sending for ESCs 4->

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Aug 20, 2024
1 parent 2b38774 commit ae87fab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/mavlink/streams/ESC_STATUS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ class MavlinkStreamESCStatus : public MavlinkStream
for (int batch_number = 0; batch_number < _number_of_batches; batch_number++) {
msg.index = batch_number * batch_size;

for (int esc_index = 0; esc_index < batch_size ; esc_index++) {
msg.rpm[esc_index] = esc_status.esc[esc_index].esc_rpm;
msg.voltage[esc_index] = esc_status.esc[esc_index].esc_voltage;
msg.current[esc_index] = esc_status.esc[esc_index].esc_current;
for (int esc_index = 0; esc_index < batch_size
&& msg.index + esc_index < esc_status_s::CONNECTED_ESC_MAX; esc_index++) {
msg.rpm[esc_index] = esc_status.esc[msg.index + esc_index].esc_rpm;
msg.voltage[esc_index] = esc_status.esc[msg.index + esc_index].esc_voltage;
msg.current[esc_index] = esc_status.esc[msg.index + esc_index].esc_current;
}

mavlink_msg_esc_status_send_struct(_mavlink->get_channel(), &msg);
Expand Down

0 comments on commit ae87fab

Please sign in to comment.