Tilt Compensated Compasses + Where to get GeoInfoSystems Library

Hey,
I’m building a gps controlled boat, and am in need of a compass. The first one I looked at was the HMC5843, because of its 3 axis, however I have now realised you can get 2 axis compasses that are still compensated for tilt.

Which compass would you guys recommend for my project? What compasses do you usually use?

Also, I’ve found a useful looking library for gps on fezzer, GeoInfoSystems.microGPS, however it states it requires the rest of the GeoInfoSystems library to work - I’m unable to find the other parts anywhere on the net, would anyone here be able to provide me with a link?

Cheers, X

If you want to give this a go I’ll try and help

The algorithms are here

www.xrsensor.com/pdf/liang.pdf

This is for a 2 axis compass

Cheers Ian

The URL link isn’t working for some reason…

That makes my eyes bleed. I’m only 16, haven’t done arrays nor vectors seriously at maths yet. Am I correct to understand that the hmc5843 does that for you, being a 3 axis compass?

PS: If any of you FEZ guys read this, you’ve got the character encoding wrong for these forms :slight_smile: Ahh the pains of charsets.

Have at it!
http://files.chrisseto.com/Aia

Thanks chris, is it all made by you?

And looking at your projects, that Rawr “thing”, am I correct to think its rather simular to what I’m making? - Read a set of co-ords, compare them to current location, use arctan to get the arc to target, use a compass to turn to target?

Oh noes, Just re-read the HMC5843 datasheet and realised that it is not, as I previously thought, tilt compensated.

Time to have a mental breakdown and cry :slight_smile:

In that case, Ian, I most likely will need your help

Yes, that library is totally done by me, although there was one small bit extracted from MFGps.

RWAR basically does exactly what you are doing, only on land. A small tip: Don’t skimp on the GPS. I am on my 3rd GPS unit and still not happy. I’ll be able to report back later this week if the 4th unit (http://www.sparkfun.com/commerce/product_info.php?products_id=9133) is any better.

RWAR’s complete source code is available below. I have no doubt it’d work right off the bat in your application, as long as you correctly set the ESC profile and tune the PID controller.

http://files.chrisseto.com/1tK

Would you be able to let me know what sensors you used for it? In terms of what compass, and anything else you might have. Looking at the datasheets, they all look the same, and I feel like a grandma shopping for a computer.

also, sorry I’m rather new to this stuff: "ESC profile and tune the PID controller. "? Whats an ESC and a PID?

EDIT: Just looked up the ESC you’re using. I’m rather short on money, so I recon Ill have to skimp on that on my project, and try to get away with just using variable power to two motors… PWM most likely. Looking at PID, I really do feel like a grandma again - what is it used for in your project?

+Looking through your code, what is the reason for remapping COM4?

Read up on this for PID control: PID controller - Wikipedia
The maths are a bit hard, so I don’t expect you to get it outright, but if you are 16, you have probably learned enough to understand the figure under “Summary”. It’s a lot easier to understand than it looks at first glance.

The PID is used to steer the car/boat/aircraft onto the heading.

The compass I used was a Sparkfun Razor 9DoF. This proved to be a pretty sound investment, and it does all of the tilt compensation for you. On a boat, you shouldn’t really need to worry about tilt compensation, however.

For steering with variable thrust, you can’t use PWM. You’ll have to use some form of motor control, maybe an H bridge.

If I were you, I’d buy a semi-cheap hobby grade RC boat and play with that. It may not be the cheapest option, but it will be very, very robust.

Of course, you could still go the differential thrust option, but you will need to figure out how best to input steering from that.

It might be good if you mocked up a driver where you could feed it a value (say: 90) and it would push both motors to full speed. A value of 0 would mean the left motor was stopped and the right was full power, and a value of 180 would mean the right motor was stopped and left was full power. This would emulate the steering servo exactly, and then you would not need to worry about the ESC driver.

You could then incorporate a collective system, where you could also define the speed as well as the turn direction.

As for cost, RWAR wasn’t the cheapest project, but that’s partially because I went overboard on a few things. Expect to spend a few hundred dollars for the IMU, GPS, boat and physical control systems (motors, etc).

As for sensors, RWAR has…

  • Sparkfun 9DoF Razor
  • GPS (Currently LS20033, this week upgrading it to a SkyTraq devboard from Sparkfun)

COM4 is remapped due to my use of XBees for data logging. The XBee isn’t used in the latest iteration of code, so there is currently no apparent use of COM4.

PID (and P and PI) are sets of logic used to course correct. Essentially it determines how far off course your bot is and is used to make an adjustments to get back on course.

A simple example (at least one that made sense to me) was trying to get faucet water to right temperature. You start off with mostly cold and some hot, and decide that you need more hot, so you turn it up. Then it’s too hot, so you turn down the hot a bit.

This constant adjustment to get to your goal is what a PID (or P or PI) controller does for you.

In Chris’ case, (I believe) he’s monitoring if he’s gone off to the left or right, and counter steers to get it back on track. He started off just using essentially a electronic compass (a magnetometer) and now is using GPS.

Thinking of your boat, it would be used to compensate for waves, tides or currents that push your vessel off course.

[quote]
In Chris’ case, (I believe) he’s monitoring if he’s gone off to the left or right, and counter steers to get it back on track. He started off just using essentially a electronic compass (a magnetometer) and now is using GPS.[/quote]

This is all correct.

The first step in the project was creating the heading hold autopilot to follow a heading. This is where all the PID stuff came into play.

The PID controller basically tries to figure out what the very most accurate bit of correction to apply to the steering is. It might be hard to visualize this, but if you are driving a boat, you will not just slam the wheel to either side depending on whether you are trying to go go right or left. You will make intelligent, smooth corrections to the wheel until you are on your intended course and then you will let off on the wheel and allow the boat to cruise.

The PID controller attempts to do just this, but it will never relax on the steering, it will always be maintaining some form of correction.

Ahhh thanks, I knew I had to do that, but I didn’t think there was a whole theory behind doing this. I was simply thinking “If error = x, make motors = y”, etc. That wouldn’t account for any external factors, but at the end of the day it should get me there.

And yes I have a RC boat… From the 70s :), I’m still looking at ways to take it apart without damaging it too badly.

And why should I not need to worry about tilt compensation? What about the boat rocking about etc? Would that not affect the readings?

Edit: For the SkyTraq GPS, would I need to attach an external Antena? If so, anything specific?

Let me know once you test that GPS, maybe drop me an email on dawid.kozielec@ gmail.com if you have a minute to do so please.

Chris … Is the source code for RWAR still available? The link you gave above in reply 6 is broken.

Link works (just tried it)
http://files.chrisseto.com/1tK