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

Commander: start pulling arming related parts into separate folder #13224

Merged
merged 5 commits into from
Nov 5, 2019

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Oct 18, 2019

Describe problem solved by this pull request
Goal: The user knows in advance if he'll be able to arm.

Describe your solution
First step: Pull things that relate to arming logic into the folder Arming and make sure to have a clear interface for all checks that happen before arming can take place

Describe possible alternatives
Hack my way through commander trying to run important bits and pieces in a random and unmaintainable way.

Test data / coverage
Only draft yet but I'm constantly testing every single step by using the existing unit-sitl tests and my own sitl testing. Hopefully I try to get to the point where efficient gtest unit testing is possible.

Additional Context
#7055

@jlecoeur
Copy link
Contributor

Goal: The user knows in advance if he'll be able to arm.

That is a revolution

@ndepal
Copy link
Contributor

ndepal commented Oct 18, 2019

Related? #13025 #12989

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 18, 2019

@ndepal Definitely related. Thanks for referencing. I can rebase either way no matter which one goes first.

@MaEtUgR MaEtUgR force-pushed the commander-arming branch 2 times, most recently from 2c64c0d to 53f7fa7 Compare October 18, 2019 11:05
@dagar
Copy link
Member

dagar commented Oct 18, 2019

Glad to see some movement here!

One thing I'd like to get sorted out is the line between preflight, prearm, and checks that can run continuously.

I'm wondering if we can get to the point where nearly everything results in status flags and have the arming machine act on that data rather than actually executing the checks.

The other missing piece is fitting this into mavlink.

}

/* ---- BARO ---- */
if (checkSensors) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps not what you want to tackle here, but I'm wondering if all this sensors code should be owned by the sensors module. Then a higher level sensors status would be published for commander to act on.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 19, 2019

@dagar Thanks for looking over it and your input! I try to share as many thoughts as possible. I want to first get it all in a less interdependent and hence more maintainable adaptable state.

I'd like to get sorted out is the line between preflight, prearm

My intentions after talking to a bunch of people about this: Preflight checks are the ones that determine if you can fly or not (user-focused), the pre arm checks (I left the name for now but it might not make sense anymore) are just one kind of preflight check since they prevent arming and hence flying.

and checks that can run continuously.
I'm wondering if we can get to the point where nearly everything results in status flags and have the arming machine act on that data rather than actually executing the checks.

Exactly the intention and why I started refactoring this. The goal is that there is no check that was not done before giving an arm command/input, no surprises to the user anymore. The arming state machine itself just knows if there's green light.

The other missing piece is fitting this into mavlink.

I agree, first I have to leave the strings but have them all optional (to not spam), then I plan to fill the flags at the beginning of https://mavlink.io/en/messages/common.html#SYS_STATUS as in-between solution and eventually we'll have the events interface taking care of delivering the status to the UI.

Perhaps not what you want to tackle here, but I'm wondering if all this sensors code should be owned by the sensors module. Then a higher level sensors status would be published for commander to act on.

I thought exactly the same let's go in steps.

My currently intended steps:

  • pull all checks together into PreFlightCheck into as small of an include and symbol scope as possible, dependencies get clear
  • make sure checks are callable without output and with one single call covering all desired checks
  • refactor code of checks, I saw they add up to >1200 lines of code which is almost not possible without duplication and there are better places for certain checks e.g. where the data of interest is produced or consumed

This PR should only do the first point otherwise it gets too big of a change.

@MaEtUgR MaEtUgR marked this pull request as ready for review October 20, 2019 07:42
@MaEtUgR MaEtUgR force-pushed the commander-arming branch 4 times, most recently from c25c6ba to 3ef2a84 Compare October 22, 2019 20:56
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 22, 2019

@dagar @bresch I rebased on master with the only relatively trivial conflict of these lines:
549fb0d#diff-a2bcb238e25d8a97ab2aee48f54dbc48R497-R513

It would be nice to get this in soon. I can rebase other conflicting prs easily.

@julianoes julianoes self-requested a review October 25, 2019 13:01
@dagar dagar requested a review from a team October 27, 2019 14:41
@dannyfpv
Copy link

dannyfpv commented Oct 29, 2019

Tested on Pixhawk4 v5 f-450 & Pixhawk v4pro f-450
Preflight fail: heading estimate not stable, unable to arm.

change to master firmware no issues

Screen Shot 2019-10-29 at 10 59 57 AM

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 30, 2019

Preflight fail: heading estimate not stable, unable to arm.

This was a bug introduced with #13036 and fixed in #13261 and #13267. I was unlucky to have master at the exact time it was broken as my base. I'll rebase and this will fix the problem.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 30, 2019

Thanks for the reviews and comments also from @bkueng.
I rebased, removed the funtional commit since like @dagar mentioned they don't really help by themselfes yet and addressed all the comments about includes with respect to folders in the last commit.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Oct 31, 2019

I'm assuming CI problems are now unrelated. It's ready for review check.

@dagar
Copy link
Member

dagar commented Nov 4, 2019

Looks good to me. Can you rebase?

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 5, 2019

Rebased
The conflict was just these four space characters: a475d71#diff-eb94b84d1c6e5b1530f8ad834cef9b22R3761

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 5, 2019

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 5, 2019

Upon request of @dagar I did a quick test on a real vehicle with a pixhawk 4 mini. I can normally arm and fly when all checks pass. When the vehicle is upside down I can't arm because of the failing roll check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants