Movement
Invent Logo

Welcome to Invent! You're using a miniature robot that's quite advanced. You can program it using drag-and-drop blocks but you can also use languages like Python which are used by professional programmers and engineers.

Invent can be connected over WiFi, and has rechargeable batteries. On the main robot board is also a pushbutton, two color-controllable LEDs (lights) and a speaker.

It has two super-accurate motors that can move in precise steps and even a pen holder to allow it to draw pictures. There are connectors at the front to allow different modules to be connected. Here we've connected two 'eyes' that can detect obstacles. There's also a sensor that can detect and follow lines.

Movement
The remote

Invent! can also be remote-controlled. If you have a remote you can use it to move the robot around but also do all sorts of other things. The remote is a complete programmable computer by itself so you can write programs for the remote as well as programs for the robot itself, to allow the two to communicate.

The remote
Assembling the robot

First attach the drive module to the main board. You need to align the two black connectors on the main board with sockets on the drive module.

Assembling the robot
Connecting the drive module

Press down on both sides to connect the two modules.

Connecting the drive module
Attaching the magnet

Now turn the robot upside down. Attach the magnet module by aligning the pins on the plugs with the sockets under the main board.

Attaching the magnet
Take care ...

Take care that all four pins on each plug go into the sockets underneath.

Take care ...
The finished robot

When it's fully pushed-in, it will look like this.

The finished robot
Powering up

Turn the robot on by sliding the power switch towards the 'On' position. You should see some lights turn on:

  • The white light labelled 'PWR' should now be on
  • The red 'LOW' light will turn on when your battery needs to be recharged
  • The yellow 'CHRG' light will turn on when you are charging the battery using a USB cable

The 'STAT' light is the one to look at now. It shows the status of how the robot is connected to the WiFi. If it goes red and then green, then go to the next step. If it goes blue, then skip ahead to 'Access point mode'.

Powering up
Connecting using a WiFi network

If the light turns red, the robot is trying to connect to a WiFi network. If it's successful, it should turn green within a few seconds.

If the light stays red, the robot can't connect to the WiFi. This is most likely because it hasn't been set up with the correct WiFi name and password.

If your light is now green, proceed with the next step. If the light is blue instead, jump ahead to the 'Blue light' step below.

Connecting using a WiFi network
Getting the robot's address

Look closely at the label on your robot. It has two 6-character codes. You'll need to enter the bottom code (the one in bold) in the next step. It doesn't matter whether you type it in uppercase or lowercase. The characters will only consist of the numbers 0 to 9 and the letters a to f. (So if you see a '0' it will be the zero digit not a letter 'O').

For our robot, we'll need to use the code 'fd62ec' in the next step.

Getting the robot's address
Connecting

Go to the website http://code.inventblocks.com/ui/ and click on the WiFi icon shown.

Connecting
Entering the address

Enter the bold code from the label in the 'Address' box and then click the 'Network' button.

Note: Using the https URL will only provide the option of a serial connection. Use the https link if you are connecting to your robot using wifi.

Here are the two versions of the link:

https://code.inventblocks.com/ui/

http://code.inventblocks.com/ui/

Entering the address
Success

After a few seconds the connect icon shown should go solid blue and look like the cables are connected. If it looks like the screen shown, your robot has connected. If it stays black and looks disconnected, there has been a problem. In this case, you should:

  • Check your robot has connected to the WiFi (the green light is on)
  • Check your computer is connected to the same WiFi network
  • Check you have entered the robot's code correctly in the previous step

If your robot connected properly, now skip forward to 'First Steps'.

Success
Access point mode

If your light when red/green and you've connected to your robot, skip ahead to 'First Steps'.

If your light turned blue instead, then your robot is in access point mode. This means that it has created it's own WiFi network that you can connect to. In this case, you first need to check the label and look at the 6 character code in bold. Your robot should create a network with the name 'InventXXXXXX' where the 'X' characters are replaced with your robot's code.

Go to your network settings and connect to this access point before proceeding.

Access point mode
Connecting

Go to the website http://code.inventblocks.com/ui/ and click on the WiFi icon shown.

Note: If you use https in the URL you will only have the option of a serial connection to your robot.

Connecting
Clicking the network button

Make sure that the 'Address' box is empty, and then click the 'Network' button.

N.B. We're not entering an address here as we're connected to the WiFi network the robot itself has created, so there's only one robot that it's possible to connect to.

Clicking the network button
Success

After a few seconds the connect icon shown should go solid blue and look like the cables are connected. If it looks like the screen shown, your robot has connected. If it stays black and looks disconnected, there has been a problem. In this case, you should:

  • Check your robot has created it's own WiFi network (the blue light is on)
  • Check your computer is connected to that same WiFi network (it will be identified by your robot's code)
  • Check the 'Address' box was left empty in the previous step

If your robot connected properly, now proceed to 'First Steps'.

Success
First steps

Click on the 'Invent!' menu on the left to access the blocks we'll need to control our robot, and drag a 'Move 5cm wait' block to the right where there is some empty space.

First steps
Running your code

Now press the play button shown. Your robot should now move forward 5cm and stop!

Running your code
The generated code

Click on the 'Files' tab and then on the 'codes.bipes.py' file in the file manager as shown.

On the right of the screen you should see some code. This is the Python version of the 'block' code we've just created. The robot actually runs Python code and when we press 'play', it converts the blocks to Python.

We're going to code now in Python, but at any point if you are struggling to get code working, you can create a block-based version on it, and then see what Python code has been created from it. It's also a great way of learning how to do new things in Python.

The generated code
Imports

Have a look at the code that's been created. It's really simple. There's only two lines.

The first line is:

from invent import *

We'll be using this line at the start of all programs we write. This line imports the library needed to control the invent robot. The asterisk means 'everything', so we're really saying 'from the 'invent' file, import everything that might be useful!

We'll be using more 'import' statements later when we need to do things that are in different libraries.

Imports
Move

The second line is:

move(5,true)

Whenever we want to move the robot, we need to use this command. The two things inside the brackets are called 'arguments'. They're the values that the 'move' function needs.

The first one (5) is the number of centimeters to move.

The second one (True) means to wait until the move finishes before continuing to the next command. We'll explain more about this later.

Move
Code from scratch

Now instead of converting blocks to Python code, we're going to type our code from scratch.

Open up 'Notepad' and type in the commands shown here.

Rather than going 5cm forward, this time we should go 10cm forward, and then 10cm backwards (negative 10cm).

Code from scratch
Saving the code

Go to the 'File' menu, and select 'Save As'.

Now select where you want to save your file (we've selected our 'Documents' folder), and enter the filename 'Test.py' as shown.

Finally click the 'Save' button.

Saving the code
Sending to the robot

Back on the web browser, click the button shown.

This button is used to upload code to your robot.

Sending to the robot
The uploaded code

Navigate where you saved your 'test.py' code and select it.

You should then see on the File manager, the 'test.py' file appear.

When you click on it, the code you saved in notepad should be visible on the right.

The uploaded code
Running the code

Now press the 'play' button next to 'test.py'.

You robot should run your code and move forward 10cm and then backward 10cm.

Running the code
Making a change

Try changing the distances you are moving. Here, we've changed them both to 1cm.

Make sure you click the 'Save' button shown ...

Making a change
Running the changed code

Now click the 'play' button again. Your robot should now move as you've asked it to.

N.B. If we start a new programme, we need to create it first in a text editor (like 'Notepad') but after saving it and uploading it to the robot, we can then make changes, save it, and run the changed version directly on the robot.

Running the changed code
Using the console

Now click on the 'Console' tab, and enter the command :

move(1,True)

into the black box underneath. If you type it exactly as shown, your robot should move forward 1cm. (even capitalisation is important - try typing 'true' instead of 'True' in the command above and you'll find it doesn't work!)

The 'Console' is a place where we can type in commands and have them run immediately, without having to create a full programme. The console is great for testing things out.

Using the console
Turning

Now let's try another command. This time, type :

turn(90,True)

Your robot should turn 90 degrees clockwise!

N.B. You'll notice we haven't typed the line 'from invent import *' into the console at any point. However, when we first ran our code that we wrote in 'Notepad', we asked the robot to do this, so we don't need to do it again. However, if you turn the robot off and on again and reconnect to it, you'd need to enter this 'import' statement again before using any 'move' or 'turn' statement.

Turning
Back to the file editor

Now go back to the 'Files' tab and into the 'test.py' program if it's not still showing ...

We've now got a challenge to do, and as it will have quite a few commands to run, it will be easier if we type them in to the 'test.py' code and save them before we try it. That way if it doesn't work the first time, we can change the code, save it, and run it again without having to type all the commands in again into the console.

Back to the file editor
Rescue the astronaut

Now you've got your robot moving, it's time for your first challenge. Your robot is on Mars and it's trying to rescue a lost astronaut. We've got a small 'Mars' here but you might have a larger one.

You'll need to go forward, turn around and go back to where you started to complete the challenge. If you're successful you'll collect the astronaut using the magnet on the front of your robot!

We're not giving to give you any more clues here - we're sure you can find the commands you need to complete the task ... good luck!

Rescue the astronaut
Saving your work

It's important as you complete these challenges, that you save the code so that you can go back to it later.

If we just keep editing the 'test.py' program every time, every time we save it, we'll have lost the solution to the previous challenge.

We suggest you copy and paste the code that you have created back into 'Notepad', and use the 'File | Save As' command to save a copy of your working code to your local PC. Give it a sensible name like 'Astronaut Rescue.py'. The '.py' means it is a Python programme.

Saving your work
A better way

As we're about to embark on writing code for a new challenge (moving in a square), a better way would be before we start coding, to save a blank programme (using 'Notepad') with a sensible name before we upload it to our robot.

Create a blank Notepad file, and save it as 'Square.py'. Then upload the file to your robot. Once you've done that, you can exit Notepad and continue coding directly on the robot.

Move in a square

Your next challenge is to move your robot in a perfect square. You'll want to go forward, turn 90 degrees, go forward again, turn 90 degrees again, and repeat this process another two times.

Move in a square
Loops

Try typing the code shown and running it.

If you solved the previous challenge just by having loads of 'move' and 'turn' commands, you might be pleasantly surprised how this short code can do the same thing.

The line:

for count in range(4):

tells the robot to execute the code that follows 4 times

N.B. In Python, any code that's running 'withing the loop' must be indented. You'll notice here that we've added two spaces before the 'move' and 'turn' statements. These spaces are important. Both lines must have the same amount of spaces in front of them for the code to work properly.

from invent import *

for count in range(4):
  move(5,True)
  turn(90,True)
Hints

So what do we mean by an outer loop and an inner loop? Here's the basic structure of what your code will look like.

  • 'timesaround' is just a name we've given the variable that will go from 1 to 10 each time we go around the outer loop
  • 'sides' is the variable for the inner loop that goes around the four sides

N.B. Note that we've carefully indented our code here. Each time you go into another loop you need to indent by another two spaces

from invent import *

for timesaround in range(10):
  for sides in range(4):
    # your commands go here
Multiple squares

Can you now get your robot to go around a square 10 times?

Hint: You could just increase the number of times you moved forwards and turned. Alternatively, you could use two separate loops. An outer one that repeated 10 times, and one inside it that repeated 4 times to make the square movement.

Hint 2: If your robot starts to move away from a perfect square after going around a couple of times, you might want to change the turn amount very slightly. It could be that you need to tell your robot to move slightly less than 90 degrees (or slightly more).

Rescue mission

Your next challenge is to rescue the astronaut again, but this time to move around the outside of the planet.

Hint: You'll need to do lots of little moves and little turns to succeed. You'll have to do all of these moves inside a loop. It's up to you to work out how many times through the loop you need to go, and how far each movement and turn needs to be to follow the curve of the outside of the planet as closely as possible.

Rescue mission
Mine sweeper

Your next challenge is to create a minesweeping robot. You may be using an activity mat like the one shown, or your teacher might create an arena using other objects or markings. If you're using the mat shown here, we're really just interested in the large circular dashed line. Your robot must start outside of this line and collect the 10 'mines' that are randomly scattered inside this line. The 'mines' are small objects that get picked up by a magnet and can include things like coins, stell washers, or small nuts and bolts.

Your challenge is to collect as many mines in the shortest possible time. Read the next couple of steps to find out the rules and some tips ...

Mine sweeper
Rules
  • You can stop collecting at any time, but any mines left will result in a 10 second time penalty added to your time
  • Your robot can drive outside the central circle, but not outside the outer arena rectangle
Tips 1

There are two things you will need to consider to be as successful as possible:

First is the ALGORITHM your robot uses is important. This is the process your program follows. For example, you might want to cover all of the area like you would mow a lawn - by moving in long lines, and then turning around at the end of every line. But you might be able to think of a better strategy.

Read on for some more tips ...

Tips 2

The second thing you can change is the HARDWARE design of your robot. Although you can't change the basic robot and the magnet, if your class set has some technical Lego, you can use it to make some add-ons. The two blocks at the front of your robot can accept Lego pins - once these are inserted you can then attach other Lego pieces. The picture here shows some ideas for robot football (which will be a future challenge), but you'll need to create something that works best for your 'mines' which will be much smaller and lower than the 'football' shown here.

If you don't have access to Lego, you can make something out of paper (or thin card) and sticky tape that you can attach to the front of your robot. Read on for the last set of tips ...

Tips 2
Tips 3

If you are making some sort of hardware addition to your robot, think what you are trying to accomplish. You probably want to 'funnel' the mines towards the magnet where they will be collected.

One final tip: if you are using Lego, there are some 'pins' that are designed to allow parts to freely pivot. You might find these useful as it might help in allowing your 'funnel' mechanism to drop closer towards the floor. Your mechanism will need to be fairly low to not move over the top of the mines rather than collecting them!