AP FlightMode in upcoming 2.4

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
jaames74
Posts: 22
Joined: Tue Jun 12, 2012 5:56 pm

AP FlightMode in upcoming 2.4

Post by jaames74 »

Hello, can someone please explain why the following feature is disabled in latest devs??

Code: Select all

/************************        AP FlightMode        **********************************/
/*** FUNCTIONALITY TEMPORARY REMOVED ***/
/* Temporarily Disables GPS_HOLD_MODE to be able to make it possible to adjust the Hold-position when moving the sticks.*/
//#define AP_MODE 40  // Create a deadspan for GPS.


so, if i understand correctly, upcoming 2.4 will NOT support a "loiter" functionality (gps-hold repositioning using sticks). :o

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: AP FlightMode in upcoming 2.4

Post by EOSBandi »

Yepp, that is the truth... however you can easily implement it with mixes on good remote such a Er9X or Taranis...

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

I think it should be as a option in PH mode.
Not everyone have advanced radios or skills to program them correctly.

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

This should be a cleaner way to implement it.
No messing with anything else than resetting the coordinates.

Code: Select all

        if (f.GPS_mode == GPS_MODE_HOLD && abs(rcCommand[ROLL]) > AP_MODE || abs(rcCommand[PITCH]) > AP_MODE) { 
              GPS_set_next_wp(&GPS_coord[LAT], &GPS_coord[LON],&GPS_coord[LAT], & GPS_coord[LON]); }

I will insert it in the Fixedwing dev where it really makes sense.
Last edited by PatrikE on Wed Mar 25, 2015 9:27 am, edited 2 times in total.

jaames74
Posts: 22
Joined: Tue Jun 12, 2012 5:56 pm

Re: AP FlightMode in upcoming 2.4

Post by jaames74 »

Guys,
i do not understand how this is related with radio mixes instead of code change. Anyway, i think "AP FlightMode" is a "must" feature for aerial photography....am i the only one thinking of this??

Patrik, can u be more specific?? Where to restore your code snippet?? Why it was excluded by EOS after his NAV version?? (is there a conflict between AP Aflightmode and NAvigation??)

mrsylvestre
Posts: 3
Joined: Thu Aug 16, 2012 9:30 am

Re: AP FlightMode in upcoming 2.4

Post by mrsylvestre »

I assume that on, say, an openTX compatible transmitter, one could build a mix such as:

if pitch or roll stick deflection > threshold, switch an AUX channel back from GPS hold to horizon mode

I am considering trying to set such a mix on my Taranis as an exercise, but if anyone already did this or if there is a better way, I am all for enlightenment :)

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

jaames74 wrote:Patrik, can u be more specific?? Where to restore your code snippet?? Why it was excluded by EOS after his NAV version?? (is there a conflict between AP Aflightmode and NAvigation??)


In released Version 2.4
https://code.google.com/p/multiwii/
After line 1145 in multiwii.cpp

ln:1144 if (f.GPS_FIX) {
ln:1145 if (GPS_numSat >5 ) {

Insert this

Code: Select all

     #if defined(AP_MODE)
            if (f.GPS_mode == GPS_MODE_HOLD &&(abs(rcCommand[ROLL])> AP_MODE || abs(rcCommand[PITCH]) > AP_MODE)) {                             //Position hold has priority over mission execution  //But has less priority than RTH
              GPS_set_next_wp(&GPS_coord[LAT], &GPS_coord[LON],&GPS_coord[LAT], & GPS_coord[LON]); // Move HoldPos
            }
          #endif


#define AP_MODE 50 feels good i think.

/edit/
corrected line numbers
Last edited by PatrikE on Tue Mar 24, 2015 9:15 am, edited 3 times in total.

jaames74
Posts: 22
Joined: Tue Jun 12, 2012 5:56 pm

Re: AP FlightMode in upcoming 2.4

Post by jaames74 »

Image

thanks Patrik!!!

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: AP FlightMode in upcoming 2.4

Post by carlonb »

PatrikE wrote:......
In released Version 2.4
https://code.google.com/p/multiwii/
After line 1203 in multiwii.cpp

ln:1202 if (f.GPS_FIX) {
ln:1203 if (GPS_numSat >5 ) {

Insert this

Code: Select all

     #if defined(AP_MODE)
            if (f.GPS_mode == GPS_MODE_HOLD &&(abs(rcCommand[ROLL])> AP_MODE || abs(rcCommand[PITCH]) > AP_MODE)) {                             //Position hold has priority over mission execution  //But has less priority than RTH
              GPS_set_next_wp(&GPS_coord[LAT], &GPS_coord[LON],&GPS_coord[LAT], & GPS_coord[LON]); // Move HoldPos
            }
          #endif


#define AP_MODE 70 feels good i think.

Hi PatrikE, thanks for this.
I downloaded the last MWii 2.4 and seems that your suggested code has to be added after lines 1144,1145 and not after lines 1202,1203. Can you please give me a tip or confirmation?

Someone has already tested it? I will do it asap.

@ Eosbandi: What do you think about this very simple and nice solution by PatrikE ?

Thanks
Carlo

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

Your'e right Carlos...
Thats where it should go.
I was somewhere in the blue and made the change in my modified version and didn't think about it.

After line 1145 is the correct insert point.
But here's a correct file to download and replace the original.
MultiWii_AP_MODE.zip
(16.1 KiB) Downloaded 322 times


And placed in the proper position it don't interfere with the rest of the navigation.

/Patrik
Last edited by PatrikE on Wed Mar 25, 2015 10:23 am, edited 3 times in total.

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: AP FlightMode in upcoming 2.4

Post by carlonb »

Thanks a lot Patrik,
I will give a try soon.
Carlo

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: AP FlightMode in upcoming 2.4

Post by carlonb »

Hi Patrik,
I'm looking at the your mod code in multiwii.cpp file attached in previous post and I saw this:

Code: Select all

if (f.GPS_mode == GPS_MODE_HOLD &&(abs(rcCommand[ROLL])> AP_MODE && abs(rcCommand[PITCH]) > AP_MODE)) {


In your above first example you use || (or) between the ROLL and PITCH compare, I think OR is the correct one instead of && (and).

Cheers
Carlo

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

Your right again.
Or will work better.

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: AP FlightMode in upcoming 2.4

Post by carlonb »

Thanks for the prompt reply Patrik,
Don't worry, I'm not so skilled c coder, this main idea is yours, this is important ;)
Bye

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: AP FlightMode in upcoming 2.4

Post by PatrikE »

Uploaded a corrected file in previos post.
viewtopic.php?f=8&t=6220&p=62446#p62446

Post Reply