0
$\begingroup$

I'm confused how to set up an initial heading for my mobile robot project. I've determined heading from gyro integration and also using magnetometer readings. Gyro initializes at 0 and magnetometer initializes to a random value between -180 and 180 based on direction of the imu.

My question is how should I set up this parameter initially. I plan keep the range between -pi and pi, but do i want to use the global magnetic field as my reference and navigate based upon this, or do i want to offset that value to agree with the gyro at startup?

Thanks for any help!

$\endgroup$
0
$\begingroup$

magnetometer initializes to a random value between -180 and 180

It's not a random value, it's

based on direction of the imu.

If your question is

how should I set up this parameter initially.

Then you need to decide what you want it to be. Do you want zero to be whatever direction the robot is pointing when it's powered on, or do you want zero to be magnetic North?

Either way, you need to grab the magnetometer output on startup (or maybe average the first five or ten samples.) Store it in a variable called absoluteInitialHeading.

Then, if you want zero to be magnetic North, you set the initial gyro angle to be that absolute initial heading and you're done.

If you want zero to be initial vehicle heading then you can subtract the absolute initial heading from all subsequent magnetometer readings.

$\endgroup$
2
  • $\begingroup$ I'm looking for the "recommended" way to do this. Would most suggest to set it up a certain way? Is there an industry standard for this in robotics, or does it depend upon use case? $\endgroup$ – Stephen Taylor Feb 6 at 20:29
  • $\begingroup$ @StephenTaylor - It doesn't matter; the "recommended" way is the way that meets your needs. Why are you even using a heading? I would imagine it's so you can navigate to various waypoints, so then the thing to consider is how your waypoints are defined. This would be related to how your coordinate axes are arranged - if you are trying to get to a point <1, 1>, are those x- and y-axes arranged relative to magnetic North? If not then basing your heading on magnetic North isn't going to help you at all. $\endgroup$ – Chuck Feb 7 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.