Getting started with MiRoCloud¶
Prerequisites¶
- The MiRoCloud webpages require Firefox web browser to work properly.
- You have to be connected to
eduroam
to control the physical robots. - Depending on the setup, some users might require connection to the University VPN.
- MiRoCloud credentials were sent out to everyone in a separate email.
Danger
Do not try to reset the password you were given, as this will corrupt your account.
If at any point you experience login issues, please notify the teaching team through the Discussion Board.
Logging in¶
Open your web browser and head to the Consequential Robotics' MiRoCloud hub:
cqrhub.com.
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:
"MIROcode 2021 release" is the most recent version of the software, which you will be using. Normally, there shouldn't be a need to use a legacy version, so keep that selection as is.
Info
Sometimes you might see the following message. This means that either you didn't shut down your previous session properly or your account is already connected somewhere else. If this happens, just click on the reconnect now
.
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 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.
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.
Info
In Firefox, you can also use Ctrl + [+/-/0]
to zoom in/out or reset your view.
On 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).
Warning
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 periodically do some action (e.g. press 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/respawned. - 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.
Tip
All three buttons are very important, so make sure to remember where they are located.
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.
Success
Make sure to adjust your zoom level so that all the block groups fit within your screen.
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.
Don't be afraid to experiment, as most of the blocks are fairly intuitive to use.
Tip
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.
Example 1. 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!).
Example 2. Clap then nod¶
In this example the MiRo is nodding its head upon hearing a clap. You can produce a clap by clicking on the corresponding button.
This example is interesting because it showcases blocks from different groups: loop control, time control, sensors, speaker, 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
(Or just proceed further if you're feeling bold!)
Making your own program¶
Now it's time to try making your very own program, see if you can implement some of the ones given below?
The process is simple: drag-and-drop the required blocks on the canvas, connect them in the way that fits the logic of your program and change the values in the blocks to those that you require. Easy!
Once you're happy with the result, click Play on the simulator control panel to run your program.
Tip
Remember to save your MiRoCODE programs on your laptop regularly.
If you are using a University laptop, we advise you to create a separate COM1005 folder on your student U: drive for this purpose.
Exercise 1. Clapper control¶
Using claps to control the duration of MiRo's actions, program a sequence of movements to drive MiRo from its starting position into a stack of cans on the left. Boom!
Exercise 2. Watch the Edge (sonar)¶
Program MiRo to lower its head and use its sonar in the nose to measure the distance to the surface of the table.
Can you make it go forward and stop when it sees a cliff using just the sonar? (You'll have to disable the built-in cliff reflex in the Program Start block to see your code work)
Exercise 3. Playing with LEDs¶
Can you make MiRo's LEDs blink as if it's an emergency vehicle?
Upon detecting a stroke on back, MiRo should start turning on the spot and changing the colour of each LED from blue to red in a clockwise manner (one LED at a time, five full circles).
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.
Make sure to upload the screenshots and/or .mirocode
files (even if not finished) to the corresponding submission box on Blackboard, as instructed.
This is it for the tutorial this week, hope you enjoyed it, and we will see you next week!