GPS - Very Strange.... Please help

Post Reply
Jamesp123
Posts: 9
Joined: Tue Jun 30, 2015 10:45 pm

GPS - Very Strange.... Please help

Post by Jamesp123 »

Hi All,

I have an issue with GPS, my multiwii pro will GPS Hold, RTH & Land... but it will not do a mission. I have updated the Mag Dec I have done missions from the GUI on my laptop and Android device, ive uploaded and downloaded to see if its loaded on the board and the mission is stored but I send it on a mission and it raises to 25m yaws then literally fly`s off??

Can anyone help please?

Its probably an easy fix??

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

Is your Mag calibrated properly? Do you have #define_USE_MSP_WP uncommented? Is your magnetic declination set to where you actually live?

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

Hi James,

What are you Pos, PosR and NavR PID settings? What is the size of the quad?

Does your heading change when you arm your motors? There can be problems with magnetic fields around the high power ESC wiring that cause the compass reading to change when you apply more throttle, this will have interesting consequences for navigation...

However if it does RTH ok, then it seems unlikely that the mag is the cause of the problem. What is your setup for navigation in config.h?

Thanks,
Ed

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

The only thing in config.h that is not enabled by default that relates to missions is the #define_USE_MSP_WP. That is the MOST likely reason for waypoint missions to fail as he describes. Another problem is, if you don't fly near where you live, the magnetic declination must be set to what it is where you actually fly.

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

I realise there is little to do with actually navigating in config.h, however, why would it just fly off?

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

If the #define_USE_MSP_WP is not enabled, the craft will not see any waypoints. Believe me, with a mission enabled and no code for it to recognize those waypoints, the craft simply flies off. It heads for the first waypoints co-ordinates then just continues on because it doesn't recognize that it has reached it's first waypoint. Lots of newbies make this error. The craft will do RTH and all that other stuff because they don't use waypoints. If the GPS system is enabled in config.h but the #define_USE_MSP_WP is not, the result upon trying to fly a mission will be a fly-away. #define_USE_MSP_WP is how you make waypoint missions active. Just look it up in the wiki..... :?

BTW, the way to regain control in this situation is to simply switch off your mission.

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

Surely this is a bug/feature that should be fixed? It violates the rule of least surprise!

Enabling a mission with no waypoints loaded shouldn't be possible to prevent this sort of fly away... It's got to be a simple thing to check for, after all, it can tell when a mission is finished, perhaps the same behaviour (ie switching to pos hold) should occur when a mission is started with no waypoints loaded.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

When I built my quad it cost me a pretty penny so before I tried to use any of the neat stuff like waypoint nav I sat down and read everything I could about Multiwii and waypoint. I found out about the #define_USE_MSP_WP during my research process as well as what fence distance was, and all the other things I needed to know before trying to fly my first mission. The result of that was a perfect first mission. Understanding that an FC is just a computer and it can only do what it is told when it is told to do it, goes a long way in knowing that things can go wrong when you leave out details like reading up on what you are trying to do. Sure, you can write some code to make it do what you want but why not just learn all about it up front like I did? I am imagining that the waypoint command that is disabled by default is that way because there are lots of builders out there who are not interested in flying autonomously with waypoints enabled. GPS really isn't needed to fly a quad. Many build a quad first and then later decide they want to add GPS functionality. Simple fact is, it works as advertised if you do it right but in order to do it right you must LEARN how to do it first. To learn you must read. The literature is there. My quad and I proved that with a successful first mission. When all else fails, come here and ask someone. Maybe you can pull off fixing the code so it works as you described, I don't know. I'm not good at writing it. I think it helps more to understand how to use whats already there first. I think what people need most to build and fly one of these successfully is the ability to do some research. Now, if you want some real excitement, by accident switch on a mission you have loaded and forgotten about when you aren't at that location :mrgreen: :mrgreen: :mrgreen: :o :shock:

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

Yeah, what's with the lecture seemingly directed at me? I earn my living by programming firmware in C, developing electronics and writing documentation... *I* have read the code, wiki, forum etc.

I'd like to know why/how the OP had this happen, that's the point of this thread, surely it shouldn't be possible to *start* an *empty* mission??? (If that is what happened?) Some sensible failover to GPS hold or similar would be nice.

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

James, just to get this back on track...

As kbev pointed out, do you have #define USE_MSP_WP uncommented?

Does RTH work correctly and reliably, even in the wind?

Thanks,
Ed

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

edsimmons3 wrote:Yeah, what's with the lecture seemingly directed at me? I earn my living by programming firmware in C, developing electronics and writing documentation... *I* have read the code, wiki, forum etc.

I'd like to know why/how the OP had this happen, that's the point of this thread, surely it shouldn't be possible to *start* an *empty* mission??? (If that is what happened?) Some sensible failover to GPS hold or similar would be nice.


Just passing along some info. Not trying to lecture.
I have to assume that you aren't the only one reading my posts. Some of what I have said can surely help someone??? I hope???

The mission isn't empty. From what I gather, the heading information and other stuff is there as are the waypoints, (they were after all uploaded to the FC) but the waypoint can not be recognized once the craft heads out towards it so it keeps on flying due to the fact that waypoint navigation was not enabled. Might be poor code planning. I might have my facts completely wrong because I have never had this event happen. I have no clue. The way I avoided this problem was by reading carefully and the uncommenting the correct phrase in the code before trying to fly a mission. I managed to work around it OK so others should be able to as well.....with a little info passed along. The mission function works real well with a good GPS unit, all the code in the config.h set correctly, and if all of three or four other things are done right as well.

I applaud your effort to improve the code and hope you are fantastic at doing that :) I have done some .net stuff and other things like Citrix while back in college. I lost interest in programming after a career change. Nowadays I consider myself a complete moron when it comes to anything like writing this stuff (arduino code for multiwii.) I think that the point I was trying to get across is that if I (who never even heard of arduino before I built my first multiwii) can get a quad up and running (quite well I might add) using the code as it came to me online even with it's quirks and seemingly odd behavior built in, just through researching the available info on how to get it to work, then anybody else can do the same thing. I am sorry you took it as a lecture. That was not my intention.

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

If there is a problem in the code that caused this somehow, then I'd like to see if it can be found and fixed... If it is possible to send your craft away *thinking* it is supposed to be following waypoints, it shouldn't be able to leave unless it can actually navigate (but PIDs being set incorrectly could still cause the wind to blow it away...)

I'd like to establish the cause of James' incident so we can be clear whether this is something that needs fixing in the code or whether it was a misconfiguration due to inadequate docs, or whatever else it may be.

James, please can you share your config.h file so I can investigate? Pastebin is a good way to share these without cluttering up the forum thread...

Thanks,
Ed

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

I am wondering about this in other ways as well. I would ask Jamesp if the quad took off in the direction of the first waypoint entered into his mission. If so, did he wait long enough for his first waypoint to even be reached? On some of my missions, after entering the waypoints into the FC using EZGUI, the way points are in reality farther away than what it looks like on your mission screen. What looks like about twenty yards or so on your mission map in reality is really 50 yards!! I HAVE had that happen. I waited patiently for the first waypoint and it was eventually reached about twice as far as I expected.

Testing in a space that is less than adequate for missions (anything less than a couple of footballfields) can lead to the conclusion that the quad is flying away. Also testing in a space that turned out to be too small, one day I tried to fly a mission in my front yard. On the EZGUI where I drew it, the first and second waypoints were between the house and a tree out near the road. I made sure there was plenty of clearance involved with everyhting. First waypoint reached seemed a little late, sure enough, second one was in the tree. I guess that this GPS stuff is only just so-so accurate. Other times, flying in a huge field nearby to where I live, the GPS seems to function flawlessly. But, out there, you can't tell if things are spot on or not because you have so much room that you can't tell exactly where it is executing it's waypoints and if they are where you entered them on your mission. I plan to investigate this stuff when I get my telemetry working so I can correlate actual logged flight data to what I entered. All I need is a good host mode tablet and I'll be there.

User avatar
stronnag
Posts: 114
Joined: Thu Oct 24, 2013 9:32 pm
Location: New Forest, England
Contact:

Re: GPS - Very Strange.... Please help

Post by stronnag »

The other thing worth remembering is that missions are retained in (e)eprom after power off. Loading a mission for a particular location, then moving some considerable distance, then starting mission may be somewhat disconcerting.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

stronnag wrote:The other thing worth remembering is that missions are retained in (e)eprom after power off. Loading a mission for a particular location, then moving some considerable distance, then starting mission may be somewhat disconcerting.


Exactly what I was talking about when I said "Now, if you want some real excitement, by accident switch on a mission you have loaded and forgotten about when you aren't at that location" :mrgreen: :mrgreen: :mrgreen: :o :shock:
What I was referring to here is the day that I accidentally flipped into mission on my TX instead of taking it out of POS Hold like I wanted to do. It had a mission uploaded for the park down the road and around the corner. I never figured out what I did wrong until it hit the trees and crashed (thankfully). During the subsequent troubleshooting I saw my TX switched to the mission position and right away I realized my error.
The disconcerting description is good, nice level of understatement made there....he musta done it once like me!! :mrgreen: :D

Something else jamesp123 mentioned was that the craft rises to 25m. This leads me to believe that the set of circumstances I mentioned about never really reaching the first waypoint might actually be fact. The default waypoint altitude in my EZ GUI is 25m......meaning perhaps that the craft will move to the height of the first waypoint before flying to it??? I'm not sure if it is supposed to work that way because I have always done missions using less than probably 25 feet on altitude at my first waypoint and have never really noticed (because I never had a reason to) if it rises as it flies to the waypoint or if it goes to 25 feet first and then heads off. The fact that it goes to 25 meters and then flies off might be showing that the craft is at least going to altitude called out in the first waypoint (also assuming that he never changed default waypoint altitude settings) which takes me back to heading related issues involving the mag if he is actually waiting long enough to see if it will reach a waypoint. If it flies off looking for a waypoint that is there in the FC but its mag is telling it to head another way to get there....well,you get the drift, and so will the craft as it drifts off in search of the first waypoint that it is not going to ever end up at.

If he has the wrong or the default magnetic declination (which just happens to be Budapest Hungary) entered as opposed to the MD where he actually is flying (which should be in there instead) the above mentioned set of circumstances goes into action with unpredictable results.

There is also a nav setting called wait to reach RTH alt. that is enabled by default in the code that if he has set at 25m might be why it goes up that high right off the bat. I always thought that it only applied on a RTH situation, but maybe it also applies to when the craft is starting a mission...anyone know? I don't know for sure.....

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: GPS - Very Strange.... Please help

Post by edsimmons3 »

To find out for sure I searched the multiwii code for WAIT_FOR_RTH_ALT. It is only used for RTH in the code:

Code: Select all

case NAV_STATE_RTH_START:
      if ((alt_change_flag == REACHED_ALT) || (!GPS_conf.wait_for_rth_alt)) {             //Wait until we reach RTH altitude
        GPS_set_next_wp(&GPS_home[LAT],&GPS_home[LON], &GPS_coord[LAT], &GPS_coord[LON]); //If we reached then change mode and start RTH
        NAV_state = NAV_STATE_RTH_ENROUTE;
        NAV_error = NAV_ERROR_NONE;
      } else {
        GPS_calc_poshold();                                                               //hold position till we reach RTH alt
        NAV_error = NAV_ERROR_WAIT_FOR_RTH_ALT;
      }
      break;


The magnetic declination + old mission info looks like the culprit from all this discussion...

Remember that it's better to set your magnetic declination in your config.h file rather than using the GUI to set this value. It's much harder to have the wrong value loaded then! I noticed that it's possible to set in the processing GUI, seems to me like this is a possible route to having the wrong value set after many cycles of flashing firmware and forgetting about updating it during setup... at least if it is set correctly in config.h you cannot forget to set it ;)

The desired altitude hold value is set to the waypoint altitude at the beginning of navigation to each waypoint:

Code: Select all

            switch(mission_step.action)
              {
              //Waypoiny and hold commands all starts with an enroute status it includes the LAND command too
              case MISSION_WAYPOINT:
              case MISSION_HOLD_TIME:
              case MISSION_HOLD_UNLIM:
              case MISSION_LAND:
                set_new_altitude(mission_step.altitude);
                GPS_set_next_wp(&mission_step.pos[LAT], &mission_step.pos[LON], &GPS_prev[LAT], &GPS_prev[LON]);
                if ((wp_distance/100) >= GPS_conf.safe_wp_distance)  abort_mission(NAV_ERROR_TOOFAR);
                else NAV_state = NAV_STATE_WP_ENROUTE;
                GPS_prev[LAT] = mission_step.pos[LAT];  //Save wp coordinates for precise route calc
                GPS_prev[LON] = mission_step.pos[LON];
                break;
               ....
               }

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: GPS - Very Strange.... Please help

Post by Kbev5709 »

Great work there on the RTH info. Thanks Ed.
The same thing will happen (bad behavior in flight) with updated mission info if the MD is set wrong. Finding out that the craft will rise to the altitude stated before flying off makes it look more like that may be his problem. More great work there on your part. Thanks again :)

Entering your MD in the config.h will solve the problem of having the wrong MD for one location. Trouble with that is, as I mentioned in this thread before, your MD must be set to the location where you are flying on any particular day. So, unless you want to plug in to your computer before every time you fly and reset your MD to the location you will be at, your best bet is to use the EZ GUI at each place you fly. Go to the misc. settings in your EZ GUI and press auto and the EZ GUI will automatically find the MD of the location you are trying to fly at. Make sure you click the little upload arrow and that the EZ GUI says settings have been read. Now go fly. Of course, if you always fly at the same location, having the correct MD in your config.h sketch is the way to go. For someone like me, I very rarely ever go into config.h once I have everything up and running, preferring to reset variables that need changed (PID, GPS, etc.) through my EZ GUI. Usually, ironically, the thing I change the most is the MD. I rarely fly in the same location every day so I need to update my MD all the time. The MD also changes over time in the same location. It can really change a lot in a couple of months. It pays to check what the MD in your flight area really is TODAY just to be safe. I can go a couple of miles in either direction from my house and the MD will be different than what it is where I live. It will also be different in those locations in a month sometimes.

If you don't have or don't use the EZ GUI app, the computer will do in a pinch. When you re-upload your new MD in Arduino,
make sure that your config.h in the *memory savings* section has been changed to uncomment the line
#define SUPPRESS_DEFAULTS_FROM_GUI. Failure to uncomment this statement before the upload will put all of the factory defaults (PID settings and everything else too) back in the FC. Then you will have to re-set everything. This will happen EVERY TIME you upload a new sketch unless you uncomment that line.

While we are talking about possible magnetic problems, I would like to add that I always re calibrate my mag at the location I am going to fly at. It really isn't hard to re calibrate using the EZ GUI. It takes an extra 30 seconds. If you are flying a DJI you know that mag re calibration must be done before every flight. It is just part of the takeoff procedure with that FC. I follow the same procedure with my multiwii. It is one of the things on my checklist before every flight (EZ GUI has a checklist function you can customize.) When I'm sending my quad off on it's own I want everything in my favor as much as possible and re calibrating the mag is one extra thing you can do to make sure your headings will be what you expect.

Other things that can mess with an otherwise perfectly set up GPS system is solar and magnetic field activity. Once again, EZ GUI can help with the GPS function. There at the bottom in the GPS readout is the state of the sun and the earths magnetic field in your area. Certain days I will not use GPS at all, depending on what these readouts say. For all anyone here really knows, he could have been just trying to use his GPS on a really bad day.

Post Reply