2.21

## Begin Robotics

Skip to 0 minutes and 1 secondSo let's see how I got on, trying to do the exercises in the second week.

Skip to 0 minutes and 10 secondsSo this is the web page, and I've set the speeds up. So the When No Wall Is Seen. The robot will go forward. I've ticked the reverse-left motor option. When a wall is detected on the left, the left motor goes forward, the right motor stops, so the robot will turn away from it. And then opposite and so forth. So if I press start, we see the robot's doing fine. That is, until it hits the wall. When you can see the wall, it goes back. Then it can't see the wall so it goes forward, which is particularly dumb. So what you actually need to do is that when you do see a wall on both sides, go back but turn.

Skip to 0 minutes and 46 secondsSo if I turn that minus 4 to minus 2, you see it's now turned away quite happily. And it goes along, and when it detects the wall here, it turns. And it turns. It also works with a complex environment like so. Mind you it does get stuck in the corner. Again it's sort of turning one way then the other way. I have to give it a little nudge. But then it's OK. So it is working all right. I'm going to scroll up so I can see the track controls, and I'm going to put track on. And then I'm going to go racing. And does it now work? It sees-- oh, it turns, yes.

Skip to 1 minute and 27 secondsIt's turning the right way, so it's going around the track. And it's going to turn again. Yeah. Who's a good ERIC. Hey, presto. That's worked quite nicely. OK. What about doing a return race? Is it going to work? So let's go racing. And no, it's turning the wrong way. That's because, it's turning right going this way, but it's got to turn left that way. So I need to change the speeds for when it sees an object on both sides. Now when I go racing again from the start, you'll see it's going there around and yes. It turns the right way. So with very simple commands, the robot can navigate a race.

Skip to 2 minutes and 24 secondsThough it does need to know which way it's going.

Skip to 2 minutes and 30 secondsNow put it into line follow mode, same speed, press start. It goes back, finds a line, and its happily moving around on the line, same speeds. I bet if I were to start it in the middle there it's going around in a circle and not finding it. So perhaps we want it to move around in a bigger circle. So let's try something like minus 8 and minus 7. And now it's found the line.

Skip to 2 minutes and 58 secondsSo the same sort of commands for avoiding walls, also works for following lines.

Skip to 3 minutes and 10 secondsAnd here's the second exercise. Can we steer to the lights? Well again I've setup the speeds so that when no light is seen the robot goes forward. When the light is just signal left, it turns towards it. So the left motor goes a bit slower. The right motor stays at the same speed and it will turn. When it gets closer, it gets a bit slower still. So if I press start, you'll see that it works. Yep. Sees it, turns. Sees it, turns. And now it gets slower, and it finds it. It works quite nicely. Stop it. Put it back to initial position with the wider beams. You'll find it works just as well.

Skip to 3 minutes and 57 secondsGo straight towards it rather than turning towards it. So that's fine. If I want the robot to steer towards the light then veer away, then I want to change things when the light is much closer. So if instead of turning towards it we turn away-- put the robot back in the initial position and press start, we will see it comes along, sees the robot, turns towards it, happy. And then when it gets very close it zooms away. OK. So it does work.

# What you should expect to see in the simulations

If, for whatever reason, you aren’t able to try out these exercises for yourself, Richard has recorded this brief video to show you what to expect. He demonstrates what happens when he manoeuvred the mobile robot around a race track and in an arena to avoid various obstacles.