gps angle

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been playing with avr for some years now and have become quite proficient at assembler language.
I have a new project that I am working on. It uses 2 gps units that are at a distance of no more than 1 mile apart. gps A receives the co ordinates of gps B via a radio link. gps A then needs to calculate a bearing and distance to gpsB. I intend to use a separate micro at gpsA to parse gpsA"s position and receive B's position. then feed the 2 lat longs to an atmega 162 via usart to do the math. I have looked at the math required and its way beyond what I can do in assembler.The final output only has to be accurate to 5 or 10 degrees and distance to 200 feet, therefor if there is a shortcut in the math that would also work
Does anyone have a c file that can do this or point me in the right direction.
Many thanks Bazza.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do it in C.

I am reasonably proficient in assembler, and this is something I would never attempt in assembler.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://www.movable-type.co.uk/sc...

Should be easy to use the basic formulae given there or the example Javascript in C.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try doing a haversine in assembler! I think his problem is not the equations, but the fact that he can't figure out how to do it in assembler.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My problem is I do not know "C"
I am intending on learning C but I think this will be too complicated a project to learn a new language on.
Bazza

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If your not talking about very great distances, just join the 'Flat Earth Society'. :D

Ignoring the sphericity, given positions A and B, subtract the two from each other to obtain the difference in latitude and longitude... Dx Dy.

Bearing is then atan2( Dy, Dx)... rotated 90 degrees, of course
Distance is sqrt( Dx^2 + Dy^2 )

EDIT

I just saw you don't know C. I think this could be a great project to become familiar with it!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I am intending on learning C but I think this will be too complicated a project to learn a new language on.

You could turn that the other way around.. Since this project obviously involves some "advanced" math operations, this would be an excellent opportunity to see one of C's advantages over assembler.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's my program that calculates distance between two lat longs using the haversine formula. My goal was to test the 64bit double prescision floating point routines in the imagecraft v8.11 c compiler and time how long the calcs take. You could look at the jpl haversine formula in the comments, then look at the subroutine that calculates it and see if it looks enough like regular old algebra that its not terrifying and scary, then step 3 would be dl the iccv8 compiler which has a free 45 day demo and compile it and run it, and step 4 might be dl AtmelStudio and recompile the whole thing using single precision fp and see if it still has sufficient accuracy. Probably will.

Attachment(s): 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ed William's Aviation Formulary is a must have link for anyone doing Great Circle Route, (or flat earth approimations), calculations.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Novatel do have receivers that will do this for you- but you'll pay for the privelege.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mikericetga wrote:
If your not talking about very great distances, just join the 'Flat Earth Society'. :D

Ignoring the sphericity, given positions A and B, subtract the two from each other to obtain the difference in latitude and longitude... Dx Dy.

Bearing is then atan2( Dy, Dx)... rotated 90 degrees, of course
Distance is sqrt( Dx^2 + Dy^2 )

Not quite. Dx=Dlon needs to be scaled by cos(lat).
The resulting distance is in the same units as the latitude.
Also, hypot is easier.
Bearing, from north, is atan2(Dy*cos(lat), Dx) radians.
The formula given also has a sign issue.
Quote:
EDIT

I just saw you don't know C. I think this could be a great project to become familiar with it!

At the very least OP will want to call some C functions.
I only see only two ways around doing at least some floating point computation outside a library function:
One is to convert the data to fixed point and write most of your own math functions.
Not pretty.
The other is to find the avr-gcc functions that do fp arithmetic.

'Tis probably simpler to learn enough C to write single-statement functions.

Iluvatar is the better part of Valar.

Last Edited: Mon. Jul 15, 2013 - 05:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks everyone. It looks like a crash course in C for my near future.
Bazza