Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixer profile to open the posibility for vtol/mixed platform #8555

Merged
merged 69 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0b247d9
mixer profile switching by cli
shota3527 Nov 5, 2022
fcf9ca1
add mixer profile switching by logic
shota3527 Nov 6, 2022
88e9231
in progress of output_profile dev
shota3527 Nov 7, 2022
a9f8ebd
add mixer_profile.h
shota3527 Nov 7, 2022
23968a6
in development
shota3527 Nov 8, 2022
97318e4
add sannity check in hot mixprofile switching, and fix cli
shota3527 Nov 10, 2022
80a3dee
added servo to mixer
shota3527 Nov 11, 2022
cbbef19
mixer_profile draft pr
shota3527 Nov 13, 2022
67390e1
mixprofile development
Nov 14, 2022
6d861fd
mixer profile dev
shota3527 Nov 15, 2022
0e94190
updates in mixer_profile
shota3527 Nov 16, 2022
e0db9ae
navigation init on mixer profile
shota3527 Nov 16, 2022
8b72ffa
move motor stop feature to mixer config
shota3527 Nov 21, 2022
3ad0991
Merge remote-tracking branch 'origin/master' into sh_mixer_profile
shota3527 Jun 25, 2023
203bb2a
mixer and pid profile linking
shota3527 Jun 29, 2023
2fb9601
mixprofile transition support
shota3527 Jun 30, 2023
1839a45
add mode to swtich mixer profile
shota3527 Jul 1, 2023
1273d86
Merge branch 'master' into sh_mixer_profile
shota3527 Jul 22, 2023
fe30a8a
refactoring
shota3527 Jul 22, 2023
fb73715
minor fix
shota3527 Jul 24, 2023
e0abc47
minor fix
shota3527 Jul 24, 2023
d220dcb
mend
shota3527 Jul 24, 2023
18cefcc
mend
shota3527 Jul 24, 2023
4d81361
mixer profile switching servo speed support
shota3527 Jul 24, 2023
3cf482c
fix include for target config.c
shota3527 Jul 25, 2023
ec9ee9d
update documents
shota3527 Jul 25, 2023
a10d6ca
[mixer-profile] [doc] add some clarifications
stronnag Jul 25, 2023
5a14ff7
move ENABLE_STATE(FW_HEADING_USE_YAW) from navigation.c to mixer.c
shota3527 Jul 25, 2023
a7e1aad
Merge pull request #9 from stronnag/sh_mixer_profile_update_docs
shota3527 Jul 26, 2023
167db6e
add sannity check in Platform specific RC modes, Add sanity check in …
shota3527 Jul 27, 2023
5242ad2
mixer profile sitl support
shota3527 Jul 28, 2023
1d34800
initinal failsafe support for mixer profile
shota3527 Jul 30, 2023
e46ccfe
minor bug fix on failsafe mixertransition
shota3527 Jul 30, 2023
310bb09
modification on airmodes
shota3527 Jul 30, 2023
384439a
automated transition
shota3527 Jul 31, 2023
7c8b997
automatic mixer profile switching on rth and land
shota3527 Aug 1, 2023
271c798
minor fix
shota3527 Aug 1, 2023
1bdca4e
some clean up for mixer profile
shota3527 Aug 2, 2023
c9ff9cd
updates
shota3527 Aug 2, 2023
1188ff7
fixes
shota3527 Aug 2, 2023
258a88c
no loiter waypoint for vtol
shota3527 Aug 3, 2023
f96fd64
refactoring on pid i term
shota3527 Aug 4, 2023
75bd05a
refactoring on pid iterm
shota3527 Aug 5, 2023
461497e
refactoring on pid motorItermWindupPoint
shota3527 Aug 5, 2023
2f75a76
refactoring on pid iterm
shota3527 Aug 5, 2023
eac42ce
update docs
shota3527 Aug 5, 2023
57bba67
minor fix
shota3527 Aug 5, 2023
ecad9fe
pid windup backcalc fix
shota3527 Aug 7, 2023
5008f1b
revert commit on pid
shota3527 Aug 7, 2023
36eb299
Merge branch 'shota_pid_refactoring' into sh_mixer_profile
shota3527 Aug 7, 2023
454387f
updates on documents for mixer_profile
shota3527 Aug 9, 2023
6ac1bec
update the docs
shota3527 Aug 12, 2023
c51f15f
some cleanup
shota3527 Aug 12, 2023
bf0c0d8
Merge remote-tracking branch 'origin/master' into sh_mixer_profile
shota3527 Aug 28, 2023
1d0d5be
refactoring
shota3527 Aug 31, 2023
8161ef8
updates on mixer_profile
shota3527 Sep 7, 2023
454a289
add option to use tpa on yaw
shota3527 Sep 7, 2023
9ba3e9f
Merge branch 'shota_pid_refactoring' into sh_mixer_profile
shota3527 Sep 7, 2023
5cf1665
update the documents for mixer_profile
shota3527 Sep 7, 2023
e51fd78
Merge remote-tracking branch 'origin/master' into sh_mixer_profile
shota3527 Sep 10, 2023
e4ced70
update with timer overide
shota3527 Sep 10, 2023
59e421f
Merge branch 'master' into sh_mixer_profile
shota3527 Sep 19, 2023
49e69f0
revert changes of pid controller
shota3527 Sep 19, 2023
24ffa37
minor fix
shota3527 Sep 20, 2023
2b75da5
Merge remote-tracking branch 'origin/master' into sh_mixer_profile
shota3527 Sep 22, 2023
e4984a5
minor fix
shota3527 Sep 22, 2023
8328870
minor fix
shota3527 Sep 23, 2023
0e93fce
Revert "refactoring"
shota3527 Sep 23, 2023
e108558
add MIXER_TRANSITION_ACTIVE OPERAND
shota3527 Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ startup_stm32f10x_md_gcc.s
#.vscode/
cov-int*
/build/
/build_SITL/
/obj/
/patches/
/tools/
/downloads/
/debug/
/debug/
/release/

# script-generated files
Expand Down
144 changes: 144 additions & 0 deletions docs/MixerProfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# MixerProfile

A MixerProfile is a set of motor mixer, servo-mixer and platform type configuration settings to enable VTOL transitions.

Currently two profiles are supported on targets other than F411 and F722 (due to resource constraints on these FC). i.e VTOL transition is not available on F411 and F722 targets.

By default, switching between profiles requires reboot to take affect. However, when all conditions are met, and a suitable [configuration](#configuration) has been applied, `mixer_profile` also allows in-flight profile [switching](#rc-mode-settings) to allow things like VTOL operation. This is the recommended operating mode.

Please note that this is an emerging / experimental capability that will require some effort by the pilot to implement.

## Setup for VTOL
- A VTOL specific FC target or `timer_output_mode` overrides was required in the early stage of the development, But since unified mapping introduced in INAV 7.0 It is not needed anymore.
- ~~For mixer profile switching it is necessary to keep motor and servo PWM mapping consistent between Fixed-Wing (FW) and Multi-rotor (MR) profiles~~
- ~~Traditionally, FW and MR have had different enumerations to define the PWM mappings. For VTOL operation it is necessary to set the `timer_output_mode` overrides to allow a consistent enumeration and thus mapping between MR and FW modes.~~
- ~~In operation, it is necessary to set the `mixer_profile` and the `pid_profile` separately and to set a [RC mode](#rc-mode-settings) to switch between them.~~
## Configuration
### Timer overrides
Set the timer overrides for the outputs that you are intended to use.
For SITL builds, is not necessary to set timer overrides.
Please note that there are some display issues on the configurator that will show wrong mapping on the mixer_profile which has less motor/servo compared with the another
### Profile Switch

Setup the FW mode and MR mode separately in two different mixer profiles:

In this example, FW mode is `mixer_profile` 1 and MR mode is `mixer_profile` 2.

Currently, the INAV Configurator does not fully support `mixer_profile`, so some of the settings have to be done in CLI.

Add `set mixer_pid_profile_linking = ON` in order to enable `pid_profile` auto handling. It will change the `pid profile` index according to the `mixer_profile` index on FC boot and allow `mixer_profile` hot switching (this is recommended usage).

The following 2 `mixer_profile` sections are added in the CLI:

```
#switch to mixer_profile by cli
mixer_profile 1

set platform_type = AIRPLANE
set model_preview_type = 26
# motor stop feature have been moved to here
set motorstop_on_low = ON
# enable pid_profile auto handling (recommended).
set mixer_pid_profile_linking = ON
save
```
Then finish the aeroplane setting on mixer_profile 1

```
mixer_profile 2

set platform_type = TRICOPTER
set model_preview_type = 1
# also enable pid_profile auto handling
set mixer_pid_profile_linking = ON
save
```
Then finish the multi-rotor setting on `mixer_profile` 2.

Note that default profile is profile `1`.

You can use `MAX` servo input to set a fixed input for the tilting servo. Speed setting for `MAX` input is available in the CLI.

It is recommended to have some amount of control surface (elevon / elevator) mapped for stabilization even in MR mode to get improved authority when airspeed is high.

**Double check all settings in CLI with the `diff all` command**; make sure you have set the correct settings. Also check what will change with `mixer_profile`. For example servo output min / max range will not change. But `smix` and `mmix` will change.

### Mixer Transition input

Typically, 'transition input' will be useful in MR mode to gain airspeed.
Both the servo mixer and motor mixer can accept transition mode as an input.
The associated motor or servo will then move accordingly when transition mode is activated.
Transition input is disabled when navigation mode is activate

The use of Transition Mode is recommended to enable further features and future developments like fail-safe support. Mapping motor to servo output, or servo with logic conditions is **not** recommended

#### Servo

38 is the input source for transition input; use this to tilt motor to gain airspeed.

Example: Increase servo 1 output by +45 with speed of 150 when transition mode is activated for tilted motor setup:

```
# rule no; servo index; input source; rate; speed; activate logic function number
smix 6 1 38 45 150 -1
```
Please note there will be a time window that tilting motors is providing up lift but rear motor isn't. Result in a sudden pitch raise on the entering of the mode. More forward tilting servo position on transition input(you can use 'speed' in servo rules to slowly move to this position), A faster tilting servo speed on `MAX` servo input will reduce the time window. OR lower the throttle on the entering of the FW mode to mitigate the effect.

#### Motor

The default `mmix` throttle value is 0.0, It will not show in `diff` command when throttle value is 0.0 (unused); this causes the motor to stop.

- 0.0<throttle<=1.0 : normal mapping
- -1.0<throttle<=0.0 : motor stop, default value 0
- -2.0<throttle<-1.0 : spin regardless of the radio's throttle position at speed `abs(throttle)-1` when Mixer Transition is activated.

Example: This will spin motor number 5 (counting from 1) at 20%, in transition mode only, to gain speed for a "4 rotor 1 pusher" setup:

```
# motor number; throttle; roll; pitch; yaw
mmix 4 -1.200 0.000 0.000 0.000
```

### RC mode settings

It is recommend that the pilot uses a RC mode switch to activate modes or switch profiles.
Profile files Switching is not available until the runtime sensor calibration is done. Switching is NOT available when navigation mode is activate or position controller is activate, including altitude hold.

`mixer_profile` 1 will be used as default, `mixer_profile` 2 will be used when the `MIXER PROFILE 2` mode box is activated. Once successfully set, you can see the profiles / model preview etc. will switch accordingly when you view the relevant INAV Configurator tabs. Checking these tabs in the INAV Configurator will help make the setup easier.

Set `MIXER TRANSITION` accordingly when you want to use `MIXER TRANSITION` input for motors and servos. Here is sample of using the `MIXER TRANSITION` mode:

![Alt text](Screenshots/mixer_profile.png)

| 1000~1300 | 1300~1700 | 1700~2000 |
| :-- | :-- | :-- |
| FW(profile1) with transition off | MC(profile2) with transition on | MC(profile2) with transition off |

It is also possible to set it as 4 state switch by adding FW(profile1) with transition on.

### Automated Transition
This feature is mainly for RTH in a failsafe event. When set properly, model will use the FW mode to fly home efficiently, And land in the MC mode for easier landing.
Set `mixer_automated_switch` to `ON` in mixer_profile for MC mode. Set `mixer_switch_trans_timer` in mixer_profile for MC mode for the time required to gain airspeed for your model before entering to FW mode, for example, 50 ds. Finally set `mixer_automated_switch` to `ON` in mixer_profile for FW mode to let the model land in MC mode.
```
mixer_profile 2
set mixer_automated_switch = ON
set mixer_switch_trans_timer = 50
mixer_profile 1
set mixer_automated_switch = ON
save
```

`ON` for a mixer_profile\`s `mixer_automated_switch` means to schedule a Automated Transition when RTH head home(applies for MC mixer_profile) or RTH Land(applies for FW mixer_profile) is requested by navigation controller.

When `mixer_automated_switch`:`OFF` is set for all mixer_profiles(defaults). Model will not perform automated transition at all.


## Happy flying

Remember that this is currently an emerging capability:

* Test every thing on bench first.
* Remove the props and try `MIXER PROFILE 2`, `MIXER TRANSITION` RC modes while arming.
* Then try MR or FW mode separately see if there are any problems.
* Try it somewhere you can recover your model in case of fail-safe. Fail-safe behavior is unknown at the current stage of development.
* Use the INAV Discord for help and setup questions; use the Github Issues for reporting bugs and unexpected behaviors. For reporting on Github, a CLI `diff all`, a DVR and a Blackbox log of the incident will assist investigation.
Binary file added docs/Screenshots/mixer_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,36 @@ This is the PWM value sent to ESCs when they are not armed. If ESCs beep slowly

---

### mixer_automated_switch

If set to on, This mixer_profile will try to switch to another mixer_profile when 1.RTH heading home is requested and distance to home is lager than 3*nav_fw_loiter_radius on mixer_profile is a MULTIROTOR or TRICOPTER platform_type. 2. RTH landing is requested on this mixer_profile is a AIRPLANE platform_type

| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |

---

### mixer_pid_profile_linking

If enabled, pid profile_index will follow mixer_profile index. Set to OFF(default) if you want to handle PID profile by your self. Recommend to set to ON on all mixer_profiles to let the mixer_profile handle the PID profile switching on a VTOL or mixed platform type setup.

| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |

---

### mixer_switch_trans_timer

If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_automated_switch. Activate Mixertransion motor/servo mixing for this many decisecond(0.1s) before the actual mixer_profile switch.

| Default | Min | Max |
| --- | --- | --- |
| 0 | 0 | 200 |

---

### mode_range_logic_operator

Control how Mode selection works in flight modes. If you example have Angle mode configured on two different Aux channels, this controls if you need both activated ( AND ) or if you only need one activated ( OR ) to active angle mode.
Expand Down Expand Up @@ -2612,6 +2642,16 @@ Output frequency (in Hz) for motor pins. Applies only to brushed motors.

---

### motorstop_on_low

If enabled, motor will stop when throttle is low on this mixer_profile

| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |

---

### msp_override_channels

Mask of RX channels that may be overridden by MSP `SET_RAW_RC`. Note that this requires custom firmware with `USE_RX_MSP` and `USE_MSP_RC_OVERRIDE` compile options and the `MSP RC Override` flight mode.
Expand Down
2 changes: 2 additions & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ main_sources(COMMON_SRC
flight/rth_estimator.h
flight/servos.c
flight/servos.h
flight/mixer_profile.c
flight/mixer_profile.h
flight/wind_estimator.c
flight/wind_estimator.h
flight/gyroanalyse.c
Expand Down
2 changes: 2 additions & 0 deletions src/main/cms/cms_menu_mixer_servo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "build/version.h"

#include "flight/mixer_profile.h"
#include "flight/mixer.h"
#include "flight/servos.h"

Expand All @@ -40,6 +41,7 @@

#include "fc/runtime_config.h"
#include "fc/settings.h"
#include "fc/config.h"

static uint8_t currentMotorMixerIndex = 0;
static uint8_t tmpcurrentMotorMixerIndex = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/main/config/parameter_group_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
//#define PG_TRANSPONDER_CONFIG 17
#define PG_SYSTEM_CONFIG 18
#define PG_FEATURE_CONFIG 19
#define PG_MIXER_CONFIG 20
#define PG_SERVO_MIXER 21
#define PG_MIXER_PROFILE 20
// #define PG_SERVO_MIXER 21
#define PG_IMU_CONFIG 22
//#define PG_PROFILE_SELECTION 23
#define PG_RX_CONFIG 24
Expand Down
1 change: 1 addition & 0 deletions src/main/drivers/pwm_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "drivers/io_types.h"
#include "flight/mixer.h"
#include "flight/mixer_profile.h"
#include "flight/servos.h"

#if defined(TARGET_MOTOR_COUNT)
Expand Down
Loading
Loading