Odometry with optical shaft encoders

Hello people. I need help. So me and my team are planning to use optical shaft encoders for odometry but I don’t know how to code or map the route in autonomous in vex code v5 pro? Would anyone find a tutorial because I can’t find any or plz tell me how to code it? Thanks!



Dude that does not help. That is probably PROS. I need in vex v5 pro code. I don’t know how it helps. Is there a video that codes on screen and teaches at the same time?

Is this a question of not understanding how tracking wheel odometry works or not knowing how to implement it? If you’re confused on how it works, I’d suggest taking the time to read through this pdf from 5225A on position tracking.

1 Like

He is referring to the fact that you should research the topic your self. People on the forum will help you with specific issues (“My heading is overshooting” or “This motor is overheating”). However, you must put in work your self first. Try reading the 5225A document, or try watching videos online to learn about odometry.


Additionally here are some helpful YouTube playlists that should guide you through your odometry development process:

98881A Odometry Devlog - YouTube (98881A’s odometry devlog at the start of the Turning Point season)

What is Odometry? - YouTube (Rex Liu from team 4253W created a 3 part series on odometry. Basically the PiLon’s document but explained in visual form)

Odometry Part 1 - Educational Resources - YouTube (Head programmer of 5225A joined a VEXU team and this is an “educational library” of sorts. Videos 3 & 4 pertain to odometry).


I saw the video by Rex Liu. I understand how it works and where on the robot it goes. I just don’t understand how to code it in v5 pro code. That is what I need help with. And I will chack ou the pdf rn.

Getting encoder values will look something like this:

currentL = (EncoderL.rotation(rotationUnits::deg))*(lWheelRatio); //gets the rotation of the left wheel

In robot-config.cpp you want

encoder EncoderL = encoder(Brain.ThreeWirePort.C);

with the top wire of the encoder plugged into port C and the bottom wire plugged into port D.


Is there some way to break it down to a middle school stand point? Or should MS teams look towards something before Algebra ideas? Just curious, I was reading a little into the pdf, and its a lot of math that I’m pretty sure my kids have not reached yet.

If they don’t have a good foundation of geometry and basic trig, it will be hard to code an odometry function.


Ya both those are high school courses in our state, alright we’ll figure something else out thanks :slight_smile:

Usually when someone says “skill issue” it’s a joke. However I’m going to say it seriously.

The only real solution here is to get good at coding and reading documentation. I will say, v5 pro is a little lacking in the greatest documentation, but it has a ton of example programs you can find on the forums if you look for them. In those example programs, you should hopefully get an indication on the caption that it uses something involving encoders (I’ll leave that up to you to figure out), and then be able to see it’s usage. This is how I learn code when something has not great documentation, and it works very well. Especially when you can actually test your code and not just guess what the outcome should be based on the source code because you didn’t have access to the brain almost all summer (im not projecting, you are)

Being a good programmer also means you know where to look for for information. You know that the same program can be made in PROS and Vexcode pro, so you know there’s a commonality. You just have to find it. So find it, learn something new about using different libraries to accomplish similar tasks, and quite literally “get good”.

plus it’s a lot easier than you’d expect to use vexcode and pros interchangeably. I became fluent in the pros api in about 3 weeks, and its not insanely difficult to get code from pros into vexcode. Probably much easier to do vice versa, but if you try to understand what each line does, the big picture comes. Plus you literally have a tutorial. (Unless those tutorials are using okapi I don’t think you can use that in vexcode).

1 Like