CA_SV_CS_COUNT and CA_SV_TL_COUNT size loops over fixed arrays, and a parameter's range is not enforced when it is set, so an out-of-range count indexed past them.
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
* fix(control_allocator): zero non-finite torque setpoint components
vehicle_torque_setpoint is also written by external producers over
uXRCE-DDS and Zenoh. The torque vector was copied unchecked while the
thrust path is sanitised; one NaN component makes every actuator
setpoint NaN, which the mixer maps to the disarmed output. Zero
non-finite components as the rate controllers do, on both allocation
instances (and the second instance's thrust).
* fix(control_allocator): note that the second instance has no NaN based motor stopping
* refactor(AlphaFilter): revert back to allowing configuration using seconds
I agree having
setParameters(uint64_t sample_interval_us, uint64_t time_constant_us)
is useful for multiple call sights but the refactor to only allow 64-Bit microseconds timestamps went too far and made the library more error prone and consume more resources.
The original mistake of
float dt = get_timestamp() - last_timestamp;
cannot easily be prevented this way and mixed uint64_t, float use anyways leads to a compile error with the overloaded functions.
* [AUTO COMMIT] update EKF change indication
See .github/workflows/checks.yml for more details
* fix(AlphaFilter): explicitly delete mixing float and unit64_t parameters to improve the compiler error
* fix(dt-calculations): consistent static_cast<float>(now) * 1e-6f conversion pattern
* fix(control_allocation): drop control axes that are not independently achievable
Stopping a hexarotor motor and its geometric opposite (CA_FAILURE_MODE=1)
leaves four rotors whose roll and yaw effectiveness rows are collinear -
exactly so on ideal geometry, 1.3 deg apart on a surveyed airframe. Yaw is
no longer independently controllable, but nothing in control allocation
checked for that, so geninv inverted a near-singular matrix and returned a
mix with roll gains ~50x and thrust gains ~2000x with random signs
(Moore-Penrose residual 1e4). Sequential desaturation cannot recover from
gains that large and left ~0.85 on two rotors at zero thrust demand: a
vehicle armed on the ground at idle lifted off by itself.
dropDependentAxes() walks the effectiveness rows in priority order
(thrust z, roll, pitch, thrust x, thrust y, yaw) and zeroes any row whose
component orthogonal to the higher-priority rows falls below
kMinAxisIndependence = 1e-2, i.e. within ~5.7 deg of their span. The axis
becomes explicitly unachievable and is reported through the dropped-axis
mask instead of being inverted into garbage.
The metric is unit-free, so it does not depend on CA_ROTORn_KM or arm
length: verified identical decisions for KM from 0.003 to 0.5 and arms from
0.05 m to 5 m. Across in-tree geometries healthy multirotors score 1.00,
hexa/octo with one motor out 0.75/0.89 and tailsitter 0.70, none affected;
only quad-with-one-motor-out and hexarotor failed+opposite drop yaw.
The orthogonalization runs through the Cholesky factor of the Gram matrix
of the accepted unit rows rather than on the rows themselves, so no
NUM_ACTUATORS-long vectors land on the stack: 288 B of frame instead of
632 B, which matters because this runs on wq:rate_ctrl with 3150 B.
Co-Authored-By: Matthias Grob <maetugr@gmail.com>
* feat(matrix): add dot product for matrix::Slice
* fix(control_allocation): replace custom rowDot() with new matrix::Slice::dot()
---------
Co-authored-by: Matthias Grob <maetugr@gmail.com>
* feat(control_allocator): add reversible-motor failure recovery for hexarotors
On a single motor failure (CA_FAILURE_MODE), handle the failed motor's
geometric-opposite motor on a hexarotor to recover the lost control authority:
1 = remove failed + shut off opposite (restores symmetry)
2 = remove failed + make opposite reversible (assumes a reverse-capable ESC)
Non-hex frames have no opposite and keep the upstream remove-only behavior.
The opposite motor is found geometrically (opposite spin, closest antipode) and
only for hexarotors. Reverse thrust is modeled as CA_REV_THR_FRAC of forward
thrust and the reversible actuator range is rescaled to [-1, 0] on publish.
Consumes failure_detector_status.motor_failure_mask, independent of detection.
* feat(uavcan): render reversible motor outputs as signed RawCommand
Re-encode reversible channels from the mixer's [min,max] range to a signed
RawCommand (negative = reverse). A channel at its disarmed value is passed
through untouched, so a stopped motor is never inverted to reverse.
* fix(dshot): match per-channel minimums to the 3D encoding
calculate_output_value() applies the 3D split when DSHOT_3D_ENABLE is set or the
channel is reversible, but the per-channel minimum was derived from the
reversible bit alone. Two problems followed.
A reversible channel made reversible at runtime kept a stale minimum, so its
neutral no longer landed on the mid-throttle split. A non-reversible channel
with 3D enabled was worse: it mapped from DSHOT_MIN, which sits below the split,
so zero commanded thrust decoded as near-full reverse.
Select the minimum from the same two facts the encoder uses. A reversible
channel keeps the range bottom so neutral lands on the split, a forward-only
channel starts just above it, and without 3D the DSHOT_MIN idle floor applies as
before. For a split channel the idle floor is applied per direction inside
convert_output_to_3d_scaling(), so it must not be added to the minimum. The
deadband is now applied only to reversible channels, since a channel that cannot
be commanded negative has no neutral to guard.
Apply the minimums from a new OutputModuleInterface::reversibleMaskChanged(),
called once the new mask is known and before any output is computed with it.
Applying them from Run() left the range one cycle behind the mask it depends on,
which in 3D mode changed the sign of the output on the transition.
The reversible mask can now change while armed, since failure recovery reverses a
motor in flight, so the reversibleOutputs() contract is updated to say so.
Changes output values for every DSHOT_3D_ENABLE=1 setup that has any
non-reversible motor. Verified on fmu-v4 with 3D-mode ESCs: forward-only
channels floor at 1001 with no samples below the split across 85 s armed, and a
runtime-reversed recovery motor tracks yaw input through the split in both
directions.
* docs(control_allocator): document motor failure recovery
Add a Motor Failure Recovery page covering CA_FAILURE_MODE, the hexarotor
stop-or-reverse behaviour of the opposite motor, CA_REV_THR_FRAC, the
detection prerequisites and which output protocols can drive a motor in
reverse.
Document the signed DroneCAN RawCommand encoding for reversible motors,
and correct the failure detector section, which claimed motor failures
are non-latching while the current-based check holds a flagged motor
until the vehicle disarms.
Add the page to the navigation and to the v1.18 release notes.
* docs(docs): subedit
* docs(docs): subedit
* refactor(control_allocator): align CA_REV_THR_FRAC naming and description
Rename the parameter member to _param_ca_rev_thr_frac to match the
parameter name, and note in the description that the reverse thrust
fraction is mostly a property of the propeller.
* docs(motor_failure_recovery): move under Actuators and target v1.19
The page documents how control allocation is reconfigured, so list it
under Actuators next to Actuator Allocation instead of under Safety, and
link it from the Actuators and multicopter Features indexes. Safety
configuration still links to it from the motor failure trigger section.
The release branch for v1.18 is already cut, so move the release notes
to main.md and set the version badges to main (PX4 v1.19).
* docs(motor_failure_recovery): spell out the reversing requirements
Any of the six motors can fail, so every motor has to be reverse-capable,
not just one. List the settings that mode 2 needs, split the per-protocol
detail out (DroneCAN reverses from the signed RawCommand alone, DShot also
needs the ESCs in 3D mode and DSHOT_3D_ENABLE to match), and say what
happens when they are not set: a reverse command comes out as forward
thrust, and on PWM the recovery motor sits at around half throttle.
Also note that motors do not have to be marked bidirectional (CA_R_REV)
for this, since the recovery motor is made reversible at runtime.
* Apply suggestions from code review
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
* fix(uavcan_main): log final value in actuator_outputs, always run through reversible logic
We want worst case execution time all the time and as little control paths as possible. Also actuator_outputs is used to debug ESC behavior and should contain the final value that is sent out over the wire.
* refactor(DShot): directly calculate minimum dshot value in apply_min_values()
* refactor(control_allocator): static_cast, correct CA_FAILURE_MODE description
* fix(control_allocator): treat undefined parameter values as default, use matrix function to zero a collumn
---------
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Matthias Grob <maetugr@gmail.com>
- Separate stopped motor mask into separate state variables (one for
stopping due to flight phase, one for stopping due to NaN thrust in
each direction) and combine them on demand in getStoppedMotors. This
removes the need of hard to follow &= and |= operation involving
shared state.
- use the new nanToZero to clean _thrust_sp for CA internal use
- Introduce lateral/longitudinal/vertical motor masks in base
ActuatorEffecctiveness (and remove previous from individual
Effectiveness classes)
- Populate the bitmasks from all relevant effectivenesses by calling
the new _rotors.setMotorDirectionBitmasks()
- isAlignedWithCoordinateAxis checks axis alignment with given
angle tolerance
- motor stopping is the same as before, using the result of
getStoppedMotors
The current preflight check works by sending individual actuator
commands over mavlink. This can only be done sequentially, so the
surfaces do not move in a coordinated way, instilling little confidence.
To alleviate, this adds a control surface preflight check which causes
the allocator to command torque in the given direction, so the control
surfaces move as they would in flight.
Triggered by `{MAV,VEHICLE}_CMD_ACTUATOR_GROUP_TEST`. Only runs when
pre-armed (control surfaces, tilts) or armed (thrust). Test runs for 0.5
seconds -- for longer duration, send repeatedly from the GS.
Check is rejected in flight and cancelled when nav_state changes.
- Expose overrideCollectiveTilt in ActuatorEffectiveness, empty base, only overridden for Tiltrotor
- Allow giving collective tilt that is used in updateSetpoint in place
of command from tiltrotor_extra_controls
- Needs to be called with do_override = false to clear override
- add comment explaining technical debt
PR #25799 added 'servo-launch-lock' to apply_identifiers (6 items) but
did not add a corresponding 6th entry to the 19 rule item arrays, causing
QGC to reject all servo-type rules with "unexpected num items expected: 6".
So transitions between stopped/not stopped respect the slew rate.
- Remove previous stopped motor handling in publish_actuator_controls
- Replace with handle_stopped_motors, called in Run() before slew
- Introduce ApplyNanToActuators in ControlAllocation to stop
- Refactor ice shedding slightly to fit new structure
In the CA_ICE_PERIOD param description, a '>' was at the start of a
line. This is interpredeted by markdown as a quotation type indented
block which applies not only to that line, but to all following ones.
Changing the line breaks to only occur after full stops fixes it.
* FWModeManager: add option to set flag for disabling actuators during launch
Signed-off-by: Silvan <silvan@auterion.com>
* Allocation: add option to each control surface to be locked for launch
Signed-off-by: Silvan <silvan@auterion.com>
* FW rate control: reset integral while control surfaces are locked
Signed-off-by: Silvan <silvan@auterion.com>
---------
Signed-off-by: Silvan <silvan@auterion.com>
Co-authored-by: mahima-yoga <mahima@auterion.com>
* feat: implement UAVCAN LED control for individual light control and assignment
* uavcan led: nit-picks from review
* uavcan led: reduce maximum number of lights
to avoid unused parameters
* uavcan led: simplify anticolision on check
* uavcan led: correctly map 8-bit RGB to rgb565
* Trim param name character arrays to 17
16 characters + \0 termination
* uavcan led: final nit-picks
---------
Co-authored-by: Matthias Grob <maetugr@gmail.com>
This feature periodically spins the unused motors on VTOL airframes, to
break off ice that has built up in the motor while it is still feasible
to do so. Each ice shedding event sends a motor ouput of 0.01 to the
unused motors for 2 seconds.
Configured by `CA_ICE_PERIOD`, the duration of the entire cycle. Set to
0 to disable.
Add PWM_*_CENTERx for each servo.
Use a bilinear transform to map actuator_servos to PWM signals.
This solution only works for PWM based servos. Other types of servos are not affected.
* PWM: Add servo trim option
* PWM: Improve documentation of PWM trim feature
* PWM: cleaner clamping and docs typo
* update documentation & safety
* add migration formula
* rename param from trim to center
* docs with center instead of trim
* move clamping and reorder values
* improve documentation
* adress failing range check
* improve documentation
* CA: add event for setting CENTER with TRIM
Signed-off-by: Silvan <silvan@auterion.com>
---------
Signed-off-by: Silvan <silvan@auterion.com>
Co-authored-by: Silvan <silvan@auterion.com>
* rft: initial merging of controllers for spacecraft vehicles
* feat: rate controller nominal
* feat: spacecraft tooling for commander and VehicleStatus
* feat: spacecraft tooling for commander and VehicleStatus
* fix: format
* fix: format
* fix: remove iostream
* fix: remove iostream
* feat: spacecraft attitude control and minor refactoring of params
* feat: add position controller
* fix: format
* fix: moved trajectories to new message, removed derivative filters
* fix: format
* fix: removed extra newline
* fix: spacecraft allocation builds
* feat: add thrusters to effectivenes, add spacecraft build to cmake, clean comments
* feat: required changes for allocation
* feat: thruster simulation interface
* fix: update maximum and minimums
* fix: format
* fix: added newline at the end of spacecraft actuator effectiveness
* feat: configurable board pwm freq from Kconfig
* feat: mavlink compliant spacecraft definition
* feat: add orbiter to define
* boards: Increase TELEM2 rx buffer size for DDS over serial use-case (ARK Jetson)
feat: spacecraft tooling for commander and VehicleStatus
fix: format
fix: remove iostream
feat: mavlink compliant spacecraft definition
* feat: add orbiter to define
* feat: add orbiter to define
* fix: change mav_type to new spacecraft orbiter enum value
* fix: build issue
* feat: update mavlink
* feat: update mavlink to latest master with spacecraft
* feat: update mavlink
* feat: update mavlink to latest
* feat: cleanup and synchronization with new mavlink vehicle definition
* fix: get away without specifying spacecraft vehicle
* fix: removed unnecessary definition
* fix: format
* feat: cmake variant for spacecraft
* feat: proper mav_type and rc init
* fix: removed dart from build system
* add: thrusters to actuator type
* rft: reordering actuator type
* rft: initial merging of controllers for spacecraft vehicles
* feat: rate controller nominal
* fix: format
* feat: spacecraft attitude control and minor refactoring of params
* feat: add position controller
* fix: format
* fix: moved trajectories to new message, removed derivative filters
* fix: format
* fix: removed extra newline
* fix: spacecraft allocation builds
* feat: add thrusters to effectivenes, add spacecraft build to cmake, clean comments
* feat: required changes for allocation
* feat: thruster simulation interface
* fix: update maximum and minimums
* fix: format
* fix: added newline at the end of spacecraft actuator effectiveness
* feat: configurable board pwm freq from Kconfig
* feat: add orbiter to define
* feat: cleanup and synchronization with new mavlink vehicle definition
* fix: get away without specifying spacecraft vehicle
* fix: conflicts
* fix: format
* fix: remove duplicate entry
* rft: remove Kconfig changes
* rft: revert main Kconfig
* rft: revert main kcoonfig on platforms
* rft: remove changes to board PWm (go on another PR)
* rft: revert changes to commander (main is correct)
* fix: extra char on commander_helper
* rft: removed extra spaces
* rft: moved effectiveness to spacecraft
* fix: spacecraft effectiveness
* fix: extra space
* feat: preliminary version, still using thrusters
* rft: initial pipeline on PX4 side with rotors instead of thrusters
* feat: add atmos model
* feat: spacecraft with rotor pipeline tested, working
* feat: update gz
* rft: removed thruster interfaces
* fix: format
* fix: remove control allocation
* fix: thruster normalization
* fix: format
* fix: nuttx version
* fix: clang tidy error
* feat: updated gz to add atmos model
* fix: update gz
* fix: update mavlink
* fix: remove friend class from allocation lib
* fix: remove actuator_outputs/motors
---------
Co-authored-by: Alexander Lerach <alexander@auterion.com>
* Remove more circular dependencies with ActuatorEffectiveness
* Separate vehicle specific actuator effectiveness
Keep actuator effectivenss in control allocator
* Remove test dependency for now
* Group library directories
Fix
* Change directory names
* Rebase fix