View Single Post
  #2   Spotlight this post!  
Unread 31-01-2008, 23:25
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How to get robot to drive straigth using shaft encoders

I can't guarantee a "best" way to do it, but I can tell you a simple way. When you want to start going straight, set both the left and right encoder counts to zero. Every so often, perhaps in the Default_Routine() for convenience, read them both and compute the difference (or more likely the sum, as they will probably be counting in opposite directions). When the result is positive, tweak one side's motors to run a little slower and the other side a little faster than otherwise commanded. When the result is negative, do the opposite.