Vacuum Cleaner Robot in Webots

by alyona_lyshak in Circuits > Robots

1172 Views, 2 Favorites, 0 Comments

Vacuum Cleaner Robot in Webots

Vacuum cleaner robot in Webots

This article is about creating a new world, adding a robot vacuum cleaner, and writing a controller to it in Webots.

Creating a New World

empty_2.png

Let's start by creating a new world.

Select Wizards -> New Project Directory. Name your world, choose where it will be saved, and check all the boxes, including "Add Rectangular Arena", which is unchecked by default.

Congratulations, you have just created your very first world of Webots! The 3D image should show a square arena with a chessboard floor.

Arena Settings

empty_3.png

Let's set up our arena. Let's change the height and color of the walls and the look of the floor.

Webots hosted in world files are organized in a tree-like structure called the scene tree. You can change nodes and fields in the scene tree. In the RectangeArena node, change the wallHeight to 1.2. Also in the same node, change the floorSize to 10 by x and y. Change the colorOverride to the desired color of the walls and choose the type of "light strip" for the floor.

Adding Objects and Robot

empty_1.png

Now we need to add all the objects we need.

To do this, select the RectangeArena node, then click "Add a node", in PROTO nodes (Webots Projects) select "objects" to add objects and "robots" to add robots. You can add what you like. In my work I added an armchair, sofa, table, closet, ball, flowerpot and more. We also need to add a robot vacuum cleaner called "Create".

Writing a Controller

Знімок екрана 2021-11-13 142054.png

The last step is to add and write a new controller for our robot.

A controller is a program that determines the behavior of a robot. Webots controllers can be written in the following programming languages: C, C ++, Java, Python, MATLAB, ROS, etc. I used the C language to write my controller. Select Wizards -> New Robot Controller. Next, select the language and name of the controller and IDE. Now we will connect the given controller to our robot, for this purpose in a robot node in item "controller" we will select our controller. Next you need to write the controller code itself. My controller makes the robot move in a circle.

That's it, our work is ready!