# How to convert/transform robot local frame to global frame to use in Kalman Filter?

I'm currently working on the iRobot Create 2 platform using a RaspberryPi (Python) and ROS. I have an indoor navigation/ GPS system, which can provide me with x,y coordinates within its coordinate system. I have thus far implemented a Kalman filter in MATLAB for practice and now am trying to implement on the Create. I also have an IMU but haven't yet implemented that.

I'm currently trying to figure out how to subscribe to the topics from the Marvelmind indoor nav system (but that's a different issue).

My Kalman filter is using [x, y, xdot, ydot], and I believe those should be in the global frame (which I'm taking to be the coordinate system provided by the Marvelmind indoor nav system). That being the case, I can easily get my x and y position from that system; however, I'm not sure what to do about the xdot and ydot. Currently, I have that information from the Create odometry (Twist msgs), but those are in the local frame (since the robot can only go in the x (forward) direction and can't go in y (side to side)). Do I need to transform the local to the global? If yes, do I need to use the IMU to get the angle to use for the transformation?

I feel like I have many pieces, but I'm just not sure how to piece them together. Any advice would be appreciated. Thank you!

It sounds like you are saying that the navigation system tells you the robot's x and y position within a global reference frame and that the IMU tells you the robot's speed (but not direction) within the same global reference frame. Let's say that these are your two types of measurement.

The kalman filter requires that you provide a transformation from the robot's state space [x,y,xdot,ydot] into the measurement spaces for each of your types of measurements. Here are the two transformations:

GPS: [x,y,xdot,ydot] -> [x,y]

IMU: [x,y,xdot,ydot] -> sqrt(xdot^2 + ydot^2)

Kalman filter also requires a motion model. I think you already have that part, but I'll include it just in case.

Motion: [x,y,xdot,ydot] -> [x + xdot * deltat, y + ydot * deltat, xdot, ydot]

It's okay if some parameters in your state, such as xdot and ydot, are not directly measurable. The kalman filter would still be able to make use of those parameters and narrow down their likely values based on how they affect x and y over time, even if you didn't have speed measurements. Just let the kalman filter work its magic. :-)

• Thank you for the reply (I'm just seeing this). I think I was able to get my Kalman filter to work (first modeled in MATLAB) and converted to Python. The results seem a little different, but it's working. I have decided to use the IMU in a separate KF to estimate the orientation only.
– Erin
Apr 18, 2018 at 1:22
• Much of the kalman filter’s power comes from combining input from multiple sensor types. I think you’ll get better accuracy by combining both sensor types into one kalman filter. Apr 18, 2018 at 2:16
• Yes that definitely makes sense. I think I've been so focused on the magnetometer (for yaw) that I completely forgot about the accelerometer. I'm a bit constrained with time for the moment, but I will definitely have to check that out later. Thanks!
– Erin
Apr 18, 2018 at 4:38
• If this answer helped you then please mark it as accepted. Apr 18, 2018 at 11:06