mpy-IMU / fusion with FXAS/FXOS chips

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
roland_vs
Posts: 85
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

mpy-IMU / fusion with FXAS/FXOS chips

Post by roland_vs » Tue Nov 07, 2017 12:47 am

Dear all,

and maybe Peter @pythoncoder

I'm trying to get the fusion library to work (micropython-IMU) using different sensors.
I use the FXAS21002 and FXOS8700 chips to get gyro, accelerometer and magnetometer readings.

What I really need is compass information so I tried to use the fusion module to get heading information.

So far I seem to have correct gyro (degrees/s), acceleration and magnetometer information nicely reported at an ODR=100Hz and gyro with 250DPS, accelerometer in 2G mode... in three tuples and feed that into the fusion module.

Basically the code calls

Code: Select all

fuse.update(imu9DOF.acc(), imu9DOF.gyro(), imu9DOF.mag())
and prints the fuse.heading.

The output stabilises in 5 iterations around like 162.437, -2.018, -15,300 for heading , pitch and roll. If I rotate it over the axis, going up/down and left/right follow the movement, but the heading is not much changing when rotating the sensor and definitely not 0-359 what I was expecting

So I wonder if somebody has a dataset of acc/gyro/mag sensor measured values that can be used to feed into the fusion code to see what is supposed to happen and a way to verify if the numbers are in the same order of magnitude..

Anyone?

Thanks already!

User avatar
pythoncoder
Posts: 3506
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by pythoncoder » Tue Nov 07, 2017 6:33 am

I feel your pain ;) I've seen this symptom many times and the cause was invariably the magnetometer readings - mags are sensitive devices and the Earth's magnetic field is small. When testing indoors the Earth's field can be affected by local conditions which can vary over quite small distances. So the mag needs calibrating in the precise location where they it is to be used. Testing can be easier outdoors, but you still need to consider the effects of currents in wires and fields from motors if the device you're developing has these.

Before testing with sensor fusion calibrate the mag. Then set up a simple loop which periodically reads and displays the mag (x,y,z) vector. Slowly rotate the device around each orthogonal axis and ensure the readings behave as expected.
Peter Hinch

User avatar
roland_vs
Posts: 85
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by roland_vs » Tue Nov 07, 2017 9:01 am

@pythoncoder

Peter,

Calibration helps a lot. The reading is CCW is positive and CW is negative to 180. So that was easy to fix by adding 180 to the negative. Also my headless system could use a display at this point :idea:

Thanks a million.

R

OutoftheBOTS_
Posts: 628
Joined: Mon Nov 20, 2017 10:18 am

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by OutoftheBOTS_ » Tue Dec 05, 2017 3:45 am

does anyone here have experience with putting IMU's on robots with motors??

My experience with IMU's so far has just been head hurting and haven't done a lot because of just how hard they r to get to work well.

I do plan to want to put one on my my robot sbut so far haven't invested much time in because others have told be the magnetic noise from the motors sends the compass crazy then this goes through the fusion filter and makes the output data corrupt.

Has anyone here made them work on moving robots with electric motors??

User avatar
pythoncoder
Posts: 3506
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by pythoncoder » Tue Dec 05, 2017 6:56 am

This is an interesting question and it would be good to know the answer. But it isn't MicroPython specific - perhaps you'd get more feedback on a general robotics forum.

Do report any findings - my balancing robot has an IMU but I haven't attempted to use the magnetometer from a general sense of pessimism on this issue.
Peter Hinch

OutoftheBOTS_
Posts: 628
Joined: Mon Nov 20, 2017 10:18 am

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by OutoftheBOTS_ » Tue Dec 05, 2017 10:20 am

Thanks for your response.

I haven't yet invested much time in the IMU because all the robot guys that I talk too don't seem to have good things to say about their experience with IMU's mainly because of the problems with magnetometer.

At some point I will have to bite the bullet and have a go, I was hoping to be able to get advise from someone that has been successful first but it seems there is only a very few out there that can make it work well.

User avatar
pythoncoder
Posts: 3506
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by pythoncoder » Wed Dec 06, 2017 10:44 am

Magnetic fields tend to be fairly short range so, depending on the design of your robot, it might be possible to mount one on some sort of stick. But bear in mind the calibration issue mentioned above. I first learned this was necessary when I bought a Google tablet a few years ago: applications like Google Sky fail to orientate until I go through the process.

The odd thing is that a traditional compass doesn't need special treatment to work outdoors.
Peter Hinch

OutoftheBOTS_
Posts: 628
Joined: Mon Nov 20, 2017 10:18 am

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by OutoftheBOTS_ » Wed Dec 06, 2017 1:58 pm

This is what I have seen guys mounting them on poles sticking up from their robot to minimize the problem.

User avatar
roland_vs
Posts: 85
Joined: Tue Dec 08, 2015 8:28 pm
Location: Netherlands
Contact:

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by roland_vs » Thu Dec 14, 2017 9:14 am

Maybe some of the above problems can be handled using the "MotionCal" utility.

Check out: https://github.com/PaulStoffregen/MotionCal

Regards,

Roland

OutoftheBOTS_
Posts: 628
Joined: Mon Nov 20, 2017 10:18 am

Re: mpy-IMU / fusion with FXAS/FXOS chips

Post by OutoftheBOTS_ » Sat Dec 16, 2017 8:39 pm

Thanks for that :)

It just keeps showing me just how complex it is to get accuracy orientation of my robots.

It looks like it will take me some serious hours coding and experimenting to get both the mag calibration and the fusion filter doing what I want.

It will be interesting to see how the MotionCal handles the changing magnet environment from the motors ramping up and down speed as the robot drives around.

The BNO055 from bosh has a built in MCU that runs a calibration and fusion filter on board the sensor chip and I brought I but found like everyone else it had very poor performance. People found if they put it in the car and went for a drive up the street it's orientation was worse than just using a gyro and nothing else as the constant re-calibration of the mag meant the orientation error was more than the gyro drift just using a gyro and nothing else.

I am seriously considering looking at buying this module as it seems to be one of the best sorts of combos for solving all the problems everyone keeps finding https://www.tindie.com/products/onehors ... -solution/

Post Reply