Odometry Data

Hello. I am working on a software for odometry and I am having issues keeping a global/ final x/y position. We are using two tracking wheels for now but the third will be implemented once the code is debugged. My position refresh code is running in a while loop inside of void autonomous. On the brain screen, I programed it to display the current x/y position change (the difference in x pos 10 msec ago and now) and angle change. The change x/y is showing but when I try to take the previous position (10 msec ago) and add it to the total change to find the total change, it doesn’t display the correct number. The weird thing is that the final angle code is working correctly and is displaying the right angle. All three x/y/angle calculations are done in the same format. All it displays is the change x/y and it goes back to zero once the robot isn’t moving. The code for the refreshing is down below. Keep in mind, the code posted is only the adding and subtracting for the total change in position. All other mathematical equations are not shown so people can’t copy and paste. All input and sensing values are refresh and measured every 10 msec. Any Help will be greatly appreciated.

Are you doing any rotation to Robot_X_Position_Change to account for the change in angle of the robot?

What do you mean by that? We use the angle in the calculation in the change of x and y. The robot knows what direction it is heading at all times.

Is Previous_X_Robot_Position a local variable?

yes (Post must be at least 20 characters)

Try moving Previous_X_Robot_Position and Final_Robot_X_position to the global scope.

does that mean to the top of the code. Like above preauto? All variables are stored right below the picture below. The values are then updated in the auto and sent back to the top to represent the new value.

All of the values are stored under this section of code.

Those are all in the global scope. I can think of two things that might be happening:

  1. You are incorrectly calculating the values. Since you don’t want to share that part of your code, you will just have to double-check you are doing everything correctly.

  2. You are printing it wrong. You might be formatting it wrong or something. It would be helpful if you posted that part of the code.

1 Like