Is it possible that the autotune flight mode I can select as one of my 6 flight modes is not the same as the autotune discussed here?
That AutoTune flight mode is really only meant to be displayed with ArduPlane. In ArduPlane it is a flight mode, and in ArduCopter it is a function that can be invoked while in AltHold.
I'm not sure you can invoke it from the ground station, my understanding is that ArduCopter's AutoTune can only be invoked via Ch7/8 :(
Sorry! If someone has different experience I'd love to hear it.
I took a look at the code in git. It looks to me like you are correct for the 3.1 branch. But it also looks like 3.2 may already support autotune as a flight mode, no channel 7/8 required. I was prepared to code it up myself because this seems to me a useful feature, but it looks like I won't have to. Someone please correct me if I am wrong. I think I'll try the latest beta release.
Yes, you're right it's been turned into a flight mode in AC3.2. There's a slight difference in how it's started in that when called from ch7/ch8 it uses autotune_start() and autotune_stop() while if called from ch5 flight mode switch it uses autotune_init().
There's some extra code in the autotune_start() function (i.e. ch7/ch8) which backs up the current gains so I think it won't work well if it's triggered from ch5.
This is all more by accident rather than a conscious decision though. AC3.2 had so many other changes we didn't put any effort into making it work from ch5. It should be possible though.
I had another brief look at the code. It seems to be simple enough to rework it to make directly entering autotune flight mode via sw5 work about the same as via sw6/7 Switching directly from althold to autotune should be the same as selecting it via sw6/7 and switching back to althold should be the same as sw6/7 off so I think the same state machine can be used for restores, etc. But I'm not yet familiar with the code base or this project so a few questions please:
My initial thought is that changing the call to autotune_init() in set_mode() to autotune_start() and replacing the call to set_mode() in autotune_start() with a direct call to autotune_init() and reworking the AUX_SWITCH_AUTOTUNE case in do_aux_switch_function() to directly change modes via set_mode() may be all that is required. Am I on a reasonable path? Sw7/8 activation then seems redundant, should it be deprecated later (or even now)?
If I work up a changeset that works for me, would you be interested in a pull request on github? Even if I can't test sw7/8?
Where is the best place to discuss code details prior to a pull request?
Any reason something like this shouldn't go into 3.2?
Please don't let this discussion stop you from just fixing this yourself if you have time! It will take me a while to get setup for builds and test some code.
I did make similar changes I described above which makes autotune work from ch 5 and it worked well for me. Should I submit a pull request? Which branch should it be against?
I did submit a pull request about a week ago but there has been no comment or merge yet. If you have time, can you take a look at it and comment to let me know if it looks OK? I think a few others would appreciate being able to autotune via ch5.
Randy is it possible to have some flight modes on channel 6 ? like simple and auto or camera trigger rather than all those params we will not likely use ?
Replies
That AutoTune flight mode is really only meant to be displayed with ArduPlane. In ArduPlane it is a flight mode, and in ArduCopter it is a function that can be invoked while in AltHold.
I'm not sure you can invoke it from the ground station, my understanding is that ArduCopter's AutoTune can only be invoked via Ch7/8 :(
Sorry! If someone has different experience I'd love to hear it.
I took a look at the code in git. It looks to me like you are correct for the 3.1 branch. But it also looks like 3.2 may already support autotune as a flight mode, no channel 7/8 required. I was prepared to code it up myself because this seems to me a useful feature, but it looks like I won't have to. Someone please correct me if I am wrong. I think I'll try the latest beta release.
Thanks!
--Brad
Brad,
Yes, you're right it's been turned into a flight mode in AC3.2. There's a slight difference in how it's started in that when called from ch7/ch8 it uses autotune_start() and autotune_stop() while if called from ch5 flight mode switch it uses autotune_init().
There's some extra code in the autotune_start() function (i.e. ch7/ch8) which backs up the current gains so I think it won't work well if it's triggered from ch5.
This is all more by accident rather than a conscious decision though. AC3.2 had so many other changes we didn't put any effort into making it work from ch5. It should be possible though.
Randy,
Thanks for the clarification!
I had another brief look at the code. It seems to be simple enough to rework it to make directly entering autotune flight mode via sw5 work about the same as via sw6/7 Switching directly from althold to autotune should be the same as selecting it via sw6/7 and switching back to althold should be the same as sw6/7 off so I think the same state machine can be used for restores, etc. But I'm not yet familiar with the code base or this project so a few questions please:
My initial thought is that changing the call to autotune_init() in set_mode() to autotune_start() and replacing the call to set_mode() in autotune_start() with a direct call to autotune_init() and reworking the AUX_SWITCH_AUTOTUNE case in do_aux_switch_function() to directly change modes via set_mode() may be all that is required. Am I on a reasonable path? Sw7/8 activation then seems redundant, should it be deprecated later (or even now)?
If I work up a changeset that works for me, would you be interested in a pull request on github? Even if I can't test sw7/8?
Where is the best place to discuss code details prior to a pull request?
Any reason something like this shouldn't go into 3.2?
Please don't let this discussion stop you from just fixing this yourself if you have time! It will take me a while to get setup for builds and test some code.
Thanks!
---Brad
Randy,
I did make similar changes I described above which makes autotune work from ch 5 and it worked well for me. Should I submit a pull request? Which branch should it be against?
--Brad
Brad,
A pull request would be great. Against master please!
Randy,
I did submit a pull request about a week ago but there has been no comment or merge yet. If you have time, can you take a look at it and comment to let me know if it looks OK? I think a few others would appreciate being able to autotune via ch5.
Thanks!
Ha! Cool there you go... I never even looked! :)
Randy is it possible to have some flight modes on channel 6 ? like simple and auto or camera trigger rather than all those params we will not likely use ?
Regards Reuben
Reuben,
At this moment it's not possible but it's on the to-do list (with 160+ other issues)...