View Single Post
  #8   Spotlight this post!  
Unread 27-01-2009, 17:40
ellisk ellisk is offline
Registered User
FRC #1540
 
Join Date: Dec 2008
Location: Vancouver, WA
Posts: 41
ellisk is on a distinguished road
Re: Using encoders for traction control help

Hi, thanks for the suggestions. Here's what I'm currently using, and it seems to work better than my other algorithms, but still very poorly (worse than no correction at all ).

Here is the algorithm:
Code:
// transVel: the velocity according to the wheels (transmission)
// omniVel: the velocity of the robot (off the omni wheels)
// realWheel: the PWM value currently being sent to the wheel (not currently used)
// desiredWheel: the PWM value the joystick says the wheel should be
// maxSpeed: the maximum velocity of the robot
float correctForSlip(float transVel, float omniVel, float realWheel, float desiredWheel, float maxSpeed)
{
	// make sure that there's enough of a difference
	const float slipThreshold = 30.0;
	if (fabs(transVel - omniVel) < slipThreshold)
		return desiredWheel;

       // We are slipping.
	
	// calculate what speed we are saying we should go at
	// This should be whatever the omni wheels say
	float correctSpeed = omniVel / maxSpeed;

        // at this point, we can return correctSpeed
        // however, this makes it really jerky, so we this following instead:
	// Average them, to still give the drivers some control
	return (desiredWheel + correctSpeed) / 2.0;
}
In short, it sees if it's slipping, and if so, it converts the velocity of the robot into a PWM value (float correctSpeed = omniVel / maxSpeed; ) and then averages that with the desired PWM value according to the joystick.

So, the step I'm stuck on is the "Limit commanded_speed based on maximum acceleration to prevent slipping" step from Abwehr's algorithm. Does anyone know of any better ways of limiting the commanded speed?

Thanks,
-Kevin