go in a strait line

Ok,

i am programing in EasyC and was wandering if it is posible to have a robot with shaft encoders self correct to make the robot go in a straight line. :confused:

you can program it to do that with dead-reconing. if you can program 2 shaft encoders yes you can

ok, so how might i go about doing something like that?

if right 255 and left 0 doesn’t make it go straight, then you should check your drive system for extra friction such as a badly placed bearing block or too much spacers in the axles
if you still have issues make a test code and make it go 157 and 97 (±30)
see which side it leans towards and adjust as you see fit

thats the method we used and it works like a charm our current “friction” is +30/-24 from 127

In autonomous, you would place if statements (saying that if the right encoder reads greater values than the left encoder, power the left drive motor(s) more/lessen the power on the right drive motor(s), vice versa…) within the while statements (saying how many ticks the encoder has to reach before it stops).

In driver control, you can place if statements (saying that if the right encoder reads greater values than the left encoder, power the left drive motor(s) more/lessen the power on the right drive motor(s), vice versa…) within a if statement (saying that while the joysticks read this value, etc…) within the while loop.

Excuse my horrible pseudo. If you want me to write you an actual snippet, I’ll gladly help.

Don’t do what murdomeek said and try to correct drive friction by changing relative PWM values. While that works, you can use shaft encoders to automate that exact process.

I don’t know the logic behind it, but it seems simple enough to figure out with good code. Get encoder values from both sides, compare them, and if they’re uneven, get them to within an acceptable range of each other.

i have a video tutorial that a friend of mine made. do you have V2 or V4? the video is for v2 but the concept can be used for V4 as well