-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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: move more static variables to class #13613
Conversation
The next little incremental step that would help is if we transition (or kill) the command line helpers to vehicle commands (calibrate, arm, disarm, mode, etc). |
Future work
|
Makes sense, @julianoes also brought that up today. What about the acks? For the developer it's nice to have a response but e.g. for the calibration state command it's safety critical.
I wouldn't worry about this one too much. I want to run the checks periodically and the
I would say so. The check if it's possible has to be lightweight and when it's actually executed blockage if any is likely not a huge issue anymore.
The command executing RC driver should directly acknowledge instead of the commander. Very good inputs, thanks!! |
2e7562d
to
494fe6a
Compare
We can update the vehicle command helper to send the command, then poll |
b09ca4c
to
e43439b
Compare
|
e43439b
to
57ee7f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through all the changes in great detail. Overall it looks like a very nice improvement of readability, scopes, initialization and parameter handling.
I report the most significant comments that came to my mind the rest are just ideas for further improvement that I can follow up with.
Thanks for the thorough review. I have a few more commits coming that get everything except vehicle_status, vehicle_status_flags, and actuator_armed into the class. To get the rest under control (and kill/move the commander low priority loop) what we're missing is a mechanism to specifically enter |
Tested on PixRacer V4:Flight Card 1 Modes Tested: Procedure: Logs: https://review.px4.io/plot_app?log=eddc7cef-5af6-40af-b39e-eccaa4d5bed4 Flight Card 2 Modes Tested Procedure Armed form QGC. Logs: https://review.px4.io/plot_app?log=7c08c14f-a8b1-4a77-9996-c52f75517a0d Flight Card 3 Procedure Logs: https://review.px4.io/plot_app?log=f1d090ec-c406-49ff-b0e8-14ba29b16f94 Flight Card 4 Logs: https://review.px4.io/plot_app?log=faf21f96-c658-4cd0-9bd0-3219d9d6346c |
Tested on Pixhawk 4 v5 f-450 Modes Tested: Procedure: Log: Flight Card 2 Modes Tested Procedure Armed form QGC. Logs: Flight Card 3 Procedure Logs: https://review.px4.io/plot_app?log=d26ed441-b2d9-4b59-aaa4-4c13b56c483a Flight Card 4 log: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better!
if (TRANSITION_DENIED == arm_disarm(false, true, &mavlink_log_pub, "command line")) { | ||
PX4_ERR("rejected disarm"); | ||
} | ||
send_vehicle_command(vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM, 0.f, 0.f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that's safer!
|
||
return 0; | ||
} | ||
|
||
if (!strcmp(argv[1], "takeoff")) { | ||
// switch to takeoff mode and arm | ||
send_vehicle_command(vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF); | ||
send_vehicle_command(vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM, 1.f, 0.f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hang on, first you need to arm and then send a takeoff, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's indeed how it was done before: https://github.com/PX4/Firmware/blob/fbcc6a96bc89d14806126c14d70b9a0585dcdb6d/src/modules/commander/Commander.cpp#L412-L413
but I think QGC also switches to takeoff first and then arms.
If you'd ask me a takeoff command should do whatever is necassary to take off...
if (shutdown_if_allowed()) { | ||
bool shutdown_ret_val = PX4_ERROR; | ||
|
||
if (((int)(cmd.param1)) == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think we should be using roundf
everywhere for these params.
bool StateMachineHelperTest::run_tests() | ||
{ | ||
ut_run_test(armingStateTransitionTest); | ||
ut_run_test(mainStateTransitionTest); | ||
ut_run_test(isSafeTest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more isSafe
? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, turns out to be useless 😄
Co-Authored-By: Matthias Grob <[email protected]>
In general you should feel free to commit the ones you're sure about. At this point let's try to get the current state merged with most, but not all suggestions applied and keep going with smaller followup PRs. |
I'm hitting issues with the designated initializers, which don't seem to actually be a part of c++11. |
Co-Authored-By: Matthias Grob <[email protected]>
9d82e9e
to
abb7539
Compare
@PX4/testflights could we please get another round of testing on this one? @julianoes @MaEtUgR if you can, please give this PR a quick run through with anything you normally use (eg the command line helpers for takeoff, arm, etc). There's a lot more change in this PR than originally intended, including areas with no code coverage. |
Tested on NXP FMUK66 v3Modes Tested
Procedure Notes Logs Modes Tested
Procedure Notes Logs Modes Tested
Procedure Notes Logs |
Tested on PixRacer V4:Maximum wind 10.2 m/sFlight Card 1 Modes Tested: Procedure: Logs: https://review.px4.io/plot_app?log=17f640c2-9418-47bc-8d83-85edcd9f656c Flight Card 2 Modes Tested Procedure Armed form QGC. Logs: https://review.px4.io/plot_app?log=b0f1f872-fc9e-41ee-89e3-4e146862efc7 Flight Card 3 Procedure |
Tested on Pixhawk 4 v5 f450 log: |
Thanks everyone! I'm going to merge this so we can keep going. Please pay particular attention to any potential commander regressions. We still have quite a lot to do before this module is under control. |
This pushes the flash slightly over the v2 limit. Looks like I'll need to bring it something like #12601 first. |
#13596 might give you some space |
Regression from #13613. VEHICLE_CMD_COMPONENT_ARM_DISARM from CLI would enter the ARMING_STATE_IN_AIR_RESTORE logic. This was never intended for disarming (and leads to state machine transition failures), and IMO it is also not intended for commands from CLI.
Regression from #13613. VEHICLE_CMD_COMPONENT_ARM_DISARM from CLI would enter the ARMING_STATE_IN_AIR_RESTORE logic. This was never intended for disarming (and leads to state machine transition failures), and IMO it is also not intended for commands from CLI.
No description provided.