True WP navigation development

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
nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

True WP navigation development

Post by nhadrian »

Hi all,

I made this topic to collect all infos related to WP navigation development to one group.

Regarding to discussions in EZ-GUI topic, I have a suggestion on universal WP data handling, I suggest to use a struct for storing WP datas

Code: Select all

  static struct {
      int32_t Lat;               // Lat for WP
      int32_t Lon;               // Lon for WP
      int32_t Alt;               // alt at WP (cm)
      int16_t Heading;           // heading at WP (deg)
      int16_t Vario;             // vario for alt changing (cm/s)
      int8_t  Time;              // time to stay in WP (s)
      int8_t  Uploaded;          // can WP be used or not?
              // 0 - current WP is not yet uploaded, contains only 0          - can't be used
              // 1 - current WP is already updloaded and contains valid datas - can be used
  } WP[16];


Here are the nav flags I suggest:

Code: Select all

  /*** GPS WP datas***/
  // suggested naw flags:
  #define HOME 0
  #define HOLD 1
       // 2-16 - generic WP navigation  */


I suggest also to reset all values when setup():

Code: Select all

  #if GPS
    for(uint8_t i=0;i<=15;i++){
      WP[i].Lat = 0;
      WP[i].Lon = 0;
      WP[i].Alt = 0;
      WP[i].Heading = 0;
      WP[i].Vario = 0;
      WP[i].Time = 0;
      WP[i].Uploaded = 0;
    }
  #endif


On this way, the struct of naw datas is not rigid, can be expanded with further datas in the future without rechecking the complete naw code.
Also, the number of WPs can be increased if neccessary.
_____________________________________
About WP navigation function itself, here is my suggestion:
Three BOX items should be made:
- GPS WP MODE
This mode is for flying through WP-s. Both RTH mode and HOLD mode should ovveride this.
It ALT HOLD is also on, in WP mode it should go to the WP altitude. My primitive alt changing routine could be used for this but with the modification of enable throttle control by stick at the very end of stick travel for emergency situations
- GPS NEXT WP
If checked and aux channel is on this state, copter always go to the next valid WP (the Uploaded item in struct), when reaches the last WP, starts from WP[2] again
- GPS PREV WP
The same as NEXT WP but into the opposite direction

If these would be written once into GUI and Multiwii, that would be much easier to let developers test their ideas in the air bout WP naw!!!
Could anybody write this???

I suggest not to store any values in the EEPROM since than faulty datas could be remain in there (ie from last different place).
For example all WP datas could be uploaded via MSP before take-off, or even in the air via BT or 3DR module. Only a multifunctional MSP_WP part must be written to be able to upload all WP datas step-by-step.

I attached my custom code (NHADRIAN r17 based on official r1349), JUST FOR A SAMPLE OF USING THIS STRUCT!!! DO NOT USE IN THE AIR since just a development sample about my idea!!!!!!

BR
Adrian

PS.: thanks for reading... :)
Attachments
Multiwii_r1349_NHA_r17 _EXP_WP.zip
(166.03 KiB) Downloaded 134 times
Last edited by nhadrian on Sat Feb 23, 2013 12:18 pm, edited 1 time in total.

Lapino
Posts: 84
Joined: Tue Aug 16, 2011 10:01 am

AW: True WP navigation development

Post by Lapino »

I'd suggest to add wp_precision to define a circle around the wp. The timer for this particular wp starts when the uav is in the circle

And maybe add horizontal speed ;)
Last edited by Lapino on Sat Feb 23, 2013 10:46 am, edited 1 time in total.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: True WP navigation development

Post by timecop »

Forget keeping stuff in arrays with limited functionality.
*immediately* forget supporting anything less than tarduino 2560.
then implement scripting / mission planning and that will get you free waypoints.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: AW: True WP navigation development

Post by nhadrian »

Lapino wrote:I'd suggest to add wp_precision to define a circle around the wp. The timer for this particular wp starts when the uav is in the circle

And maybe add horizontal speed ;)


this is alreaady defined in Multiwii and that's how for example RTH code works now...
Horizontal speed is also defined, but still now none of them are user-tuneable.

Timecop - My oppinion is the same, Mega2560 is the minimum req. for WP navigation.

alexia
Posts: 85
Joined: Sun Jun 17, 2012 10:23 pm
Contact:

Re: AW: True WP navigation development

Post by alexia »

nhadrian wrote:
Lapino wrote:I'd suggest to add wp_precision to define a circle around the wp. The timer for this particular wp starts when the uav is in the circle

And maybe add horizontal speed ;)


this is alreaady defined in Multiwii and that's how for example RTH code works now...
Horizontal speed is also defined, but still now none of them are user-tuneable.

Timecop - My oppinion is the same, Mega2560 is the minimum req. for WP navigation.



mega 2560 is a necessary for high level fonction and now it s not very expansive thanks to rctimer and other chinese shop

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: True WP navigation development

Post by nhadrian »

Hi,

Another idea is to use a struct for GPS_WP (current WP datas) instead of stand alone definition.

Code: Select all

  static struct {
      int32_t Lat;               // Lat for WP
      int32_t Lon;               // Lon for WP
      int32_t Alt;               // alt at WP (cm)
      int16_t Heading;           // heading at WP (deg)
      int16_t Vario;             // vario for alt changing (cm/s)
      int8_t  Time;              // time to stay in WP (s)
      int8_t  Number;            // number of current WP written into GPS_WP
  } GPS_WP;


and then GPS_set_next_wp should called like:

Code: Select all

void GPS_set_next_wp(int32_t* lat, int32_t* lon, int32_t alt, int16_t heading, int16_t vario, uint8_t time, uint8_t number) {
  GPS_WP.Lat = *lat;
  GPS_WP.Lon = *lon;
  GPS_WP.Alt = alt;
  GPS_WP.Heading = heading;
  GPS_WP.Vario = vario;
  GPS_WP.Time = time;
  GPS_WP.Number = number;

  GPS_calc_longitude_scaling(*lat);
  GPS_distance_cm_bearing(&GPS_coord[LAT],&GPS_coord[LON],&GPS_WP.Lat,&GPS_WP.Lon,&wp_distance,&target_bearing);

  nav_bearing = target_bearing;
  GPS_calc_location_error(&GPS_WP.Lat,&GPS_WP.Lon,&GPS_coord[LAT],&GPS_coord[LON]);
  original_target_bearing = target_bearing;
  waypoint_speed_gov = NAV_SPEED_MIN;
}


Also I have an idea on the complex function, I attached a triout.
Basically, my idea is that if GPS_WP_MODE is active, copter stays in a current WP. Once GPS_WP_NEXT or GPS_WP_PREV is activated also, copter goes through on different WP-s, if reaches the last, stops.
For security reasons it always check if the next or previous WP is uploaded or not (this information could be stored in the WP struct as showed in my first post).

THE ATTACHED CODE IS JUST A SKETCH, MUST NOT BE USED FOR TESTING!!!!!!!!!!
just for some brainstorming... :)

MAYBE I'M COMPLETELLY ON THE WRONG WAY, so any comment would be wellcome.

BR
Adrian
Attachments
Multiwii_r1349_NHA_r17 _EXP_WP.zip
(167.24 KiB) Downloaded 125 times

Post Reply