-
Notifications
You must be signed in to change notification settings - Fork 2
How to use Webots components
If you want to replace the simulator in your system by Webots simulator, please start at step 3. Otherwise, the following instructions will explain how to create from scratch a system using Webots components to reproduce the SystemLaserObstacleAvoidP3dxPlayerStageSimulator which is presented in the following figure. It will also give you specific instructions that you have to follow for Webots components in order to make the simulation running.

Step 1: Create a system
This step is carried out just like any other system.
- Open
SmartMDSD Toolchain v3.12. - On the top right, there is an white rectangle with the letter S inside. Click on it and the Project explorer on the left will change.
- Select
File>New>System Project (Tier 3). - Choose a name for the system respecting the convention. Here type
SystemWebotsLaserObstacleAvoidP3dxand click onNextbutton. - Choose to add some SmartMDSD Model Types. The default checked box are sufficient for this example, so click on
Nextbutton. - Include in the system the components you need. For a simulation using Webots simulator, you need at least
ComponentWebots. Select alsoComponentWebotsRobot,ComponentWebotsLidarandComponentLaserObstacleAvoid. Don't worry if you miss a component, you can still add it after. - Then, click on
Finishbutton. The interface will change and open three tabs.
Step 2: Create the system model
TargetPlatform
Start with tab the most on the right. This file is accessible from the Project explorer on the left. Open the model folder and unfold the third file icon called SystemWebotsLaserObstacleAvoidP3dx.target. Double-click on the file to edit the TargetPlatform. Use the Palette on the right for the following instructions.
Note : If the Palette panel is not visible, there is a small triangle to open it in the top right corner of the window's tab.
- Click on
TargetPlatformand drag it into the window. One boxPC1and one boxTargetMiddlewaresinside appears. - Click on
NetworkInterfaceand drag it into thePC1box. - Save the file.
ComponentArchitecture
Continue with the middle tab. This file is accessible from the Project explorer on the left. Open the model folder and unfold the second file icon called SystemWebotsLaserObstacleAvoidP3dx.componentArch. Double-click on the file to edit the ComponentArchitecture. Use the Palette on the right for the following instructions.
Note : If the Palette panel is not visible, there is a small triangle to open it in the top right corner of the window's tab.
- If you miss some components when creating the system, click on
ImportComponentsand drag it into the window. Then, check the components needed and click onOKbutton. - Click on
ComponentInstanceand drag it into the window. Select all the component that you need for your system. For this tutorial, select all of them and then, arrange their position and shape. - Click on
Connectionand relies components together with respect to the service used. The results is shown in the next figure. - Optional : You can change the component name using the Properties tab. It is necessary when you have two instances of the same components.
- Save the file.

Deployment
Continue with the last tab. This file is accessible from the Project explorer on the left. Open the model folder and unfold the second file icon called SystemWebotsLaserObstacleAvoidP3dx.deployment. Double-click on the file to edit the Deployment. Use the Palette on the right for the following instructions.
Note : If the Palette panel is not visible, there is a small triangle to open it in the top right corner of the window's tab.
- Click on
TargetPlatformReferenceand drag it into the window. SelectDefinition PC1from the pop-up window and click onFinishbutton. - Click on
UploadDirectoryand drag it into thePC1box. - Click on
NetworkInterfaceand drag it into thePC1box. SelectNetwork Interface eth1from the pop-up window and click onFinishbutton. - Click on
ComponentArtefactand drag it into the window. Select all the component that you included in the model of the previous tab. Arrange them around thePC1box. - Click on
NamingServiceand drag it into the window. - Click on
Deploymentand relies each component to thePC1box. Do the same for theNamingService. The results is shown in the next figure. - Save the file.

Step 3: Generate the code and configure Webots parameters
Generate the code
- Search for the system that you want to deploy and select it.
- Make a right-click on it and select
Build Configurations > Clean Alland click onOKbutton. - Make a right-click on it and select
Run Code-Generation. - Make a right-click on it and select
Build Configurations > Build Selectedand click onOKbutton. - If you encounter a build error, please delete the following folders :
opcua-backend,smartsoft/buildandsmartsoft/src-gen. Then, make again the two previous steps.
- Make a right-click on it and select
Configure Webots parameters
After having generated the code, folders have been created in smartsoft>src, one folder per component of the system. They have the name of the component appended by _data. You have to configure the ones of Webots. The following explanations use some specific components as illustration but can easily be extrapolated for other components.
-
ComponentWebots_datais the folder which store the simulation world file. It includes all the parameters for physics, lights, view as well as the objects, textures and robots used. You have some rules to follow :- The world file have to be called
world.wbtand has to be in the folderworldssuch asComponentWebots_data/worlds/world.wbt. - Textures have to be in the folder
texturessuch asComponentWebots_data/worlds/textures/grass.jpg. - You can place several worlds in the
worldsfolder but only the one calledworld.wbtwill be used.
- The world file have to be called
-
ComponentsWebotsRobot_dataneeds a file calledconfiguration.json. The content of this file should be written using the JSON format. The first element should be the name of the robot (it should be strictly equivalent to thenamefield of the robot in Webots). For this example, if you look at the Pioneer 3-DX PROTO from Webots, you will find the namePioneer 3-DX. The second element is an array which specifies for each wheel used in navigation 3 coefficients mapping velocity commands (vx, vy and omega) to the rotational speed of the wheel. You can find this information in the README page. Example:{ "name": "Pioneer 3-DX", "navigationVelocity": { "right wheel": [10.2564, 0.0, 1.3795], "left wheel": [10.2564, 0.0, -1.3795] } } -
ComponentsWebotsLidar_data(or any sensor) needs (as for the robot's component) a JSON file calledconfiguration.jsonwith only one element consisting of thenamefield of the secondary robot. A secondary robot is a robot node inside the primary robot (as a child). In this secondary robot, the robot's name has to be changed toLidaror whatever, you want but stay consistent with the component's name. Please look below at code 1 which shows the world file of a system withoutComponentsWebotsLidarand code 2 with it. Example:{ "name": "Lidar" } -
For each robot (primary and secondary), you have to attribute the
externcontroller (in Webots) in order that Webots simulator lets SmartSoft control the simulation.
Code 1 : Without ComponentsWebotsLidar
#VRML_SIM R2020a utf8
WorldInfo {
}
Viewpoint {
orientation -0.10293827833600912 0.9728353655005681 0.2073525077846757 2.2417544015195427
position 4.697927742004711 2.5359574393586644 -3.8935842558599614
}
TexturedBackground {
skybox FALSE
}
TexturedBackgroundLight {
}
RectangleArena {
floorSize 5 5
floorTileSize 2 2
wallThickness 0.1
wallHeight 0.5
}
Pioneer3dx { # Primary robot
controller "<extern>" # Don't forget to select the "extern" controller
extensionSlot [ # See the difference here with the next code
SickLms291 {
translation 0 0.22 0
}
]
}
Code 2 : With ComponentsWebotsLidar
#VRML_SIM R2020a utf8
WorldInfo {
}
Viewpoint {
orientation -0.10293827833600912 0.9728353655005681 0.2073525077846757 2.2417544015195427
position 4.697927742004711 2.5359574393586644 -3.8935842558599614
}
TexturedBackground {
skybox FALSE
}
TexturedBackgroundLight {
}
RectangleArena {
floorSize 5 5
floorTileSize 2 2
wallThickness 0.1
wallHeight 0.5
}
Pioneer3dx { # Primary robot
controller "<extern>" # Don't forget to select the "extern" controller
extensionSlot [ # See the difference here with the previous code
Robot { # Secondary robot
translation 0 0.22 0
children [
SickLms291 {
}
]
name "Lidar" # Don't forget to change the name
controller "<extern>" # Don't forget to select the "extern" controller
}
]
}
Step 4: Deploy the system
- Make a right-click on the system that you want to deploy and select
Deployment Action. - A new popup window called
Deploymentwill appear within you have to chooseYes. - On the new popup window (fuschia background) called
Global Scenario Control, selectmenu-startwith the keyboard arrows and validate withEnter. - Webots will open and the simulation of the system will start.
- When you have finished, switch back to the window with fuschia background and select
menu-stop. It will disappear to close all the other windows. When it appears again, selectquitand you will be allowed to close the last windows. If another console window is still open, close it as well.
You just finished the tutorial ! If you want to explore more, you can follow the guideline on how to create Webots components available here : How to create Webots components.
For tutorials on how to create SmartMDSD component, system and more, please refer to the technical Wiki of Service Robotics from Ulm University of Applied Sciences.