mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 10:23:33 +08:00
uavcan: more efficient calculation of esc.RawCommand.cmd array size
This commit is contained in:
committed by
Jacob Dahl
parent
c44e0be18a
commit
ae03630570
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014-2022 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2014-2025 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -1082,7 +1082,19 @@ bool UavcanMixingInterfaceESC::updateOutputs(uint16_t outputs[MAX_ACTUATORS], un
|
||||
unsigned num_control_groups_updated)
|
||||
{
|
||||
if (_esc_controller.initialized()) {
|
||||
_esc_controller.update_outputs(outputs, num_outputs);
|
||||
// num_outputs is the maximum possible number of outputs (8)
|
||||
// output_array_size adapts to the highest output index that is mapped (4 for a quad)
|
||||
// this allows for sending less CAN frames depending on what output indices are mapped
|
||||
uint8_t output_array_size = 0;
|
||||
|
||||
for (int i = MAX_ACTUATORS - 1; i >= 0; i--) {
|
||||
if (mixingOutput().isFunctionSet(i)) {
|
||||
output_array_size = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_esc_controller.update_outputs(outputs, output_array_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user