How to use Webots components - cyberbotics/AROSYS GitHub Wiki

How to use Webots components ?

In Systems

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.

Reference system for the tutorial


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 SystemWebotsLaserObstacleAvoidP3dx and click on Next button.
  • Choose to add some SmartMDSD Model Types. The default checked box are sufficient for this example, so click on Next button.
  • Include in the system the components you need. For a simulation using Webots simulator, you need at least ComponentWebots. Select also ComponentWebotsRobot, ComponentWebotsLidar and ComponentLaserObstacleAvoid. Don't worry if you miss a component, you can still add it after.
  • Then, click on Finish button. 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 TargetPlatform and drag it into the window. One box PC1 and one box TargetMiddlewares inside appears.
  • Click on NetworkInterface and drag it into the PC1 box.
  • 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 ImportComponents and drag it into the window. Then, check the components needed and click on OK button.
  • Click on ComponentInstance and 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 Connection and 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.

Component architecture result

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 TargetPlatformReference and drag it into the window. Select Definition PC1 from the pop-up window and click on Finish button.
  • Click on UploadDirectory and drag it into the PC1 box.
  • Click on NetworkInterface and drag it into the PC1 box. Select Network Interface eth1 from the pop-up window and click on Finish button.
  • Click on ComponentArtefact and drag it into the window. Select all the component that you included in the model of the previous tab. Arrange them around the PC1 box.
  • Click on NamingService and drag it into the window.
  • Click on Deployment and relies each component to the PC1 box. Do the same for the NamingService. The results is shown in the next figure.
  • Save the file.

Deployment result


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 All and click on OK button.
    • Make a right-click on it and select Run Code-Generation.
    • Make a right-click on it and select Build Configurations > Build Selected and click on OK button.
    • If you encounter a build error, please delete the following folders : opcua-backend, smartsoft/build and smartsoft/src-gen. Then, make again the two previous steps.

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_data is 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.wbt and has to be in the folder worlds such as ComponentWebots_data/worlds/world.wbt.
    • Textures have to be in the folder textures such as ComponentWebots_data/worlds/textures/grass.jpg.
    • You can place several worlds in the worlds folder but only the one called world.wbt will be used.
  • ComponentsWebotsRobot_data needs a file called configuration.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 the name field of the robot in Webots). For this example, if you look at the Pioneer 3-DX PROTO from Webots, you will find the name Pioneer 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 called configuration.json with only one element consisting of the name field 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 to Lidar or 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 without ComponentsWebotsLidar and code 2 with it. Example:

    {
      "name": "Lidar"
    }
    
  • For each robot (primary and secondary), you have to attribute the extern controller (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 Deployment will appear within you have to choose Yes.
  • On the new popup window (fuschia background) called Global Scenario Control, select menu-start with the keyboard arrows and validate with Enter.
  • 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, select quit and you will be allowed to close the last windows. If another console window is still open, close it as well.

Congratulations!

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.

⚠️ **GitHub.com Fallback** ⚠️