Your first .robot
View the structure
Once you have the
robotsparebin-starter robot open, you will see files on the left of the Robocorp Lab screen. The robot needs to have those files in place to work correctly. Read about the robot structure, if you are interested.
Open the robot file
tasks.robot file to open it in Notebook mode:
.robot files are text files. Opening them in Robocorp Lab in Notebook mode adds the possibility of running your robot directly from the user interface, and enables more advanced ways of working on your robot code.
The Notebook interface is based on the idea of cell: cells can be executed individually, rearranged, duplicated, etc.
Our starting robot has two cells: one for the
*** Settings *** section, one for the
*** Tasks *** section.
You can edit the contents of a cell by clicking on it.
You can add a new cell using the
+ button on the toolbar, and you can remove (cut) a cell using the
You can copy and paste cells, and rearrange them:
You can undo the removing or adding of a cell by pressing the
Run the robot
Great! The robot is ready for action. Press the
>> icon in the toolbar. A modal with the question "Restart Kernel?" appears. Click on
Restart. The robot completes the task of saying "Hello World!"!
View the task log
Your robot writes a log of everything it did during the execution of the task. When developing your robot, viewing the log lets you see what your robot did in detail.
After the task is completed, a
Log button appears at the bottom of the Notebook. Click on it to open the log file.
A log window opens. At the bottom of the window you see "TASK Say hello to the world". Hover over it and click the
⌄ icon (
Expand all) on the right to expand it:
On the last line in the log, you see "Hello World!". Hurray! The robot successfully greeted the world!:
Here's what it should look like:
The anatomy of a robot 🤖
What are small robots made of? Of settings, tasks, and keywords, mostly! These are placed in sections.
*** Settings *** Documentation Starter robot for the Beginners' course. *** Tasks *** Say hello to the world Log Hello World!
This robot has two sections. The
*** Settings *** section typically contains documentation, possibly some libraries, and references to other files. This robot contains only documentation. The
*** Tasks *** section defines the task for the robot. This robot has one task:
Say hello to the world.
To complete the task, the robot calls the
Log keyword. Think of keywords as functions, if you are familiar with programming. Keywords provide the robot with specific skills. In this case, writing to the log. The
Log keyword takes one argument. In this case, the argument is the text we want the robot to write to the log (
We'll discuss the robot anatomy in more detail in the next chapter, where you will teach your robot to open the RobotSpareBin intranet in a web browser.
What we learned
- A robot is made of files and possibly directories.
- In Robocorp Lab, the Notebook mode provides a nice interface to work on your robots.
- The notebook interface is made of cells that can be added, removed, copied, moved around.
- To run your robot, you can click on the
>>button in the toolbar on the top.
- When you run your robot, a log file is created with all the details.
.robotfiles are made of sections, each with a specific function.
- Keywords are like functions in other programming languages, and they can accept arguments.