Two Wheeled Robot

While a four wheeled robot provides the best performance for a soccer robot, often it's not possible to have four wheels. For those times, we've put together some ideas that might help make your two wheeled robot move better.

Robot Position

It's important that your robot is facing the goal as often as it can. This helps to ensure that you are pushing the ball in the right direction and that your robot position matches your coding logic.

The key is to have the robot periodically check to see if it is offset from it's starting position. We don't want to check too often, otherwise it will get caught up always trying to straighten and not be able to move effectively.

Lets assume that every 2 seconds we will check to see if the robot is out of position and then make a correcting move.

The code will check every 2 seconds and test to see if the yaw is greater than 45 degrees, if it is out of position it will move to the left for a small period of time.

Likewise the right hand turn check:

Ball Chasing

Next we put the ball direction into a variable so that we can easily compare it to our known directions.

Some of our movements are pretty easy, if the ball position is zero, then we want to stop as no ball has been detected.

In the code above the loop has been broken into two parts.

  1. When the robot is driving forward: BallPosition is greater than 8 or BallPosition is less than 4. - These are our forward movements.

  2. Otherwise, we need to move backwards. Remember it's always better to get behind the ball and push forward. If the ball is directly behind us (i.e. position 6), we don't want the robot to go directly back, we want to choose a side and move to that direction.

From here we pick a sensor position and think about the movement we want the robot to take to get behind the ball. Often we want to have one motor value higher than the other to get it to move in the right direction. This will mean that the robot starts to face the wrong way, but our position check above will help get the robot into the right position (when correcting movements are made to the robots position every 2 seconds, see above). Your goal is to get the robot behind the ball so that when it straightens up it can push forward.

It takes a lot of testing, each robot will be different. Thats where the fun starts!

Last updated