Traction Control in Autonomous?

I was wondering how you could integrate Traction Control while you are in autonomous mode.

What Traction Control requires is a constantly updating loop. The way we drive in autonomous is “Turn Motor On” “Wait a few seconds” “Turn motor off”

During those few seconds of waiting does the traction control variables update?

If they dont any ideas?

Something that we’ve been doing quite successfully is something to this effect:



double start = GetTime();

while (IsAutonomous())
{
	double time_elapsed = GetTime() - start;

	if (time_elaped < 0.5)
	{
		// time period of 0-0.5 seconds
		speed = .25;
		angle = some_N;
		rotation = some_N;
	}
	else if (time_elapsed < 1)
	{
		// time period of 0.5 to 1 seconds
		speed = .5;
		angle = some_N;
		rotation = some_N;
	}

	// ... and so on until 15 seconds
	
	myDrive.Drive( speed, rotation );
}
	

Doing it this way allows you to manually say what speed you want it to go at any given point, and as long as you ramp it up slowly you should be good. Clearly having real traction control would be better, but this works well enough for us and gets us out of the reach of the human player.

As a bonus, we use the gyro to get the angle of the robot, and some things that can set the rotation parameter of our bot based on our current angle relative to the field so we can say “point the nose in this direction”. Of course we have swerve/crab drive the so rotation stuff is a bit easier to implement since we can specify a heading and a rotation value.

We are using a simple ramp to drive in autonomous, of course we are only driving forward and spinning so that simplifies things a bit…:yikes:

How is your code set up for traction control? You may very well be able to take the teleop traction control, put it into a function, and call it separately from both autonomous and teleop.

If you would like an example of code that achieves this, I’d be more than willing to send it to you to analyze. Or, if you sent me your code, I could look over it and give more specific details on how to implement it.

Other than that, if you ramp up to speed, it will work – traction control is more ideal, but it’s not bad.

The traction control is setup using 2 encoders on each side of the bot.

It grabs the data from each encoder then stores it into a variable. If it detects the bots wheels are moving to fast (slipping) then is slows the motor speed down.

It detects slippage like this encoder1 stores variable new / Makes one loop / new becomes old / encoder stores new / compare new to old.

So basically it detects slippage and its suprisingly very accurate & works great for pushing people.