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

FlightTasks: Stick library for auto land #15325

Merged
merged 5 commits into from
Jul 16, 2020
Merged

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Jul 14, 2020

Describe problem solved by this pull request
This is a follow-up to #15324 but I didn't want to overload the original pr.
The auto task uses the sticks since #12220 to adjust the land speed during final descend. It did so in a FlightTaskManual independent way duplicating the functionality.

Describe your solution

  • Now it can reuse the Sticks library from FlightTasks: Move stick handling into library, remove FlightTaskManual #15324
  • For the reusability of the things I copied into the Sticks library I had to untangle the landing gear logic since you don't want to override the landing gear automatically set by the land mode using your RC.
  • As discussed with @jkflying the stick has a bit more authority to actual stop during slow down and not just slow down vertical movement.

Describe possible alternatives
A clear and concise description of alternative solutions or features you've considered.

Test data / coverage
I tested it in SITL but I did not have a landing gear in my tests so please review that logic thoroughly.

@MaEtUgR MaEtUgR requested a review from bresch July 14, 2020 13:41
@MaEtUgR MaEtUgR self-assigned this Jul 14, 2020
jkflying
jkflying previously approved these changes Jul 14, 2020
Copy link
Contributor

@jkflying jkflying left a comment

Choose a reason for hiding this comment

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

LGTM.

Just from a general design perspective, it worries me a little that we aren't evaluating explicitly whether the sticks are valid when we are using them. Instead we implicitly expect them to internally timeout, and give a 0 response. I made a suggestion which goes towards this pattern, while I agree it doesn't change anything right now, it's the kind of defensive programming which prevents future bugs. But this is more of a general pattern, and this isn't necessarily the best example.

if (speed < land_speed * 0.5f) {
speed = land_speed * 0.5f;
// user input assisted land speed
if (_param_mpc_land_rc_help.get()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't modify if the sticks aren't good

Suggested change
if (_param_mpc_land_rc_help.get()) {
if (_param_mpc_land_rc_help.get() && _sticks.evaluateSticks(_time_stamp_current)) {

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually want to do exactly this. I must have postponed it because of the implementation order. We should definitely add it, thanks for pointing out!

Copy link
Member Author

Choose a reason for hiding this comment

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

I added this to the last commit (the rest is unchanged).

Base automatically changed from stick-library to master July 14, 2020 16:07
@jkflying jkflying dismissed their stale review July 14, 2020 16:07

The base branch was changed.

@MaEtUgR MaEtUgR force-pushed the stick-library-for-auto-land branch from 9d90c9a to 0dbffac Compare July 15, 2020 07:29
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Jul 15, 2020

Base automatically changed
The base branch was changed

GitHub apparently changed the base to master because the original base-branch was merged but it didn't understand that rebasing without conflict is possible so I did exactly that manually. ✔️

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.

I like it

// user input assisted land speed
if (_param_mpc_land_rc_help.get()) {
_sticks.evaluateSticks(_time_stamp_current);
speed = land_speed + _sticks.getPositionExpo()(2) * land_speed;
Copy link
Member

Choose a reason for hiding this comment

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

If the behavioral change is intended, don't forget to update the description of the parameter MPC_LAND_RC_HELP

Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized that the change makes is potentially quite a bit slower depending on the configuration. Let's preserve the possibilities.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if we really want to enable such a high downwards speed close to ground. I refactored the implementation to be more clear and adjusted the parameter description. It's the last commit (the rest is unchanged).

bresch
bresch previously approved these changes Jul 15, 2020
@@ -53,7 +53,7 @@ class Sticks : public ModuleParams
Sticks(ModuleParams *parent);
~Sticks() = default;

void evaluateSticks(hrt_abstime now); ///< checks and sets stick inputs
bool evaluateSticks(hrt_abstime now); ///< checks and sets stick inputs
Copy link
Member

Choose a reason for hiding this comment

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

We could also rename it checkAndSetStickInputs and get rid of the comment.... :D

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that also to the other function, see last commit. Also rebased on master since CI is succeeding again. Sadly I lost the review and am not allowed anymore to override and merge 🤷

jkflying
jkflying previously approved these changes Jul 15, 2020
@MaEtUgR MaEtUgR dismissed stale reviews from jkflying and bresch via 30855c4 July 16, 2020 13:44
@MaEtUgR MaEtUgR force-pushed the stick-library-for-auto-land branch from 7b9376d to 30855c4 Compare July 16, 2020 13:44
@jkflying jkflying merged commit 413cf8b into master Jul 16, 2020
@jkflying jkflying deleted the stick-library-for-auto-land branch July 16, 2020 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants