GPS integration

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
User avatar
mbrak
Posts: 136
Joined: Sat Dec 03, 2011 8:08 pm
Location: Germany, Lemgo

Re: GPS integration

Post by mbrak »

hi nils

congratulation !!!

have you made ​​any modifications to the 2.0pre1 code?

br michael


jevermeister wrote:So I did some testing yesterday:
1. Walking tests with copter and notebook. Everything seems plausible, except the bearing to home need to be the other way around, inclusive bearing relative to copter nose. We have a meg, why not use it.

2. Flight test: Amazing!!! It works you flick the switch and it comes back, I have a little problem with the PID it is overshooting the position it should hold, but this is just parameter optimizing.

Walking behind the copter and try to shove it into another direction is funny too, you can feel it wanting to return to home or hold position

I am so happy.

Good work Alex!!

Nils

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

I only made my config an added my buzzer.

I changed nothing to the gps routine yet.

nils
mbrak wrote:hi nils

congratulation !!!

have you made ​​any modifications to the 2.0pre1 code?

br michael


jevermeister wrote:So I did some testing yesterday:
1. Walking tests with copter and notebook. Everything seems plausible, except the bearing to home need to be the other way around, inclusive bearing relative to copter nose. We have a meg, why not use it.

2. Flight test: Amazing!!! It works you flick the switch and it comes back, I have a little problem with the PID it is overshooting the position it should hold, but this is just parameter optimizing.

Walking behind the copter and try to shove it into another direction is funny too, you can feel it wanting to return to home or hold position

I am so happy.

Good work Alex!!

Nils

fffmonkey1
Posts: 3
Joined: Sun Mar 11, 2012 2:41 am

Re: GPS integration

Post by fffmonkey1 »

I have a problem Serial3 error problem, am I missing something?

When compile, the following error occur
MultiWii_1_9.cpp: In function 'void setup()':
MultiWii_1_9:295: error: 'Serial3' was not declared in this scope
MultiWii_1_9.cpp: In function 'void loop()':
MultiWii_1_9:537: error: 'Serial3' was not declared in this scope


Image

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

Re: GPS integration

Post by nhadrian »

Hi,

today I have many-flights with the currend GPS code.
I can confirm that this way of GPS code will newer work even with PID tuning.
The main problem is the basic idea. Because with current code, when copter hits the destination point, the angle become "0", but the speed will be not zero. So it will overrun. But, interrestingly, in wind it quite works, because copter can stabilized behind the destination point with the angle neccessary for hoovering in the wind.
I started a topic with another idea, which is based on the speed not distance. Iths very similar to the Arducopter's one. But I don't have the neccessary programming skills. :(

BR
Adrian

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Hi Adrian,
interesting statement.I read your idea a while ago but wasn't into gps that time. send me a pm and I will try to use my limited skills to code your idea.

Nils

User avatar
mbrak
Posts: 136
Joined: Sat Dec 03, 2011 8:08 pm
Location: Germany, Lemgo

Re: GPS integration

Post by mbrak »

hi

that may be the same problem i had a couple of days before. it was absolutely no wind and the copter overruns the position and did not stop.
maybe today i will do some test with some wind. wait and see.





nhadrian wrote:Hi,

today I have many-flights with the currend GPS code.
I can confirm that this way of GPS code will newer work even with PID tuning.
The main problem is the basic idea. Because with current code, when copter hits the destination point, the angle become "0", but the speed will be not zero. So it will overrun. But, interrestingly, in wind it quite works, because copter can stabilized behind the destination point with the angle neccessary for hoovering in the wind.
I started a topic with another idea, which is based on the speed not distance. Iths very similar to the Arducopter's one. But I don't have the neccessary programming skills. :(

BR
Adrian

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: GPS integration

Post by LuFa »

interesting idea.
I have found out the same problem, when the Angle is Zero the Multiwii shoul break for a short time .
I think its not sooooo different to programm it , the higher the angle, the greater the braking effect should be .

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

Re: GPS integration

Post by nhadrian »

The main problem that during approaching, copter has an angle to direction, and a speed. When closer to destination, angle starts to decrease. And the speed a little bit, too. But, when copter hits the target, it will have 0 angle, but not 0 speed! So it will overrun and starts to lean to the opposite direction. When it stops, it will have some degrees angle, so it starts to accelerate towards to the destination. So when hits target again, it WILL HAVE SPEED!!!!!! So overrun continues.

In wind, the situation is a little bit different, when copter is behind the target, it will slow down before hits target because of the wind. And will calm down some meters away from target. BUT! Try RTH when copter is before the target in wind! It will have serious speed to the ground, and will owerrun much more on target!!!! When wind is high enough, it can be scarry!!!

That's why it is important to regulate the angle based on speed not distance!!! Because then, ie. wind can be compensated as much as overruns in calm day. Because, when approaching, copter can achieve negative angles before target to slow down.

Unfortunatelly, GPS speed data is not accurate enough especially in low speeds, so speed should have calculated from coordinates, they are accurate enough. And, since we have a secondary arduino (EOSBandi), such calculations can be simply done without overlading the main processor...

I wish I would know programming, its hard to have the regulation process in my mind but not able to write down with program code.... :(:(:(:(:(

EDIT: Arducopter CODE already HAS this type of speed calculations and regulation method !!!!!!!!!!!!!!!!!!!!!!

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Hi,
that seems to be the same priniple as baro vel and baro alt.

The hover mode does the same thing, it measures the absolute angle AND the anglespeed to obtain 1G hovering, I think we have a problem with the GPS update rate if we try to do taht. A frequency of 1 value per second is far too low to get speed readings you can count on.
But if we have accurate speed readings, doing the math should be easy, it is, as stated before, the same priciple as baro and hover PID.

Nils


I understand the problem.

User avatar
mbrak
Posts: 136
Joined: Sat Dec 03, 2011 8:08 pm
Location: Germany, Lemgo

Re: GPS integration

Post by mbrak »

hi

i use the gps from flyduino. i thought it has 10hz. isnt that right?

the ardurcopter software (megapirate) runs also on the same hardware some people uses here, the flyduino mega. there is no coprozessor to do the gps math. why it should not be possible to to this with mwc?

the act which describes ardian is the same that I've found some days before.

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

Re: GPS integration

Post by nhadrian »

I'm using Locosys GPS and it runs on 10Hz!
So i'm sure that is enough for speed calculation. But, I'm interrested in any other solution that could result in a good behaviour even in windy and calm weather too, without overshooting!!! And, which gives correct position holding, because now in strong wind, hoovering position will be 10-15 m after the target point.......

But still I have the idea that Arducopter code would be a nice point to start from.

fffmonkey1
Posts: 3
Joined: Sun Mar 11, 2012 2:41 am

Re: GPS integration

Post by fffmonkey1 »

Does 1.9 TTL GPS module support Cirus SE (Arduino Pro mini 5V/16Mhz w/ATMega328 board)?

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS integration

Post by Wayne »

I am in the market for a GPS module as my HK/Apache module may or may not work.
HK/Apache uses GTPA010 and the same chipset as the Flyduino’s FMP04, HK/Apache is just smaller.
I found FMP04 for $25 but I do not want to buy the same freeze problem again.

nhadrian, what Locosys GPS module are you using?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

I use flyduino bob with fmp04 without freeze problems.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: GPS integration

Post by copterrichie »

Have anyone been able to get the i2c-gps-nav working? If so, how did you do it pleas..

http://code.google.com/p/i2c-gps-nav/

Thank you

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

Re: GPS integration

Post by nhadrian »

HI,

I'm using since many weeks with success.
Just connect the serial GPS serial port to the secondary Arduino (Be careful, if using 5V Arduino, use a logic level converter, ie. sparkfun!!!), and the secondary arduino to the main board on i2c (again, be careful, if secondary arduino is 5V one, connect to the 5V level i2c, or build a level converter!). Upload the i2c_nav_code to the secondary arduino, be careful to set up GPS module for porper NMEA strings and update/baud previously (ie. use minigps PC software, or add the gps init code from multiwii into the i2c GPS code after void_setup / serial_open).
Then, enable i2c GPS in multiwii code... and DONE!

BR
Adrian

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: GPS integration

Post by Alexinparis »

nhadrian wrote:The main problem that during approaching, copter has an angle to direction, and a speed. When closer to destination, angle starts to decrease. And the speed a little bit, too. But, when copter hits the target, it will have 0 angle, but not 0 speed! So it will overrun and starts to lean to the opposite direction. When it stops, it will have some degrees angle, so it starts to accelerate towards to the destination. So when hits target again, it WILL HAVE SPEED!!!!!! So overrun continues.

In wind, the situation is a little bit different, when copter is behind the target, it will slow down before hits target because of the wind. And will calm down some meters away from target. BUT! Try RTH when copter is before the target in wind! It will have serious speed to the ground, and will owerrun much more on target!!!! When wind is high enough, it can be scarry!!!

That's why it is important to regulate the angle based on speed not distance!!! Because then, ie. wind can be compensated as much as overruns in calm day. Because, when approaching, copter can achieve negative angles before target to slow down.

Unfortunatelly, GPS speed data is not accurate enough especially in low speeds, so speed should have calculated from coordinates, they are accurate enough. And, since we have a secondary arduino (EOSBandi), such calculations can be simply done without overlading the main processor...

I wish I would know programming, its hard to have the regulation process in my mind but not able to write down with program code.... :(:(:(:(:(

EDIT: Arducopter CODE already HAS this type of speed calculations and regulation method !!!!!!!!!!!!!!!!!!!!!!


Hi,
I know the current GPS angle correction is very basic.
It was a way to proceed step by step, before adding some refinement.
Having a working code is for a moment a nice step, that will become more and more optimized.

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

Re: GPS integration

Post by nhadrian »

Yes, I absolutely confirm this method.
But, I feel like the distance-angle calculation refinement is not the right way from now on, because speed calculations need different basic calculations.
Indeed, this basic calculation is great for debug communication with GPS and NMEA string decoding!!!

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Hi,
I know the current GPS angle correction is very basic.
It was a way to proceed step by step, before adding some refinement.
Having a working code is for a moment a nice step, that will become more and more optimized.


I am with you Alex. Noone wanted to talk bad about the GPS code.

You cannot imagen how glad I was when I first saw the copter tilt to home coordinates and return home. That was really really cool.

The whole platform ist just awesome. Something I soldered, milled and screwed together is flying on its own. COOL!

I hope I can contribute anything in the future!

Nils

User avatar
Th0rsten
Posts: 65
Joined: Mon Oct 31, 2011 10:28 am

Re: GPS integration

Post by Th0rsten »

jevermeister wrote:The whole platform ist just awesome. Something I soldered, milled and screwed together is flying on its own. COOL!

Yes! My full acknowledge. It's so cool - it's flying. :)

User avatar
fr3d
Posts: 97
Joined: Sun Feb 06, 2011 11:21 am
Location: Cappelle la grande near the ch'ti village
Contact:

Re: GPS integration

Post by fr3d »

hi all,
I would like to use the poor man(aka remzibi) gps module. this gps module works @ 38400 bps. I've tried to to send via remzibi gps emulator v1.2.6 gps data @9600 bps with

Code: Select all

#define GPS_SERIAL 1 // should be 2 for flyduino v2. It's the serial port number on arduino MEGA
#define GPS_BAUD   9600

it's working
but with

Code: Select all

#define GPS_SERIAL 1 // should be 2 for flyduino v2. It's the serial port number on arduino MEGA
#define GPS_BAUD   38400

the mw 2.0 freeze :(

any idea to help me ?

another things in this software you can add/remove nmea instructions. If I use only one GPRMC or GPGGA it's seems to work. it doesn't freeze. if I select two it's freeze

User avatar
fr3d
Posts: 97
Joined: Sun Feb 06, 2011 11:21 am
Location: Cappelle la grande near the ch'ti village
Contact:

Re: GPS integration

Post by fr3d »

Can a programmer throw a look @ lines 600
we have maybee some synthax error or strange code
for me....

Code: Select all

    #if BARO
      if (rcOptions[BOXBARO]) {
        if (baroMode == 0) {
          baroMode = 1;
          AltHold = EstAlt;
          initialThrottleHold = rcCommand[THROTTLE];
          errorAltitudeI = 0;
          BaroPID=0;
        }
      } else baroMode = 0;
    #endif
    #if MAG
      if (rcOptions[BOXMAG]) {
        if (magMode == 0) {
          magMode = 1;
          magHold = heading;
        }
      } else magMode = 0;
      if (rcOptions[BOXHEADFREE]) {
        if (headFreeMode == 0) {
          headFreeMode = 1;
        }
      } else headFreeMode = 0;
    #endif
    #if GPS
      if (rcOptions[BOXGPSHOME]) {GPSModeHome = 1;}
      else GPSModeHome = 0;
      if (rcOptions[BOXGPSHOLD]) {
        if (GPSModeHold == 0) {
          GPSModeHold = 1;
          GPS_latitude_hold = GPS_latitude;
          GPS_longitude_hold = GPS_longitude;
        }
      } else {
        GPSModeHold = 0;
      }
    #endif

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS integration

Post by Wayne »

This morning with 2.0.PV2 loaded and without MAG/BARO, I froze a minute or so after GPS lock.
I did however, without unplugging, hit the reset button and loaded dev20120225 into it WHILE I still had GPS lock.
I opened a new session of MWWinGUI. I see that I have lock onto 6 satellites and have a distance and direction home.
It’s been running now for 15 minutes without freezing even with MAG & BARO.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: GPS integration

Post by Alexinparis »

fr3d wrote:another things in this software you can add/remove nmea instructions. If I use only one GPRMC or GPGGA it's seems to work. it doesn't freeze. if I select two it's freeze

multiwii looks only to GPGGA and should ignore other ones.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: GPS integration

Post by Alexinparis »

a small video showing current GPS ability:
http://youtu.be/QD5hJRW64bQ

not perfectly tuned, but the result is here

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Ho, I already wrote tjat to Alex:
The approach to home or position hold should be created with a cascading control loop.
W
1. Inner control loop should control the groundspeed via the nick/roll angle.
2.the outer control loop should control the speed as a function of distance to target.
Secure the funtion with a max angle and a max speed.

this would be the cleanest solution I think. In theory the speed at target should be 0.to achieve this the copter would aitomatically invert the angle to slow down BEFORE the target.

Alex tried something similar to this at baro vel I think.


Nils

ps.: the baro mode in the video is funny. mine is working far better.

karsten j.
Posts: 16
Joined: Mon Mar 05, 2012 7:22 am

Re: GPS integration

Post by karsten j. »

Hi

My WiiBoard doesn´t find any satelite. I suppose it´s because the Baud-rate of my GPS. It´s from Flyduino and it is set to 38400.
.In the Multiwii 2.0pre2 I set the baud rate to 38400 (may I do this !?)
Can I just change these lines from the serial GPS software (Eosbandi):
Serial.begin(115200); //for GPS
//Serial1.begin(115200);
//Init i2c_dataset;

to

Serial.begin(38400); //for GPS
//Serial1.begin(38400);
//Init i2c_dataset;

Or the question is
What I have to do to get GPS fix in the Multiwii software ?
Thanks for help.

Greets Karsten

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Karsten,
don't get things messed up.
Are you using i2c gps from eosbandy with a standalone fmp04 and second arduino or are you using serial gps with a flyduino gps bob.

You have to stick to the right settings. serial for serial and i2c for i2c.

Nils

karsten j.
Posts: 16
Joined: Mon Mar 05, 2012 7:22 am

Re: GPS integration

Post by karsten j. »

Hi Nils,

I´m using a second arduino with the I2c gps from Eosbandi. The FMP04 with the GPS Bob is connected to this 2. arduino (5V,TX,RX,Gnd)
Connection Serial serial, I2C I2C is correct...

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: GPS integration

Post by didlawowo69 »

what the interest to use I2C Gps ?

karsten j.
Posts: 16
Joined: Mon Mar 05, 2012 7:22 am

Re: GPS integration

Post by karsten j. »

Because I have 3 Copter with the Arduino Pro Mini. I don´t want to buy the Mega-Board.

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

Re: GPS integration

Post by Lapino »

Hi,

are INS and GNSS data coupled for a precise position estimation at the moment?
In the video Alex, the Maker :) , showed us position hold ability the quad flew around quite a bit. That's why I'm asking.

As the estimated position of the GNSS jumps around the real position the quad also does these movements (that's what I observed) so I'd suggest to couple the INS and GNSS to make the quad hold still on one position / make some datafusion of the estimated position, velocity and error of the INS and the GNSS, if not done already.

In other words, when the GNSS position jumps but the INS doesn't recognize any movement in X and Y, why should it move to the newer position if the actual error is small?

Kind regards,

karsten j.
Posts: 16
Joined: Mon Mar 05, 2012 7:22 am

Re: GPS integration

Post by karsten j. »

Hi

I hope you can help me...
I´ve read main of this thread, but couldn´t find somethin regarding my problem.
Now I´ve installed the I2C-GPS and in the GUI I can see GPS-fix (8 satelites) and the Distance to home is about 0-2m
When I move with the copter and the notebook, the Distance rises... but only approx. 10 sec. and then freeze !
What could be the reason for this freeze of the GPS ?

Is this because of the MW 2.0 pre2 ?
Shall I try the 2.0 dev ?

Greets
Karsten

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

@Alex: Any reason why you only applied the recent GPS changes only to trunk and not to shared trunk?


Sorry Karsten, I use a serial GPS - I cannot help you.

Wait until EOSbandi is bacl from his moving.

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: GPS integration

Post by kos »

Lapino wrote:make some datafusion of the estimated position, velocity and error of the INS and the GNSS, if not done already.

In other words, when the GNSS position jumps but the INS doesn't recognize any movement in X and Y, why should it move to the newer position if the actual error is small?

Kind regards,


will make the error circle bigger .. . and the position hold wouldnt be as accurate .

the issue is that the n0.1°/dist algo is only suitable for traveling to wp , when wp is reached gps should use DI to stand in an error circle
when error circle is to big we put back some P


// with P=5.0, a distance of 1 meter = 0.5deg

goto wp 0.1°
wp reached 0.0°
wp error circle is reached 0.3°
wp reached 0.0°
goto new wp 0.1°

send me a gps so i can make some test :D


sensors fusion is cool , but 8bit is not enough : http://www.fusion2004.foi.se/papers/IF04-0881.pdf

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: GPS integration

Post by shikra »

I've not followed GPS side much, but had a quick look today. Maybe some of this will help...


All the FPV guys will know these tricks already to get better and faster lock on their OSD's, but for those who are not aware....
- Put a torroid on the wires to the GPS. Or an LC filte.r As close to it as can get - 4 turns minimum. More = better.
- Keep GPS away from noise generating devices - SBEC's usually worst. Also any RF devices such as FPV tx.
- Insulated square of grounded alumium/copper foil under the GPS

There is a reason DJI put there GPS up on that "saucer" - distance. Creating distance really helps minimise fr noise from devices. It's difficult to get distance on a copter...

Doing teh above can mean teh difference between 8 sats in 40 seconds and 4 sats in 20 minutes....
If you are having problems, try them.

I would also comment....
The current criteria for minimum sats is really low,

Sats of 5 with HDOP of less than 2 is what I like as an absolute minimum for RTH
Relying just upon number of sats value is not that accurate.
For position hold I like to see 8 sats and HDOP 1.2 or better for real good accuracy.

Accepting the sat/HDOP numbers to quickly before it has time to fully lock, I sometimes see errors of 50 meters.. Could be enough for a big problem!!

Now on a positive, resetting home at take off will help maximise sats for minimum wait time.

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS integration

Post by Wayne »

My HK/Apache GPS module seems to lock then drift, sometimes 100M or more from MWs home position.
This may be why my MEGA2560 is freezing after GPS lock with 2.0.PV1&2. (dev_20120225 does not freeze)
I’m going to wire in a LED to tell me when MW has GPS fix_Home established and try changing GPS_numSat to >4 or more.

No Joy. Even with GPS_numSat >10.
I did find that the line that does not cause freeze when commented is ‘while (SerialAvailable(GPS_SERIAL)) {‘.

User avatar
fr3d
Posts: 97
Joined: Sun Feb 06, 2011 11:21 am
Location: Cappelle la grande near the ch'ti village
Contact:

Re: GPS integration

Post by fr3d »

hi,
I have mofified, with mini gps software 1.4 from mediatek, my remzibi gps module. I've removed all NMEA sentences. It seems to work. bps @ 38400. if I let RMC sentence it freeze. Tomorrow I will try it in flight.

nb: If alexinparis read me for a allinone board I have to add the following line in config.h

Code: Select all

#define BMA180_ADDRESS 0x82
without this the allinone will not work.

nb2: thanks to shikra for FPV tips.

Matt.
Posts: 26
Joined: Sat Dec 31, 2011 11:41 pm
Location: Sydney, NSW, Australia

Best GPS module to use with Cirus SE

Post by Matt. »

Hey Guys,

Quick question, can you please suggest the best gps module to use and perhaps a link if you have one. I have a cirus SE board fight control board if it matters. :-)

Thanks in advance

Matt

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS integration

Post by Wayne »

Thank You Fr3d.
I have found MiniGPS, downloaded it and am now looking for a pair of 33ohm resisters and an old USB cable.
I’ll get this to work yet!

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: GPS integration

Post by Alexinparis »

Hi Wayne,

I've just uploaded a preversion3.
The RX buffer is increased a little.
I noticed it was too short. I don't know if it can help to solve your freeze problem.

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: GPS integration

Post by Wayne »

Alex you are the man!
No more MEGA freeze!
Now if you could do something about the forcasted rain and snow we are to get here this weekend......
Thank You!!!!

Fritz
Posts: 11
Joined: Fri Mar 16, 2012 8:48 am
Location: Germany

Re: GPS integration

Post by Fritz »

Hi all,

sorry for my english, it's not so good. Read and understand it but I can not write with it that way. so I google for help taken.

For a few days now I try the GPS with an extra at328 connect via i2c. That does not really work. The MultiWiiConf shows me no Staliten.

Add to my window's and my equipment:

I use the PA6B and have it set to 115200 baud and 10 Hz.
On the second Atmel 328 I uploaded I2C_GPS_NAV.ino. There, I've changed nothing.
The GPS module and the AT328 are about TX -> RX and RX -> TX connected and At328 for the GPS is connected to the Atmel for the copter by I2C.

The GPS module receives satellite and works properly. What I know not whether the AT328 is working properly. I could verify this somehow?

Incidentally, I use Multiwii 2p3. There, I have not changed ... or at least, the i2c address I've switched to 0x20. This is the gps on the atmel that way. I just do not know why anymore. Tentatively, but I have also switched to 0x40. does not matter.

gps.jpg


So slowly running out of ideas.
Can someone help me?
Greetings Fritz

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: GPS integration

Post by Bledi »

you have I2C errors ! your I2C link with the I2C GPS is not working.
One reason is perhaps your I2C speed. If it's not 400Hz you need to change the speed in the file twi.h to

Code: Select all

#ifndef TWI_FREQ
  #define TWI_FREQ 100000L
  #endif

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

Re: GPS integration

Post by nhadrian »

Hi Alex,

today I tested my idea about wrong direction.

Today I tested the swapped calculation I mentioned earlier (I changed in the i2c GPS code which uses the calculations from multiwii code, so should work in multiwii code too):

Code: Select all

void GPS_distance(int32_t lat1, int32_t lon1, int32_t lat2, int32_t lon2, uint16_t* dist, int16_t* bearing) {
  float dLat = (lat1 - lat2);                                    // difference of latitude in 1/100000 degrees
  float dLon = (lon1 - lon2) * cos(lat2*(PI/180/100000.0));      // difference of longitude in 1/100000 degrees
  *dist = 6372795 / 100000.0 * PI/180*(sqrt(sq(dLat) + sq(dLon)));
  *bearing = 180/PI*(atan2(dLon,dLat));
}


Changed the sign here:

Code: Select all

      errorAngle = constrain(2*rcCommand[axis] + GPS_angle[axis],-500,+500) - angle[axis] + accTrim[axis]; //16 bits is ok here


and positive DirecionToHome is serialized:

Code: Select all

     serialize16(GPS_directionToHome);


Now, the arrow shows the RIGHT direction to home, and the GPS code itself works OK, I tested today in several take-offs, and field tests.

BR
Adrian

PS.: EDIT: sun is shining in Hungary... ;)
Last edited by nhadrian on Sat Mar 17, 2012 7:13 pm, edited 1 time in total.

User avatar
fr3d
Posts: 97
Joined: Sun Feb 06, 2011 11:21 am
Location: Cappelle la grande near the ch'ti village
Contact:

Re: GPS integration

Post by fr3d »

Wayne wrote:Alex you are the man!
No more MEGA freeze!
Now if you could do something about the forcasted rain and snow we are to get here this weekend......
Thank You!!!!


and wind or fog in north of france ....
plz !!!

:mrgreen:

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: GPS integration

Post by Bledi »

no comment I want to flight !!!!!!!!!! and my living room is really to small for my new ARwiiDrone !!!!

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: GPS integration

Post by LuFa »

any plans to increase the GPS accuracy for the final 2.0 ?
or will the gps code unchanged for the 2.0 ?

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

We have a feature freeze now. Gps is working for now. Development will go on after 2.0.
We need do fix all bugs for 2.0.

Nils

Fritz
Posts: 11
Joined: Fri Mar 16, 2012 8:48 am
Location: Germany

Re: GPS integration

Post by Fritz »

Bledi wrote:you have I2C errors ! your I2C link with the I2C GPS is not working.
One reason is perhaps your I2C speed. If it's not 400Hz you need to change the speed in the file twi.h to

Code: Select all

#ifndef TWI_FREQ
  #define TWI_FREQ 100000L
  #endif


Thank you!

With me is in the set twi.h 100,000th I have now changed times. kan test it but not until tomorrow.

hopefully it was because.

greeting fritz

Post Reply