bluerobotics / bluerobotics/BlueOS

PWM output editor shows Trim for functions that ignore SERVOn_TRIM

Open
#4,195 1 comment 0 reactions 0 assignees View on GitHub
bug core ui
Dominant language
Vue
Stars
453
Forks
151
Avg merge
1d 3h
Merged PRs (30d)
174

Description

## Summary

The PWM Outputs parameter editor always shows a Trim handle and `SERVOn_TRIM` field for PWM-capable output functions. ArduPilot only uses trim for **angle-style** outputs. For everything else the control is cosmetic: dragging it writes a parameter that does not change the output.

Hide Trim unless the assigned function (and, for motors, `MOT_PWM_TYPE`) actually uses it.

## What the UI does today

Checked on Vehicle Setup → PWM Outputs (`1.4-dev`, `MOT_PWM_TYPE = Normal`).

| Output | Function | Trim shown? | Trim actually used? |
| --- | --- | --- | --- |
| 1–5 | MotorN | Yes (`SERVOn_TRIM` + slider) | **No** — motors use shared `MOT_PWM_MIN` / `MOT_PWM_MAX` and write raw PWM |
| 6 | GPIO | No | N/A (digital) |
| 7, 8, 15 | Disabled | No | N/A |
| 9 | SERVOn_MIN | Yes | This pin emits `SERVOn_MIN` as a constant. Trim is a sibling parameter, not this function's output |
| 10 | Script1 | Yes | **Yes** — scripting outputs are angle-style (`set_angle`) |
| 11 | CamZoom (180) | Yes | **No** — range-style (`set_range(1000)`), maps 0…1000 onto MIN…MAX |
| 12 | CameraFocus | Yes | **No** — same as CamZoom |
| 13–14 | Lights1 / Lights2 | Yes | **No** — same as CamZoom. Off sits at MIN (1100 here), not TRIM |
| 16 | Mount1Pitch | Yes | **No** — servo gimbal `move_servo()` interpolates MIN…MAX and ignores TRIM |

No Actuator or RCIN function was assigned on this vehicle. From firmware:

- **Actuator1–6**: joystick path writes raw PWM between MIN and MAX; TRIM is the startup / center position. `MAV_CMD_DO_SET_ACTUATOR` is angle-style (−1…1 around TRIM).
- **RCINn** (passthrough): MIN / MAX / TRIM ignored; input PWM is copied out.
- **RCINnScaled / RCINn_MAPPED**: angle-style; TRIM is the center.

`MOT_PWM_TYPE = PWMRange` is a third motor mode. ArduPilot honours per-channel MIN/MAX there, still not TRIM. BlueOS currently rejects that type with "PWM type is not supported".

## When firmware uses TRIM

ArduPilot `SRV_Channel`:

- **Angle** (`pwm_from_angle`): TRIM is the center. Used by PWMAngle motors, scripting, RCIN mapped, actuator scaled commands.
- **Range** (`pwm_from_range`): linear MIN→MAX. TRIM is unused. Used by lights, camera zoom/focus, video switch, PWMRange motors.
- **Raw PWM** (`set_output_pwm`): TRIM is unused unless the caller reads it itself (actuators do, for home/center).
- **Motors + `MOT_PWM_TYPE = Normal` (0)**: raw PWM from `MOT_PWM_MIN` / `MOT_PWM_MAX`. `SERVOn_TRIM` has no effect.
- **Motors + `MOT_PWM_TYPE = PWMAngle` (9)**: TRIM is the bidirectional center. This is the only motor PWM type where Trim should be editable.

The motor editor already tries to pass no trim param unless PWM type is PWMAngle. `ServoFunctionRangeEditor` then does `trimParam ?? SERVOn_TRIM`, so Trim still appears.

## Expected

Show the Trim thumb and `SERVOn_TRIM` field only when that output will use it:

- MotorN: only if `MOT_PWM_TYPE = PWMAngle`
- Lights, CamZoom, CameraFocus, VideoSwitch, Mount pan/tilt/roll, RCINn passthrough: hide Trim (keep MIN/MAX)
- Scripting, RCINnScaled / mapped, angle-style servos: keep Trim
- Actuator: keep Trim (home / center), labelled as such if we want to be precise
- GPIO / Disabled: unchanged (no range editor)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the Vehicle Setup → PWM Outputs UI and inspect ServoFunctionRangeEditor together with the motor editor's trim-parameter handling. Trace how each assigned function and MOT_PWM_TYPE determines whether trim is used. Done means Trim is hidden for range, raw-PWM, passthrough, and non-output functions while remaining available for angle-style and actuator outputs, without changing existing MIN/MAX behavior.

Written by the indexing model from the issue text.

Assessment

Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.