Getting started with MiRoCloud¶
Prerequisites¶
- Firefox is the preferred browser (and is essential to control the physical robot).
- Your device needs to be connected to eduroam and be on the University VPN.
- You'll need your MiRoCloud credentials, which were sent to you in a separate email.
Danger
Do not reset the password you were given, as this will invalidate your account.
If at any point you experience issues logging in, please notify the teaching team through the Discussion Board.
Logging in¶
Open your web browser and go to the Consequential Robotics' MiRoCloud hub
You should see the following login page:
Log in using your MiRoCloud username and password provided to you in a separate email.
Launching a MiRoCloud session¶
Once logged in, you should see something like the following:
To start the simulator, click on "Open". An AWS virtual machine on the other end will start booting a new session (or "instance", as we call it). Wait about a minute ot two for it to load, the new session should appear under the APPLICATION LIST pane. Once that's done, click on the "Launch" button to launch the MIROcloud session (shown below).
Once everything has been loaded successfully, you should see something like the following:
Getting familiar with the interface¶
As you can see, there are lots of things on this page, so it's easy to get carried away!
Let's have a look at each panel separately, in clockwise order.
Zooming in and out
In Firefox, you can use Ctrl + [+/-/0]
to zoom in/out or reset your view.
You can adjust zoom levels for the GUI elements and the simulator view independently.
Be aware that depending on the resolution and zoom level not all block groups can fit on your screen.
Simulator view (right hand side, top)¶
The biggest window on this side has a view of the Gazebo simulator with the MiRo robot in it, sitting quietly on the tables alongside some other objects. This is the default view angle, but you can pan, tilt and zoom in/out with your mouse.
At the very top, you can see an info panel that shows the status of the simulator, arrows for adjusting the size of the left/right parts of the screen, an option to reconnect cameras if they stop transmitting video, and a "burger" drop-down menu for loading other worlds (we'll get to that later).
Session termination due to inactivity
Make note of the timer that says "The session will expire in N minutes".
The simulator will shut down after 15 minutes of inactivity, so if you want to keep it running make sure to do some action periodically (e.g. pressing the clap
button)
Below that, the top right control panel contains four buttons that interact with the simulator:
- The Play/Pause button is used to halt the simulation (note that this is different from starting/stopping your code!)
- The three buttons to switch modes of interaction with the objects inside the simulator:
- Selection
- Translation
- Rotation
Give each one a go, but make sure to resume the simulator once you're done.
Then, on the left hand side there's a hidden menu to change simulator options, view the scene tree or add some generic shapes/lights. For now, the most useful from all of those would be the three "reset" buttons.
- The first one
Reset World
resets the world completely, together with the running clock. Note that static objects are not reset. - The second one
Reset Model Poses
resets just the non-static objects. - The third one
Reset view
moves the camera to its default pose.
Moving on, at the bottom left corner of the simulator window you will see three buttons that will allow you to interact with MiRo: Clap, Simulate Head Touch and Simulate Body Touch, together with the camera video feeds, which show the world as seen from MiRo's eyes.
The interaction buttons are useful when you want to trigger the corresponding sensors (touch or sound), which can be used in your program to emulate physical interaction with MiRo.
Main control panel (right hand side, bottom)¶
The main control panel is where you control the execution of your code. The upper panel is used to control the simulated robot (which you'll be doing today), while the bottom one is used to control the physical robot (which you'll be doing next week).
On the right, you can get an overview of the readings from the various sensors on board MiRo. Below is a breakdown of all the various components (look for the corresponding numbers on the image above):
-
The microphone icon shows the overall sound levels (in the simulator this only works for the
clap
button at the moment) -
On the left MiRo icon, outward waves indicate proximity to an object, as detected by the sonar in the nose. The fewer purple waves, the closer the object.
-
Also on the left MiRo icon, the 28 grey bars show all the available touch sensors. The individual sensors will turn green when activated.
-
Again, on the left MiRo icon, four golden dots represent light sensors, measuring the illumination levels. The brighter the dot, the brighter that side is.
-
Wrapping up with MiRo icon on the left, there are the two cliff sensors looking to the sides (in reality they're front-facing). Each sensors will turn blue if it detects an edge in front of it.
-
On the right MiRo icon, the speaker lights up when a sound is being played.
-
Finally, the last bit here are the 6 bars on the right MiRo icon that show the status of LEDs (Due to technical limitations of the simulator, it is not possible to show them on the robot's shell). When lit up, the LED view will show the corresponding colour of the LEDs on the MiRo's back.
Phew! Moving on.
Blocks and canvas (left hand side)¶
The "burger" style main menu in the top left shows three options when you click on it: Save Program, Load Program and Clear Canvas.
The programs that you develop can be saved as .mirocode
files on your computer, this is what the Save and Load buttons do.
The Clear Canvas simply deletes everything from the canvas, quite handy when you want to start a new program.
On the canvas itself in the bottom right corner there are four buttons: centre the view on the code, zoom in and out and a bin into which you can drag-and-drop unnecessary blocks.
Finally, we're getting to the most important part in the Simulator — MiRoCode blocks. The blocks are organised into two large sets, 'Robot' and 'Control', which in turn are divided into various groups based on what they do.
Blocks types¶
There are three types of blocks, roughly distinguished by how they connect and interact with other blocks. These types can be thought of as Starter, Action and Conditional blocks (note stylisation here and below).
- Starter blocks act as starting points for independent code parts. All of your other block chunks should start with one of the Starter blocks. At the moment there are only three of them: Program Start that indicates the main body of your program, and two types of Function blocks, which let you create functions with and without output.
- Action blocks are your main building blocks, and are the most ubiquitous. These blocks indicate actions in your program and are executed sequentially, top-down. There are two further subgroups: discrete and continuous blocks. Note the difference in usage and select the appropriate type of block for your situation.
- (D) Discrete blocks are executed immediately, and sometimes have the word 'start' in their description. Example:
Start Moving [Forwards] [Slow]
. The duration of their execution is meant to be controlled by other blocks. - (C) Continuous blocks act for a certain (usually specified) amount of time, at the same time halting execution of the code further down. Example:
Move MiRo [0.3] metres
.
- (D) Discrete blocks are executed immediately, and sometimes have the word 'start' in their description. Example:
- Conditional blocks are there to help you with variables and functions, conditional statements, arithmetic operations and so on. They can be identified by the position of their connector, which is usually on the left side of the block, so they are plugged into other blocks as variables or functions.
Block tooltips
Hover your cursor over any given block to show a tooltip with the block's description.
Output (console)¶
When running a program, you can see the status of the execution, as well as any outputs produced in the terminal window. You can also see whether the code is running on the robot or in the simulator.
There are two buttons in the top right corner of the console: the one on the left copies the output to buffer, while the one on the right minimises/expands the window.
Running a program¶
To help you start, let's look in more detail at a couple of built-in code examples. Click on the "burger" menu in the top right corner of the canvas to get a list of pre-installed programs.
Built-in program: Fibonacci numbers¶
This is the simplest program to showcase the capabilities of MiRoCode as a programming tool. When you click on Play on the simulator panel, this program simply prints out a sequence of Fibonacci numbers in the terminal below.
Make note of the Program Start block, which serves as an entry point for any program. It has two settings: Position Correction and Cliff Reflex. The former tries to make sure MiRo is following movement commands precisely, while the latter prevents MiRo from driving of a cliff (most of the time!).
Built-in program: Clap then nod¶
In this example the MiRo is nodding its head upon hearing a clap.
(You can simulate a clap by clicking on the corresponding button).
This example shows blocks from different groups: loop control, timers, sensors, audio, actuation and finally some custom Python blocks with commands for printing in the console.
Further examples¶
Have a look at the remaining built-in programs:
edelweiss.mirocode
square_dance.mirocode
whos_there.mirocode
Trying things on your own¶
Now it's time to try making your very own program, see if you can implement any of the ideas below?
The process is simple: drag-and-drop the required blocks on the canvas, connect them in the way that realises the logic of your program and change the values inside the blocks, if needed. Easy!
Save your code
Remember to save your MiRoCODE programs to your laptop — it's likely you'll want to reuse some code snippets later!
If you are using a University laptop, consider creating a separate COM1005 folder on your student U: drive for this purpose.
1. Hitting the cans¶
Program a sequence of moves and turns to drive MiRo from its starting position into a stack of cans on the left. Boom!
Bonus points
Instead of hardcoding the trajectory, can you use claps to control the duration of MiRo's movements?
2. Watch the Edge (sonar)¶
Program MiRo to lower its head and use its ultrasound sensor in the nose (sonar) to measure the distance to the surface of the table.
Bonus points
Can you make MiRo go forward and stop when it sees the edge using just the sonar?
(You'll have to disable the built-in cliff reflex in the Program Start block to see the effect of your code)
3. Emergency lights¶
Upon detecting a stroke on the back, MiRo should start turning on the spot and change the colour of each LED in sequence.
Bonus points
Can you make MiRo's lights flash as if it's an emergency vehicle?
4. Friendly MiRo¶
Upon detecting a pat on the head, MiRo should wag its tail and generally express a friendly behaviour. Have MiRo go back to the default pose after 5 seconds without touch.
Bonus points
Can you use all of the available "cosmetic" joints in programming this behaviour?
Wrapping Up¶
It's great if you got all three programs working as expected, but if not — don't worry!
The point of this tutorial was to gently introduce you to the interface and programming basics at your own pace.
This is it for this week's tutorial, hope you enjoyed it and see you next week!