Friday, May 29, 2015

Mentor Post: Turning a Two Wheeled Robot

Our iRobot Create is based on two drive wheels. All movement of this robot can be understood in terms of the relative and absolute speed of these wheels. This post attempts to layout an intermediate method for turning a robot that allows turns to be computed with the robot in motion.
 The geometry of a turn. We can define any turn as a combination of the angle of the turn and the radius of the turn. This is a step forward from last year’s pivots. A pivot being a turn with a zero turn radius.


The advantage of this turn is that we can maintain speed rather than stop to make the turn. This allows the robot to move more smoothly. 

 With a two wheeled robot we need to determine what wheel speed is necessary to make this turn. It is important to realize that the turn can be made at any speed simply by controlling the individual speeds of the wheels. In this post we will only consider constant speed turns, these turns would result in circles instead of spirals. By limiting the turns we simplify the math. The question becomes how do we compute those speeds?


If you look at the drawing above you will see that the left wheel has to travel a longer distance than the right wheel. In order to make this turn correctly the two wheels will need to travel these two distances at the same time. How can we compute the travel distance?
We can see from this drawing that the two wheels each travel an arc of a circle defined by different radii. If we let r be the radius of the turn and d is the distance from the center of the robot to the center of a wheel, a = r + d and b = r - d. Of course these values would be switched if we made a left turn. The actual distance is also a factor of the angle of the turn.

 We will need to compute the arc of a circle. If you need a refresher check out Cool Math. The arc of a circle is the angle * radius. However that result uses radians. If you are keeping your angle in degrees then you will need to convert it.

 Today’s task:

 Right a method that computes the wheel speeds for a turn for a given radius. The method should rely on a call to int[] Robot.getCurrentWheelSpeed() and return left and right wheel speed below Robot.MAX_LEFT_WHEEL_SPEED and Robot.MAX_RIGHT_WHEEL_SPEED. Make certain the routine efficiently handles positive and negative angles. 

 Ending the Turn

 How do we decide when our turn is complete? We can use a sensor that returns our orientation, we could use dead reckoning by computing a time based upon wheel speed or we could measure the actual distance travelled by each wheel. Ideally we would combine all these methods to reduce error.

Computing turn wheel speed is one of the fundamental building blocks for moving the robot in this year’s iARoC competition.

No comments:

Post a Comment