Differential Drive Odometry in LabVIEW

I couldn’t find any LabVIEW code out there that did differential drive odometry. I probably was looking in the wrong places. Regardless, I decided to try and tackle it myself. Attached is the resulting code in hopes that it will help another team. If nothing else, it is a fun example to play around with. :slight_smile:

I put together a sample VI that calculates some useful information if you have a this type of drive system with encoders at each side. The calculations are based on a PDF found here:

In your main loop, supply the VI with distance readings from left and right wheel encoders and and the wheelbase of the encoder wheels. It will output Distance Traveled, Heading, and the current X and Y of the robot.

Just as a disclaimer… This VI has only been implemented in the attached sample application. I’ve not seen how it behaves yet with real encoder data. YMMV.

This is my first post here. I’m new to LabVIEW (as I’m sure most of you are) and this is only our team’s second year in FRC. I’ll do my best to answer any questions about the code. Any feedback would be appreciated!

I’ve attached a screenshot of the front panel in action along with the source files.



DifferentialDriveOdometry.zip (58.5 KB)

DifferentialDriveOdometry.zip (58.5 KB)

Hi brian.

I was looking for an example of this topic and this post is all I got. Thank you very much for sharing!

However, I´m confused about some details in the code (calculating Wheel Rates, wheel base…). The original documentation (odometry.pdf) that you linked is nowhere to be found. Do you have it? Could you upload it, please?

I´m aware that this topic has 2 years so I think it´s meaningless to ask it now, but it would help me A LOT if its possible for you to share the documentation (or your knowledge :slight_smile: ).

I have made something very similar but i have used a picture instead of a graph.

While I haven’t tested your code, our code looks almost identical. This is how we’ve been doing autonomous for quite some time now. Excellent job.

I wasn’t able to find the original Odometry.pdf anywhere in my source code repository (ack!). I did find this page which seems pretty close to what I remember reading. I haven’t looked at the code in a couple of years, so I may be way off. (c:

I did find a couple of updated versions of the CalculateOdometry.vi in my repository. I assume I fixed something, but who knows what. I have attached them in hopes that they may be of help.

I don’t have LabVIEW installed at the moment so I have no idea what I’m posting here. It might be a good idea to shield your eyes when opening these…

Best of luck!


CalculateOdometry.zip (21.1 KB)

CalculateOdometry.zip (21.1 KB)

Thank you all for the info.

Yesterday I found 2 interesting links:


(Same aproximation as brian used)


(There is a PDF, page 20, same aproximation but more “in depth”)

With everything I got and your replies, I think I understand the whole process, except the very beginning… brian calculated:

Left Wheel = Speed + Turn Rate
Right Wheel = Speed – Turn Rate

What exactly is “Turn Rate”? Obviously thats not an angle, I think it´s a transformation of some data input from the wheel encoders, but Im not sure where it comes from. I didn´t found anything about that…

(Well, I know it´s only a “simulation” and you actually set it manually from the instrument panel, Im talking about how it applies in a real situation).

Sorry if I ask something stupid, I´m a noob in robotics, this is my third month studying this field ::rtm:: Which I have to say, I found it pretty hard, time-consuming, but also fascinanting!

BTW, I have to check better and compare the last VIs brian posted.

Oh, and maybe you can find this interesting, is a simulation comparing real trace VS Dead Reckoning aproximation: http://rossum.sourceforge.net/tools/MotionApplet/MotionApplet.html

If “speed” is the vehicle forward speed command in feet/sec, then the “turn rate” is equal to (L/2)*omega, where omega is the vehicle rotation rate command in radians per second and L is the vehicle trackwidth measured in feet. The above formulas will then give the required tangential velocity (in feet per second) for the left and right wheels (which can be converted to wheel rpm by multiplying by 360/pi and dividing by the wheel radius in inches).


Thank you very much, Ether :slight_smile: Finally I understand the whole process.