I am trying to build a low-cost SLAM system with an MPU-6050 and GY-271 (magnetometer). Currently, i have a robot with an Arduino that collects the sensor data and a Raspberry Pi that (hopefully) will do the SLAM calculations.

I want my robot to be able to use all three sensor readings in SLAM to create a 2D map of the environment. However, considering that i want a 2D map, i will not need all the axis readings correct?

I read another post on here where one of the answers said that only the yaw from the gyroscope, and the x and y from the accelerometer would be needed.

  1. My question is, how would i implement this into my SLAM robot? I was thinking of passing the accelerometer and odometry readings through a kalman filter on the Arduino and then the same for the gyro and magnetometer readings. Would that be correct?
  2. Would i also need to use all the axis (x, y, and z) readings from the magnetometer? Or just one or two axis?


  • $\begingroup$ No one can help me? $\endgroup$ – Dwo Aug 8 '17 at 14:43
  • $\begingroup$ Are you saying that you want to trace your movements starting from a fixed position? Something like dead reckoning $\endgroup$ – Biscuits Aug 15 '17 at 17:43
  • $\begingroup$ Or, more specifically, innertial navigation? $\endgroup$ – Biscuits Aug 15 '17 at 17:50
  • $\begingroup$ I would say an inertial navigation system. My goal is to create a 2D AHRS. $\endgroup$ – Dwo Aug 15 '17 at 20:02
  • 1
    $\begingroup$ If I'm not mistaken, MPU-6050 has a built-in gyro and accelerometer with sensor fusion. It can also take an external magnometer to provide a complete AHRS. $\endgroup$ – Biscuits Aug 16 '17 at 5:33

Based on your comments thread, I think what you want is a Kalman filter. I think this ahrs implementation will be helpful for you. If you search "mpu6050 ahrs" you'll also find a dozen or so other implementations to look through. If you want you can modify it so that it explicitly sets the Z coordinate to zero, but it should actually figure that out automatically.

To map the room (and do SLAM), you will need a sensor which can tell you how far away the walls are. Sonor tends to be a good low-cost entry point, though it has plenty of implementation difficulties.

  • $\begingroup$ On the last thing you said about sensors. Do you think a sharp IR sensor attached to a servo would be a better solution? If a sharp IR sensor is more accurate than a sonar then shouldn't this make it easier to implement into the slam algorithm? $\endgroup$ – Dwo Sep 21 '17 at 12:10
  • $\begingroup$ Also, if the IR sensor is not accurate enough, then could I do multi scans with the sensor using the servo in order to get more readings? However, I read that if I were to do this, then I would need to use a particle filter would that be correct? (Sorry for asking so many questions) $\endgroup$ – Dwo Sep 21 '17 at 12:14
  • $\begingroup$ An IR sensor has a tighter beam so will generally give you better resolution. You can definitely do multiple scans to reduce sensor noise, but you still have to deal with position uncertainty (and uncertainty in the relative position of the sensor and the robot). IIRC a particle filter is a different way of solving the non-linear problem that relies on sampling from the posterior when it is too difficult to compute. It's a good approach, but I would recommend starting from someone else's implementation. $\endgroup$ – combo Sep 21 '17 at 14:40

Maybe you can checkout ROS on Raspberry Pi, they have various libraries and SLAM algorithms (such as Gmapping & Hector SLAM) that you can use.


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.