Commit Graph

139 Commits

Author SHA1 Message Date
Matthias Grob ef5569fab3 px4iofirmware: reuse existing disarmed logic for lockdown and should_always_enable_pwm
The existing disarmed logic already handles disabled outputs
it makes sense to reuse it and not have lockdown handled
differently resulting in unexpeced corner cases.
2024-04-02 11:59:56 -04:00
Matthias Grob b714b5461b px4iofirmware: simplify lockdown logic 2024-04-02 11:59:56 -04:00
Matthias Grob 7f0ec2305c px4iofirmware: refactor to only have one PWM output code path
This removes the duplication with unexpected differences
and allows to consistently handle the output instead of
overriding the output for some specific cases which
leads to unexpected corner cases. E.g. disabled outputs
suddenly outputing PWM in lockdown.
2024-04-02 11:59:56 -04:00
Matthias Grob 1096384a38 px4iofirmware: don't switch to disarmed or failsafe value on disabled PWM outputs
If the output is set to 0 then the FMU had this channel disabled/no function mapped
to it. In that case we do not want to suddenly start outputing failsafe or disarmed
signals.
2024-03-25 19:21:54 +01:00
Igor Mišić 25488da944 px4io: replace safety_off state with safety button event (#19558)
internal PX4IO safety_off state is removed and replaced with a normal safety button event. From this 'commit' commander is taking care of the PX4IO safety.
2022-06-01 13:15:13 -04:00
Igor Misic 554283655c Revert "px4io: replace safety_off state with safety button event (#19558)"
This reverts commit 12a81979a8.
2022-05-26 10:06:32 -04:00
Igor Misic 12a81979a8 px4io: replace safety_off state with safety button event (#19558)
internal PX4IO safety_off state is removed and replaced with a normal safety button event. From this 'commit' commander is taking care of the PX4IO safety.
2022-05-23 06:54:37 +02:00
Daniel Agar 089c962d92 px4io: moving mixing to FMU side
Using mixers on the IO side had a remote benefit of being able to
override all control surfaces with a radio remote on a fixed wing.
This ended up not being used that much and since the original design
10 years ago (2011) we have been able to convince ourselves that the
overall system stability is at a level where this marginal benefit,
which is not present on multicopters, is not worth the hazzle.

Co-authored-by: Beat Küng <beat-kueng@gmx.net>
Co-authored-by: Daniel Agar <daniel@agar.ca>
2021-09-25 19:15:05 -04:00
Daniel Agar 22e62a044a px4iofirmware: never directly touch mixer from isr 2021-08-25 21:32:05 +02:00
David Sidrane 3d166d3279 PWM:Add Channel mask to up_pwm_servo_arm & up_pwm_servo_deinit 2021-05-05 20:48:06 +02:00
Silvan Fuhrer 7c727edc3f Simple mixer: add output slew rate
This adds the option to limit the rate of change (slew rate) of an output that's mixed by a simple mixer.
To enable it, a positive number has to be added at the end (6th number) of the output scaler line of the mixer,
specifying the min rise time of this output.
E.g. O:      10000  10000      0 -10000  10000 20000 for a rise time of 2s, resp. a max slew rate of 0.5s^-1.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2021-01-04 11:32:22 +01:00
Daniel Agar 79dc676c8f mixer: move MixerGroup out of Mixer hierarchy and delete mixer.h header 2019-11-22 15:00:25 -05:00
Beat Küng d965b928f8 px4iofirmware: convert atomic macro into methods
Reduces flash size by 744 bytes.
CPU (loop time) is not affected.
2019-11-16 11:43:42 +01:00
Beat Küng 3198610f85 src/platforms: move all headers to platforms/common/include/px4_platform_common
and remove the px4_ prefix, except for px4_config.h.

command to update includes:
for k in app.h atomic.h cli.h console_buffer.h defines.h getopt.h i2c.h init.h log.h micro_hal.h module.h module_params.h param.h param_macros.h posix.h sem.h sem.hpp shmem.h shutdown.h tasks.h time.h workqueue.h; do for i in $(grep -rl 'include <px4_'$k src platforms boards); do sed -i 's/#include <px4_'$k'/#include <px4_platform_common\/'$k/ $i; done; done
for in $(grep -rl 'include <px4_config.h' src platforms boards); do sed -i 's/#include <px4_config.h/#include <px4_platform_common\/px4_config.h'/ $i; done

Transitional headers for submodules are added (px4_{defines,log,time}.h)
2019-10-30 11:48:47 +01:00
Julien Lecoeur ced201bdb5 IO: respect actuator_armed.prearmed flag 2019-09-02 10:47:40 -04:00
Beat Küng a2ebbe9066 pwm_limit: rename to output_limit
As there is nothing pwm-specific about it.
2019-08-31 10:05:00 -04:00
Daniel Agar 737f5d4e3d px4io fix code style 2019-08-19 15:11:39 -04:00
dlwalter 310fd80405 added logic to encode NAN as INT16_MAX to transfer to IO from FMU 2019-08-19 21:08:11 +02:00
bresch c75f71abc2 IO failsafe - apply failsafe values to outputs when in failsafe.
This is required because otherwise, IO would output disarmed values if
FMU goes into a disarmed state.
2019-06-05 16:53:08 +02:00
bresch 776b1a28de IO mixer - cleanup FMU timeout check (comments and indentation) 2019-06-05 16:53:08 +02:00
bresch 158463d0a0 Flight termination - Rename "flightterm" variables and defines to "flighttermination". 2019-06-05 16:53:08 +02:00
bresch 4eaf6e77be Flight termination - Always send flag to IO without checking the circuit breaker. The circuit breaker is used inside IO to decide if it has to go into failsafe if FMU dies and also controls is the FailureDetector sets the force_failsafe flag. The other sources of flight termination (rc loss, geo fence, ...) are not disabled by the circuit breaker 2019-06-05 16:53:08 +02:00
bresch 59265f6663 Failure detector - Add flight termination comments, make format 2019-06-05 16:53:08 +02:00
bresch d655c33faa IO mixer - Change default mixer to DISARMED and allow to set outputs to failsafe if FMU does not respond and if flight termination circuit breaker is not set 2019-06-05 16:53:08 +02:00
bresch 19bf080313 PX4ioFirmware - Clean should_arm, should_arm_nothrottle and should_always_enable_pwm indentation for better understanding 2019-06-05 16:53:08 +02:00
Daniel Agar 184aa2861a PX4_ISFINITE use builtin everywhere 2019-02-21 14:56:08 -05:00
Beat Küng 3859bbb3b0 px4io mixer: fix atomic access to system_state.fmu_data_received_time
system_state.fmu_data_received_time can be set from an IRQ handler, thus
we need to ensure every read access to it in mixer_tick is atomic.
So we read it once and copy it into a local variable.
2019-01-25 07:53:37 +01:00
Lorenz Meier 3a7deefe6e IO firmware: Run critical timing operations as atomic
This is required as we might be in interrupt context on this bare-metal target.
2019-01-22 23:52:57 +01:00
Beat Küng 19ccab28bb mixer: use an enum for airmode 2018-12-13 09:50:07 +01:00
Andreas Antener e0dc5ae7f4 px4iofirmware: only set mixer trims when they got updated 2018-08-05 23:24:57 +02:00
Daniel Agar e468a9bbcc move systemlib/pwm_limit to standalone lib 2018-06-12 09:06:30 +02:00
Daniel Agar 08cc963de3 px4iofirmware use std NAN instead of undefined 0.0f/0.0f
- closes #9277
2018-04-12 00:14:50 -04:00
Daniel Agar 45eb9cb518 fix typo PX4IO_MAX_MIXER_LENGHT -> PX4IO_MAX_MIXER_LENGTH 2018-04-09 02:23:26 -04:00
bresch 6976232a20 Airmode - Add airmode parameter for multicopter mixer 2018-03-23 10:35:08 +01:00
Lorenz Meier 2c148236ae IO Mixer: Code style 2017-12-31 16:36:34 +01:00
Julien Lecoeur 89642a9203 Move src/module/systemlib/mixer to src/lib/mixer 2017-11-15 09:56:10 +01:00
Lorenz Meier afc8503260 PX4IO Firmware: Fix usage of new operator in IRQ
The mixer was creating a new class in interrupt context, which is not valid use in NuttX. This change copies the mixer into the buffer and runs the mixer management section of the code outside of interrupt context in the normal task.
2017-10-30 20:03:19 +01:00
acfloria 9d2da611f6 Fix mixer issue with undefined return in callback and non value initialized variables. 2017-10-12 12:03:22 +02:00
Daniel Agar 26f00609ac multirotor_motor_limits only publish for MC 2017-09-19 02:25:30 +01:00
Lorenz Meier 3d2d6c4fdc IO: Add lazy atomic OR, AND and CLEAR functions for flags
IO needs atomic updates of a few critical status flags, but doing these always atomic (with interrupts disabled) might cause a too high interrupts disabled interval. In order to avoid this only operations that change the state of the target variable are done with interrupts disabled, while operations without an effect on the target variable are not executed.
2017-05-04 07:46:57 +02:00
Werner Stern dc6b688a6a fixed px4io firmware read-modify-write bug 2017-05-04 07:46:57 +02:00
Lorenz Meier 60a022329f IO Firmware: Use new RC lib format 2017-05-02 07:40:50 +02:00
David Sidrane b01768addc px4iofirmware mixer uses new Oneshot API
As discusssed in https://github.com/PX4/Firmware/pull/6678#discussion_r104177663
   this take the safe approach to only call up_pwm_update on a valid mix
   it does keep intatct the riginal author (OA) had an intent.
2017-03-23 08:28:15 +01:00
Mark Whitehorn 9e3488af46 don't update servos if mixer_mix_threadsafe() failed to run 2017-03-23 08:28:15 +01:00
Mark Whitehorn 2d5588ae02 simplify oneshot mode selection; use zero PWM rate as indicator
cleanup and remove unused (new) params
2017-03-23 08:28:15 +01:00
Mark Whitehorn aa9fbbedd5 add oneshot mode capability
change fmu to task

increase fmu_servo task priority to max and enable true oneshot

use lowest FMU priority which minimizes jitter

constrain oneshot updates to control group 0 events
2017-03-23 08:28:15 +01:00
Beat Küng e7db0ed098 test_mixer & mixer: use memmove instead of memcpy
Both, src & dst use the same array, thus potentially overlapping.
Behavior of memcpy in that case is undefined.
2017-01-18 18:23:42 +01:00
Lorenz Meier 1155a4725b PX4IO: Fix mixer load corner case in string termination 2017-01-14 07:47:03 -08:00
Lorenz Meier 2cabc4866a PX4IO: Use mixer header for buffer length 2017-01-03 20:32:33 -05:00
Lorenz Meier d401252c9e IO firmware: Convert magic numbers to defines
This is necessary to allow more and better unit testing.
2017-01-03 20:32:33 -05:00