Skip main navigation

New offer! Get 30% off your first 2 months of Unlimited Monthly. Start your subscription for just £29.99 £19.99. New subscribers only. T&Cs apply

Find out more

Command a robot to do specific actions

Watch how you can command a robot to do specific actions in a simulation developed by Professor Richard Mitchell.
1.1
OK. It’s time for another exercise. This one’s a bit different. Rather than commanding to the robot to do something at one instance in reaction to it sensors, you’re going to command the robot to do something for a particular period of time, or to travel a particular distance, or turn through a particular angle.
22.2
So here’s the web page. Now if I scroll down so that we can see all the different bits at the bottom, what you’ve got is a robot in an arena, and by default there is this rectangular path. What you start to do is to experiment. So for instance, what happens if I want the robot to travel at speed eight and go forward 100 times? That’s what you do. And you can change the speed to say travel speed three and turn five times, and it will do that. So you start off by doing some experimentation to work out what speed and for how long will it take to get the robot from the start of the rectangle across to there.
67.7
And then do some similar experimentation to get it to turn through 90 degrees. And how to travel down the side of the rectangle. Eventually working out how you go from the start of the rectangle, all the way around, back to the beginning again. OK. Once you’ve worked out some of these, rather than interactively putting a number in, pressing forward, or pressing turn right, you can put in a string like this at the bottom. So if I reset the robot to the beginning, and then look at the string which says forward at speed two for 100 times, turn right, speed two for 10, forward, two for 10, turn left, three for 9. And then if I press Obey, it does that.
109.9
Going forward, turning right, and not going around back there. So it’s not a particularly useful command, but that’s what you can do. So after some experimentation, you should be able to have a nice string here which gets the robot to go all the way around the rectangle. Having done that, you can have a racetrack. Put the robot to the beginning here, work out again the commands to move the robot around the racetrack until he gets to the green area in the middle. And having done that, and it works, we’ll introduce what we call a hilled track. The key point about this is that there are areas here where the robot is going uphill.
152.8
Literally it’s a bit Escher-like rather than a real hill, in that whichever direction you’re going, you go uphill. This darker area here is a downhill one. And you will find that the commands that got you around the racetrack when it was flat won’t work when you’ve got these hills. Unless you put speed control in. OK. So work out the commands to go around with flat track, with the hills. And then see, with speed control, if you can find one command that will move you all the way around, whether you’ve got a flat track or the hill track. Optional, if you want to, you can change.
193.9
Instead of commanding the robot to move a speed for a certain number of times, specify instead travel for a particular distance. When it’s turning, turning through so many degrees. And see again if you can work out how to get the robot around the track. Have fun.

In this first exercise of Week 3, you will have the chance to command a robot to do some specific actions a certain number of times.

You need to work out how to move the robot around the rectangle. Before you start experimenting with the simulation, watch Richard demonstrate how the exercise works.

Ready? Move on to the next Step to open up the exercise.

This article is from the free online

Begin Robotics

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now