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
Plane: Add ability to run aero scripts from any mode #19811
Conversation
I think any mode is a bad idea. I would prefer to add support for guided only. The script can then switch to guided mode, do its stuff, and then switch back to your original mode. |
I do want to make this possible in all modes that use the fixed wing rate controllers (but not Q modes). What I'd like to see is an API that enables this feature explicitly for the current mode. Something like this:
this would enable the feature only for the mode specified, and it would be disabled again as soon as you change modes, so the script would have to enable it again. |
I really don't like the idea of breaking the rules on manual modes. In master if your in a manual mode you have control. The mode the vehicle is in tells the user what they can expect the vehicle do when they give inputs. With this change the vehicle can do whatever it likes in whatever mode and the user has no way to tell when scripting is taking control. My preferred method would be the script looking for the user to switch into guided mode. The script then does its stuff and puts the vehicle back into the last mode when its done. Second best would be the script looking for a aux switch, it then switches into guided itself, does its stuff and puts the mode back. As implemented this breaks the basic assumptions of what flight modes can do. Scripting should absolutely be allowed to do whatever it likes in guided mode, but unleashing it on all modes is asking for trouble. If the script author wants that behaviour they can switch modes from the script, we should not bake it into the API. I see scripting as another forum of external control, just like a companion computer, I'm sure you would not suggest we allow "fly to here" from the GCS manual mode. I do not see any advantage to allowing this in any mode vs switching to guided for a bit. Adding per mode enable bindings makes it more complex and costs more flash. |
d0954f4
to
ed49a60
Compare
added the enable as requested....new lua without having to use mode checking for mode changes below: |
@Hwurzburg thanks Henry for this implementation, I find it very useful to be able to run scripts from any mode, it would have been nice to be able to do it in MANUAL too, so the user who uses them will not be naive, this would be useful for those who use Ardupilot as a stunt aid but usually fly in MANUAL. |
fyi, test script only holds heading not track |
ed49a60
to
4eea650
Compare
4eea650
to
e5c462b
Compare
e7d98a2
to
0f94379
Compare
Updated C++ and added scripts for tricks on a switch....this provides a modular approach to having switch activated aerobatics tricks...arbitrarily limited selection range to 10 tricks max on the selection channel figuring one could not remember which is which with more than that...provided separate Aerobatics examples directories with README...tested extensively in SITL....can co-exist with AUTO nav_script_time missions....can easily change which modes allow scripting override... will test in a real vehicle as soon as time permits.... |
2238fdb
to
bb79526
Compare
flight tested and video updated https://youtu.be/XD81TRRgDUM |
bb79526
to
9577bca
Compare
I'm very happy to see this functionality, and I think the decision on what modes this should be done in should be made in the lua script, not in the C++ code. Once we have the ability to create new modes inside lua scripts I think we'll move to that, and create modes suitable for the action being performed. |
9577bca
to
95f8576
Compare
Extends scripting nav_scripting aerobatics rate control to any mode. Current time stamped in nav_scripting structure and checked by attitude and servo(throttle) modules for age to prevent script death from retaining control.
Below is an example of a knife_edge lua script routine with angle programmed by SCR_USER5 and duration by SCR_USER6....SCR_USER1-4 should be set as 2,1,80,20 for height and pitch pid values as in plane_aerobatics.lua example.....set an rc channel to 300 to start and stop knife_edge....mode changes will exit....script stop will exit (25ms keep alive time...ie for 10ms scripts)...arming protection...( I am sure my LUA style is non-optimal...but it works to test this)
caution , do not activate trick while armed and on the ground....same as if you tried to do that manually....you wont be happy
knife_edge.lua.zip
tested along side the previous plane_aerobatics example to test co-existence...no problem (except rolling circles since USER5/6 have be co-opted for the knife-edge....easily fixed by using new local params, but I was lazy since this was just for testing)
open issue: exiting the knife-edge, the yaw jumps ~20 degrees in stabilized modes...haven't been able to figure out what I need to do in the script to fix that....resetting yaw I in C++ code does not fix...