ericolsen01 / mw-wingui

Automatically exported from code.google.com/p/mw-wingui
0 stars 0 forks source link

Way Point implementation - 2 : Get Waypoint Function in WinGUI (R53) #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Way Point implementation - 1 : Get Waypoint Function in WinGUI (R53)

based on multiwii 2.2, the protocol was implemented in "Serial.ino", in
\  case MSP_WP:
\  ...
\  if (wp_no == 0) {...}
\  else if (wp_no == 16) {...}
\  serialize8(wp_no);
\  serialize32(lat);
\  serialize32(lon);
\  serialize32(AltHold);           //altitude (cm) 
\  serialize16(0);                //heading  will come here (deg)
\  serialize16(0);                //time to stay (ms) will come here 
\  serialize8(0);                 //nav flag will come here
\  }
\  break;
=====================================================
There was some statement to send current waypoints in flight controller

But in WinGUI R53, there’s to corresponding function to download 
corresponding waypoint.
It’s existing
\  private void MSPquery(int command) {...}
to get a waypoint, but what if we want to download the waypoint-to-go from 
flight controller?
Here’s solution:
In WinGUI R53, mainGUI.cs(line 1441), there’s some statement to get current 
waypoint:
\  private void evaluate_command(byte cmd)
\  {
\    …
\    switch (cmd)
\    {
\      …
\    case MSP.MSP_WP:   //  (1441)
\      ptr = 0;
\      byte wp_no = (byte)inBuf[ptr++];
\      if (wp_no == 0) {…}
\      if (wp_no == 16) {…}
\      break;

Just add codes before the “break”, as below

// ===============================================================
// MSPgetWP WP#1~WP#15 in WinGUI    based on WinGUI R53, date: 2013/11/14
if ( wp_no >= 1 && wp_no <= 15 ){
    //Clean up current mission list
    if (wp_no == 1)
    {
        missionDataGrid.Rows.Clear();
        updateIndex();
        updateMap();
    }
    Int32   lat32 = 0,  lon32   = 0,    alt32 = 0;
    double  lat = 0,    lon = 0;
    int alt = 0,    time2stay= 0;
    byte    nav_flag = 0;
    lat32       =   BitConverter.ToInt32(inBuf, ptr); ptr += 4;
    lon32       =   BitConverter.ToInt32(inBuf, ptr); ptr += 4;
    alt32       =   BitConverter.ToInt32(inBuf, ptr); ptr += 4;
    BitConverter.ToInt16(inBuf, ptr); ptr += 2;             //  for heading, not use now
    time2stay   =   BitConverter.ToInt16(inBuf, ptr); ptr += 2; //  time2stay
    nav_flag    =   (byte)inBuf[ptr];               //  nav-flag  
    lat     =   (double)lat32/(double)10000000;
    lon     =   (double)lon32 / (double)10000000;
    alt     =   alt32;
    addWP("WAYPOINT", time2stay, lat, lon, alt);
}
// MSPgetWP WP#1~WP#15 END
// ===============================================================
then, you can download the waypoints in the flight-controller!
(Of course, some implementation is needed to add in on-board multiwii,
I will add it later)

Original issue reported on code.google.com by michaelo...@gmail.com on 14 Nov 2013 at 3:53

GoogleCodeExporter commented 9 years ago
Well, the WP implementation in MW is ongoing, and it is completely different 
from the current 0-15 wp method. I'm actively working on it right now, so stay 
tuned....

Original comment by eosba...@gmail.com on 14 Nov 2013 at 4:33

GoogleCodeExporter commented 9 years ago
got it, cheers 

Original comment by michaelo...@gmail.com on 14 Nov 2013 at 4:45

GoogleCodeExporter commented 9 years ago

Original comment by eosba...@gmail.com on 8 Dec 2013 at 8:00