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.

Mentor Post: User Interface

Last year Anthony did a great job of making a functional, if not pretty user interface. This year I am asking him to focus on producing a more informative interface and building it in a way that is understandable to the team and extensible.

The team would like to show a map on the phone display. To allow this to be build without requiring a functioning robot and full scale maze I am going to ask Anthony to port the maze simulator and build a UI for it in Android Studio.

I will encourage him to use MVC techniques to build the interface. This will allow him to apply the same interface to the robot code once it is ready. I am also asking him to at least review the material design techniques. I hope that if he follows some of the patterns he will find it easier to build the user interface and modify it as we move forward.

Maze Simulator Project
Getting Started with Material Design


Mentor Post:Back to Work

As we close out May and head into the competition month it's time to get back to work. The team was sidetracked by preparation for the AP exam. In addition there are more than a few blog posts that never really got completed and are sitting in draft stage. I will probably publish them today as-is but the content may be a bit out of date and not finished.

We still have work to do to get the physical robot ready. The lack of permanent placement of ultrasonic sensors and the phone are slowing us down a little. Today's lesson will have the goal of coming up with a project plan, defining the physical changes to the robot and starting work on the UI and some new robot functions.

With robot camp less than a month away it's time to really focus on the work at hand make progress on this year's entry.