Skip to content

Conversation

@TedObrien
Copy link
Contributor

Solved Problem

When using a 4 servo swash plate, non-linearity due to the rotation of the servo arm can cause servo misalignment and binding, particularly at high collective + cyclic inputs. This results in higher loads on servos.

Solution

Add 2 parameters, CA_LIN_SERVO and CA_MAX_SVO_THROW, to account for the nonlinear output due to servo-arm rotation.

CA_LIN_SERVO: Enables the feature.
CA_MAX_SVO_THROW: Allows you to define the maximum throw of the servos in degrees. Set to 50 degrees by default.

The feature works as follows:

  • Calculate the max linear movement of a servo arm of unit length based on the max servo throw. This corresponds to a PWM value of 1000/2000 (max/min control input).
  • Calculate the servo arm angle required to achieve desired linear output with arcsin(max_servo_height * input) (input is requested from the controller).
  • The arm angle is normalized by dividing it by CA_MAX_SVO_THROW (in radians)

This feature was implemented in Ardupilot a while ago. I have used the same logic and added a parameter to adjust the max servo throw. The following links provide further information.

This requires a specific setup to work correctly. It assumes that the servo is centered on its physical throw and the swash plate in its mid position will give hover collective. The above links provide more detail about this.

Test coverage

  • Tested on a skynode (v5x) with a 4-servo swash plate

  • Disconnected one of the 4 linkages from the swash plate.

  • Commanded max collective/cyclic with CA_LIN_SERVO disabled and observed poor alignment of disconnected linkage and swash plate.
    Image (5)

  • Commanded max collective/cyclic with CA_LIN_SERVO enabled and observed improvement in alignment between disconnected linkage and swash plate.
    Image (6)

bresch
bresch previously requested changes Nov 19, 2024
Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I just added a couple of comments

@TedObrien
Copy link
Contributor Author

Thanks very much for the comments @bresch. I'll make those changes and let you know once I've built and tested it again.

@TedObrien
Copy link
Contributor Author

@bresch in the requested changes, there was a semi-colon missing and max_servo_throw was being referenced in the same line it was being declared . I've modified this and it builds fine now. I have also tested it on my test setup (skynode v5x) and it behaves as expected.

@TedObrien TedObrien requested a review from bresch November 22, 2024 12:08
@mrpollo
Copy link
Contributor

mrpollo commented Nov 25, 2024

Hey @TedObrien thanks for the PR! One of the tests caught what appears to be an error here https://github.com/PX4/PX4-Autopilot/actions/runs/12006914552/job/33466430278?pr=23961#step:6:9100

@TedObrien
Copy link
Contributor Author

Hi @mrpollo, sorry about that. I'm currently stumped as to why it's failing at that line, and only on Ubuntu 24.04, but have recreated the error. I'll try to work out why and request a review once it's sorted. Cheers!

@mrpollo
Copy link
Contributor

mrpollo commented Nov 27, 2024

Hi @mrpollo, sorry about that. I'm currently stumped as to why it's failing at that line, and only on Ubuntu 24.04, but have recreated the error. I'll try to work out why and request a review once it's sorted. Cheers!

It's due to the newer GCC / CMake combo with updated warnings. We are moving to enforce those very strictly.

@bresch
Copy link
Member

bresch commented Dec 6, 2024

@TedObrien Instead of having a parameter to enable the feature and one to specify the throw, could we just default the throw to -1 or 0 and only enable the feature if the throw is >0?

@MaEtUgR Do you have other comments on this?

@TedObrien
Copy link
Contributor Author

Hi @bresch, sorry for the delay in getting back to you. That makes sense to me. I'll try and be explicit in the parameter description that setting the throw > 0 enables the linearization feature also. I could see someone thinking it needs to be set as part of a standard swash-plate set up otherwise. The two new parameters can currently be changed within the actuators tab. Do you think I should remove it, so the new throw parameter can only be accessed via the parameter list to avoid potential confusion?

@TedObrien TedObrien requested a review from bresch January 21, 2025 09:48
@MaEtUgR
Copy link
Member

MaEtUgR commented Feb 20, 2025

Thank you @TedObrien for the contribution! Sorry that it took so long but I finally went through in detail.
I rebased your commits on the latest main branch solving some conflicts with the rpm control parameter descriptions. I added a commit with some minor wording and ordering suggestions. I didn't have the access rights to push to your remote even though that usually works when you open a public pull request if you don't manually inhibit. So I pushed that branch to the PX4 repository here: https://github.com/PX4/PX4-Autopilot/compare/pr-linearize_swashplate_servos

I suggest you take it over and/or adjust to your liking while doing so such that we keep the same pull request.
I have one last question before we can finally merge:

@TedObrien TedObrien force-pushed the pr-linearize_swashplate_servos branch 2 times, most recently from 1e130d7 to 05851a8 Compare February 24, 2025 11:40
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following up

@MaEtUgR MaEtUgR dismissed bresch’s stale review February 24, 2025 12:16

AFAIK Mathieu was waiting for me to have a look as well.

@MaEtUgR MaEtUgR merged commit 35d96d5 into PX4:main Feb 24, 2025
58 of 60 checks passed
@farhangnaderi farhangnaderi moved this from Todo to Done in PX4 v1.17 Release Oct 10, 2025
mrpollo pushed a commit that referenced this pull request Nov 24, 2025
…es to prevent binding (#23961)

* control_allocator: Added linearization feature for heli swashplates to help prevent servo binding

* Apply suggestions from code review

Co-authored-by: Mathieu Bresciani <[email protected]>

* update description of CA_LIN_SERVO parameter

* update variable name

* add missing semi-colon

* fix variable referenced before assignment

* add missing indentation

Co-authored-by: Mathieu Bresciani <[email protected]>

* removed param unnecessary param

* removed whitespace

* remove CA_LIN_SERVO and enable feature if CA_MAX_SERVO_THROW > 0 plus Update param description.

* remove CA_MAX_SVO_THROW from actuators tab to avoid confusion during standard swashplate setup.

* added comment and fixed spelling mistake

* fix spelling mistake

* fix formatting

* reduce CA_MAX_SVO_THROW short description length to stop test failure

* ActuatorEffectivenessHelicopter: clarfification suggestions for servo linearization feature

* remove NAN check.

---------

Co-authored-by: Mathieu Bresciani <[email protected]>
Co-authored-by: Matthias Grob <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants