View Single Post
  #1   Spotlight this post!  
Unread 24-01-2009, 22:21
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Using encoders for traction control help

This pseudo-code should get you started...

Code:
commanded_speed = Get_Our_Desired_Speed()
robot_speed = Get_Actual_Robot_Velocity()
wheel_speed = Get_Wheel_Velocity()

speed_error = robot_speed - wheel_speed

// Detect if we are slipping
If absolute value of speed_error is greater than tolerance then we are slipping
{
  // If we are, get back our traction ASAP!
  Set commanded_speed to robot_speed
}
Else 
{
  // If we aren't slipping, let's keep it that way!
  Limit commanded_speed based on maximum acceleration to prevent slipping
}

Send commanded_speed to the motors
Close the loop between commanded_speed and wheel_speed with a PID controller (optional)
Hopefully this will be useful!

Also, keep in mind that if you turn differentially (tank-style), your wheels ARE going to slip a little bit. Take that into account or your idler wheel is going to freak out your traction control system every time you turn.