Hi,
First post here. Congrats to the team on a wonderful piece of firmware/software
Is it possible to add STABILIZE or FBWA modes to the available functions under the Plane functionality in a near-future build please? I am using the new BUTTON functions to change modes on the flight vehicle during flight, controlled hardware external to the FC (I am using a Mavtek F765-WING). I have been able to use the MANUAL function successfully but there are no stabilizing functions available through the button functionality as it stands, so selecting MANUAL is a one-way street currently. Note that there are many more modes available under Copter, and some seem to be just masked out for Plane.
As a bit of a background I am using the FC to control the flight of a high-power rocket, stabilizing the attitude and keeping it flying vertical. I have been able to get all the functionality I need out of the latest 4.1.0 Plane, except for being able to trigger stabilized mode via button.
I am curious as to why some of the flight modes were disabled in PLANE in the first place. Any comments on that from anyone as well please?
I am not using any radios at all. Just the default failsafe inputs. The rocket will need to perform autonomously once launched.
FYI I do have a solution which uses a couple of PCBs. One generates PWM signals based on switch inputs, the other converts the PWMs to SBUS radio stream. This does indeed work, but if I can use the button functionality that is (mostly) implemented in Ardupilot then that is two PCBs I don’t need to use .
I have been working on this for a while and adding the extra modes to the auxiliary function would be a nice elegant solution.
Could this be done perhaps by using a LUA script? Does that capability exist in Plane 4.10? Someone chime in if you can point me in the right direction please
I am going to admit I am more of a hardware person (electronic engineer) than firmware. I suspect I could recompile to add the functionality I need to the BUTTON functions, but if there is a way of doing this out of the box would be good.
BTW, currently working towards flight hardware:
FC mounted on servo assembly
I don’t want do spoil your project. I still have some concerns about the choice of the flight controller for the project.
The inertial sensors in the F765-Wing (shown in the picture above) are specified for up to 16G maximum acceleration. This could be to low for the application in a
Form my understanding you will expect some clipping on the accelero-meters. It will make the autopilot useless for your application.
Hi Sascha. Thanks for your concern. It is not a problem in reality. I can choose motors for the flights that keep the acceleration under the specifications for the accelerometers and gyros. I have even flown an earlier version of this (on a commercial fixed-wing autopilot) but locked out any control during boost when any severe accelerations would peg the sensors. That kept things working and provided control during the coast phase of the flight. Keeping fins at neutral during boost also has the added safety benefit of putting distance between the rocket and spectators before the control is engaged. Anything exciting will happen a few thousand feet away, up in the air, if it does go sub-optimal.
FYI there can be a lot of good flights with motors providing around 10G of acceleration, or thereabouts. I am Level 3 certified for rocketry have quite a bit of experience with large rockets. There was one project I worked on that had an O25000 motor. That is 25000 newtons of thrust. I have a rough idea what I am talking about
With LUA scripts flight modes can be queried and also switched. But I am not sure at the moment if this already works with the current beta firmware or if the dev firmware is required. And check if your flight controller is LUA scripting capable at all.
Thanks Rolf. I have the Matek F765-WING so it should be capable of LUA. Will check it out. I am using development firmware currently. I don’t think the beta has the button functionality yet.
Any idea where I might find a good quick introduction to LUA and how to implement it? Otherwise I will just google.
I still think having this functionality built into plane, as it already is in copter, would be good as it would obviate the need for LUA scripting at all in this case. Much more elegant.
OK. I have blundered along through the LUA landscape and come up with this script:
-- This script is to set FC mode to STABILIZE when the button is pushed
-- SRC 12JAN2020
local button_number = 2 -- the button number we want to read, as defined in AP_Button
local button_active_state = true -- the 'pressed' state of the button
local last_button_state
-- flight mode numbers for Plane
local MODE_STAB = 2
--local MODE_MANU = 0
function switchstabon()
local button_new_state = button:get_button_state(button_number) == button_active_state
if button_new_state ~= last_button_state then
last_button_state = button_new_state -- update latched state for edge detection
if button_new_state then
gcs:send_text(0, "LUA: Button 2 Pressed")
vehicle:set_mode(MODE_STAB)
else
gcs:send_text(0, "LUA: Button Released") -- switching back to manual is otherwise accomplished
end
end
return switchstabon, 20 -- rescheduled loop every 20ms
end
return switchstabon() -- run immediately before starting to reschedule
I don’t have any hardware to try this on currently. If somebody spots any syntax or logical errors please let me know
Another alternative for this switching is to use the BUTTON functions to execute a script maybe. I can see that under RCn_OPTION there is the option for these to trigger scripts (300-307 for scripting1 to scripting8). Does anyone know how I link a script to the RCn_OPTION function? I assume it is just a script filename it executes but I have not been able to find what it might be in the documentation.
Having the ability to switch to stabilize with a straight button function in Plane would be much better. Can I add this as a feature request, please, developers?
As far as I understand, you run the script with a certain repetition rate. Within the script then the queries must take place. I think the Ardupilot sample scripts are very helpful
Thanks again Rolf. Given that there are numbers for the functions “scripting1” etc in the RCn_OPTIONS (have a look in the mission planner parameter tables) parameters I really suspect there is a way of executing a script on that command, rather than have one polling at regular intervals. I have done plenty of programming over the years (used to be a software engineer for six years) so I think I can smell a way through this, but I don’t have the details yet.
I will go through the rest of the example scripts, but I have yet to find anything relating to that script triggering function. If anyone else knows anything on this mechanism, please chime in
It is currently not possible to command a script to run via an RCn_OPTION. The infrastructure to handle that gracefully has been briefly discussed, but I don’t know of a pull request though. The best we currently have is to include something such as if rc:get_pwm(x)... and have the script run at about 10 Hz.
Thanks Charlie. So what I thought might have been an option is yet to be implemented. It seems a lot of functionality I am wanting to use is “late-breaking news” in this software! Luckily I held off till now where I get to use these much higher-power FCs and increased software functionality.
I did find a way of doing what I need, looking at the example lua scripts (RCIN_test in this case) as suggested by Rolf. That gives me a second way of instantiating the functionality. As it stands I think the script I posted earlier in the thread should work and will be likely what I will start out with once I get the hardware back together.
UPDATE: I have just loaded the script I wrote upthread into the FC. Worked first shot
Thanks to all who have helped along the way.
I still have a feature request for the function of triggering stabilize mode added to Plane (it is in Copter already) so I don’t have to use LUA scripts, but I am running ok for now.
In case you wanted to see what one of these systems looks like, ready to fly, here is a pic of the earlier system: