-
Notifications
You must be signed in to change notification settings - Fork 0
Tank Pure Pursuit
Driving a tank drive autonomously provides many challenges that are not present in driving holonomic drivetrains because of the limited control that you have.
On a tank drive it is more difficult to drive to a point on the field because of the limited control. This provides multiple ways to control the robots movements. There are multiple main ways to translate the robot successfully. Some of the simpler and more elegant ways this can be completed are driving in a arc and pointing and driving. The most smooth and efficient way to drive the path would be the arc but the most simple would be the pointing and moving but you have to move less efficiently.
- Point and drive
- Pros
- Less complex, just 2 PIDs, already in use and tested on other robot although slightly different.
- Cons
- Slower, turn then move
- Less smooth
- Pros
- Arc
- Pros
- Faster, driving and turning at the same time
- Smoother driving
- Can be combined to easily follow path
- Cons
- More complex, more math.
- Pros
To drive in an arc we will need a few paramaters of the arc that we want to drive. These parameters are the curvature of the arc and the speed you want to drive that arc. Calculating these variable is already done in our pure pursuit updatePoint() function that gives a curvature value and you just have to set the max speed for the paths. The tank pure pursuit would calculate the speed that the robot would be driving at given the current distance on the path, to accelerate acceleration and deceleration. We also take into account the curvature of the path and limit the robot's speed to reduce possible inaccuracies when trying to drive while turning too fast. The tank drive class will control the motor speeds by using this equation to correctly drive the drivetrain in an arc.
Left speed = speed * (2.0 + curvature * track width) / 2.0
Right speed = speed * (2.0 - curvature * track width) / 2.0
When testing this code in a simulator I found that when running the robot at top speed the drivetrain will not drive in the correct arc. I found that this problem was caused because the drivetrain class was sending motor speeds that were too high for the drivetrain to get to. This caused the side that was being driven with more speed is not able to get to that speed, and the drive does not turn as far as expected. To fix this in the control code I added a special statement where if one side of the drive is greater than the speed inputed to the function, the code will scale the speed to make the largest number less than the max speed.
In tank pure pursuit we control the drivetrain by getting the speed value from the pure pursuit class and the maxAcceleration and curvature, and the local lookahead vector from the point data that us updated in the pure pursuit class. Our first approach to control the speed while on turns, and limit the deceleration was to divide the current local lookahead vector y value by the lookahead distance. This value also gave us a side value that we could use to find which was to drive the robot, an effective curvature scaling, and deceleration at the end of the path.
When testing this solution in the simulator it worked really effectively to slow down the robot. When testing on the robot, it decelerated really well too and it worked for the 2 competitions that we went to with almost the same version of pure pursuit. After the second competition, we found that there where problems with the end behavior with the algorithm, such as the robot erratically moving once it is close to or finished the path, and the robot accelerating and decelerating too fast for the robot to catch up.
We had a big problem with the end behavior that we had set that, after the final point is closer to the robot than the lookahead distance we target the final point. This solution worked really well for holonomic drives that are able to move to the lookahead point effectively even if it is right next to it, where with the tank drive the entire drivetrain would have to turn, causing the robot to be far off angle by time it gets to the final point. There are several solutions to this, such as making the robot continue driving the arc it is driving, this should get it to the point, but following that could still leave it off angle. The solution that we found and settled on it having the last segment of the path go out infinitely so that pure pursuit will continue to follow that path.
With the way that we currently have to determine if the drivetrain is done driving the path, it finds the last point and finds how far we are away from it. This solution was great for holonomic drives because it is a lot easier to get to the point with that type of drive, but with tank drive if it doesn’t reach the done point by the time it is done it will have erratic motion at the end of the path. Also with the new solution to the erotic end behavior in theory the robot could go right around the circle and keep going forever because the path keeps going, and it will never determine that it is done with the path. To fix this we use the distance to the end of the path, from the closest point to the robot, instead of the robot distance to the last point.
The robot with this solution will start going straight to 100% speed then once it has gotten to the path go straight to 0%, this will not get to the point and probably tip the robot. To fix this we will need to have proper acceleration and deceleration code with pure pursuit. At first we tried a square root curve for acceleration at the beginning and end of the path, this is the intuitive solution for this, but when we tested this the robot would not accelerate at x = 0, because the sqrt of that would be zero, therefore it would not move. To fix this we added acceleration limits that limit the amount of acceleration at the beginning of the path to make sure that the robot doesn’t accelerate too much and doesn’t accelerate too little. This solution was very successful and it was what we are using on the robot.
- Home
- State machine
- Util classes
- Odometry classes
- Motion algorithms
- Feedback controllers
- Simulator