How to implement accelerometer, gyroscope, and magnetometer in SLAM robot?

Hi, i’m currently working on a project where i have to create a robot capable of performing SLAM. I was thinking i could send the sensor data from the Arduino to the Raspberry Pi 3 Model B+ where it would perform SLAM. The sensors being used are ultrasonic (HC-SR04), MPU-6050, LM-393 speed sensors, and a GY-273 HMC5883L magnetometer.

The goal of this project is to create an inexpensive system capable of performing SLAM. The goal is NOT to produce accurate maps of the environment, just a rough one. I have also attached a picture of the robot if you want to see what it looks like.

Anyway, to the question in the title, i know how to calculate the pitch and roll using the MPU along with a contemporary filter but have no clue what to do with the magnetometer. I have already looked into quaterions and Kalman filters and all that stuff but struggle to understand them. However, i think i’ll have to use kalman filters anyway for SLAM unless there is another alternative.

My question is, how would i implement, in terms of the code, the magnetometer with the MPU and contemporary filter in order to calculate pitch, roll, and yaw for use in SLAM?

Also, please feel free to suggest any possible improvements and ideas you would have for the robot. I’m open to all ideas. :slight_smile:

Thanks.

My question is, how would i implement, in terms of the code, the magnetometer with the MPU and contemporary filter in order to calculate pitch, roll, and yaw for use in SLAM?

What you want is called an AHRS for Attitude and Heading Reference System.

The best open source software for such a system is RTIMULib for Arduino and uses a quaternion based Kalman filter. It is no longer supported by the original author, but it works fine and has no reported bugs. I believe other people are carrying on the work.

You can read about my experience implementing it here.

Thank you, i'll have a look at it.