This article appeared in BrickJournal Issue 30, 2014


In the last installment of the MINDSTORMS articles we looked at how to program your robot to drive in a straight line.  And while that is a lot of fun to go backwards and forwards, at some point you’re going to want to turn corners.  To get started, grab your RileyRover or RetailRover that you built for the last lesson.  In fact, any two wheeled robot will be fine for this activity.  While there are a couple of ways to get your robot to turn, we’ll concentrate on using the ‘Move Steering’ command that we used previously for our straight line.

The Steering input can be used to change how tightly the robot will turn.  You can either click and drag the slider bar or type in a number.  The direction is defined by the value you enter, -100 gives you a sharp left while 100 gives you a sharp right and 0 will make the robot drive in a straight line.

 

 

Choosing numbers and slider positions between these extremes will make the robot turn in gentler arcs.  Keep in mind that the way the robot is setup may have an impact on which way is ‘left’ and ‘right’.  If you remember, I had to cross over my motor cables in the RileyRover design to make sure that if I say ‘left’ in the programming, that the robot does in fact go left!  If you find that your robot turns right when you say left, switch the left and right motor cables on your design.

Crossed over Cables on the RileyRover

Figuring out how far to turn is a little more complex.  Let’s take an initial challenge to make the robot turn around completely, ie. 360 degrees.  When most people are asked to make their robots turn around in a full circle (360 degrees), they will typically type in 360 degrees and proceed to run the program.  When run however, if they are using the RileyRover, they will find that their robot does not actually turn 360 degrees but in fact far less.

This occurs because the Move Steering block is designed to control the wheel of the robot, not the whole robot.  If we observe just the wheel, we will find that it does in fact turn exactly 360 degrees, just as it was told to do.  The angle turned by the robot however is dependent on a few different conditions such as the size of the wheels and the distance between the wheels.

Calculating the required duration to make the robot turn 360 degrees is best done experimentally.  Every robot design is slightly different, so the number of degrees required to turn a robot completely around may vary significantly, even with robots that look similar.  In addition, the surface that you are running your robot on will also affect its behavior.  A robot on carpet will behaved differently to a robot on polished wooden floorboards.

 

Try it out!

Set your program up to make your robot drive in a sharp turn to the left.  Experiment with different values in the ‘Degrees’ Input (or ‘Rotations’ input if you’re using them) and measure how far the robot turns each time.

Once you have discovered what value you need to make your robot turn a complete 360 degree turn, a little bit of Math with enable you to calculate what you need to do a half-turn, quarter-turn, in fact any angle at all!  Now in reality there are a few things that might mean this is not exactly right: friction with the floor, carpet vs hard floor, squishiness of tires, etc., but the Math does get us very close to what we are trying to achieve.  Tweak it a little and you’re good to go.  For my RileyRover, running with the Education Edition wheels (bigger than the Retail wheels), I needed 785 degrees of my wheels to do a full 360 degree turn around.

Start putting together some movements!

For my first challenge, I wanted to make my robot drive forward for 500mm, do a half turn and then drive back to where I started.  By stringing together several Mover Steering Blocks, I was able to achieve this.

How did you go?  Now try putting down a small obstacle course or maze and see if you can program your robot to get to the end.  Good luck!

Dr Damien Kee has been working with robotics in education for over 10 years, teaching thousands of Students and hundreds of Teachers from all over the world.  He is the author of the popular “Classroom Activities for the Busy Teacher” series of robotics teacher resource books.

You can find more information at www.damienkee.com or contact him directly at damien@damienkee.com