Hello!
I am a new coder for a 2nd-year vex v5 team located in a rural area. I have been trying to code an odometry system for the Override season after our autonomous code for pushback was incredibly inacurrate. No one at my school has done anything like this before so I don’t have any resources aside from what I can find online. This is also my first major project in python/text. My system has two horizontal dead wheels w/ encoders (left and right) and one perpendicular dead wheel w/ encoder (back). It is set up like the examples in Odometry | Purdue SIGBots Wiki .
When using only the left and right encoders, the code works fine, and the position updates normally; however, when I try to add the back encoder to account for the arc, the x and y start gaining when the robot turns and after a little under 180 degress they start decreasing. The offset for the back encoder is about 7.5".
I am not sure how to fix this and I would appreciate all the help I can get!
Here is my current formula for the back encoder (I code in VexCode Python):
if deltatheta == 0:
deltaB = (currentBposition - prevBposition)
else:
deltaB = 2 \* math.sin(deltatheta/2)\*((currentBposition - prevBposition)/deltatheta+TB)
I got this from the arc length formula by looking at the Odometry | Purdue SIGBots Wiki
article but I might have used it incorrectly.
I then subtract math.cos(theta + deltatheta/2) * deltaB from the x and add math.sin(theta + deltatheta/2) * deltaB to the y.
When I move the robot manually back and forth on the x-axis, the B value works fine, but if I try turning at all, it gets messed up.
Also, if I take out the B value completely from my x and y equations, they work perfectly fine, so I think it must be the B value equations that I have wrong.
Again, I am super new to both coding and Vex robotics, so I apologise if this is not something that I should be asking about on here, but I ran out of other options so I figured I could give it a try.
Thank you to anyone who takes the time to help me with this!