SRRC Wiki

Service Robotics Research Center
at Ulm University of Applied Sciences

User Tools

Site Tools


tutorials:webots:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:webots:start [2019/12/16 17:12]
oshlapak [Starting Webots Simulator Environment from SmartSoft Component]
tutorials:webots:start [2020/01/31 12:29] (current)
oshlapak [Starting Webots Simulator Environment from SmartSoft Component]
Line 30: Line 30:
  
 First, you need to create a world in Webots Environment. First, you need to create a world in Webots Environment.
-To create a world follow Hands-on #1 to #5 as described by the link below, only in Hands-on #5 instead of e-puck robot add an e-puck Robot add Pioneer 3-DX.+To create a world follow Hands-on #1 to #5 as described by the link below, only in Hands-on #5 instead of e-puck robot add Pioneer 3-DX.
 https://​www.cyberbotics.com/​doc/​guide/​tutorial-1-your-first-simulation-in-webots https://​www.cyberbotics.com/​doc/​guide/​tutorial-1-your-first-simulation-in-webots
  
Line 37: Line 37:
 Now all you need to do is set the controller to <​extern>​. Double-click on the Robot node in the scene tree. Select **controller** field. In the bottom screen click **Select...**. Choose **<​extern>​**. Now all you need to do is set the controller to <​extern>​. Double-click on the Robot node in the scene tree. Select **controller** field. In the bottom screen click **Select...**. Choose **<​extern>​**.
  
-Next, we need to implement ComponentWebotsSimulator. The image below provides the architecture of ComponentWebotsSimulator+Next, we need to implement ComponentWebotsSimulator. The image below provides the architecture of ComponentWebotsSimulator. It is not necessary to build all these tasks, but building it this way, allows later to extend functionality for Pioneer 3-DX Simulation.
  
 {{:​tutorials:​webots:​componentwebotssimulatorarchitecture.png?​600|}} {{:​tutorials:​webots:​componentwebotssimulatorarchitecture.png?​600|}}
Line 57: Line 57:
 sleep 6 sleep 6
 ;; ;;
-} 
 </​code>​ </​code>​
  
Line 105: Line 104:
 in SimulatorTask.hh in SimulatorTask.hh
  
-<​code ​bash [enable_line_number=true]>​+<​code ​cpp [enable_line_number=true]>​
 #ifndef _SIMULATORTASK_HH #ifndef _SIMULATORTASK_HH
 #define _SIMULATORTASK_HH #define _SIMULATORTASK_HH
Line 119: Line 118:
 { {
 private: private:
-    webots::​Robot *robot;+    webots::​Robot *robot_motor;
  
     webots::​Motor *rightMotor;​     webots::​Motor *rightMotor;​
Line 133: Line 132:
  
 in SimulatorTask.cc in SimulatorTask.cc
-<​code  ​bash [enable_line_number=true]>​+<​code  ​cpp [enable_line_number=true]>​
 int SimulatorTask::​on_entry() int SimulatorTask::​on_entry()
 { {
-      ​robot = new webots::​Robot();​+      ​robot_motor ​= new webots::​Robot();​
  
       // sets up wheels       // sets up wheels
-      leftMotor = robot->​getMotor("​left wheel"​);​ +      leftMotor = robot_motor->​getMotor("​left wheel"​); ​//make sure that the name is the same as in *.wbt(world file)  
-      rightMotor = robot->​getMotor("​right wheel"​);​+      rightMotor = robot_motor->​getMotor("​right wheel"​);​
  
       leftMotor->​setPosition(INFINITY);​       leftMotor->​setPosition(INFINITY);​
Line 154: Line 153:
 int SimulatorTask::​on_execute() int SimulatorTask::​on_execute()
 { {
-    if (robot->​step(TIME_STEP) != -1) {+    if (robot_motor->​step(TIME_STEP) != -1) {
  
             leftMotor->​setVelocity(1.5);​             leftMotor->​setVelocity(1.5);​
Line 166: Line 165:
 int SimulatorTask::​on_exit() int SimulatorTask::​on_exit()
 { {
-     ​delete ​robot;+     ​delete ​robot_motor;
     // use this method to clean-up resources which are initialized in on_entry() and needs to be freed before the on_execute() can be called again     // use this method to clean-up resources which are initialized in on_entry() and needs to be freed before the on_execute() can be called again
     return 0;     return 0;
Line 173: Line 172:
 </​code>​ </​code>​
  
-Now Build and Deploy ​the Component. If during deployment you see the movement of the Robot - you have correctly accessed the Webots Simulator in the SmartMDSD Toolchain.+Now Build the Component, create a 1-component System and Deploy it. If during deployment you see the movement of the Robot - you have correctly accessed the Webots Simulator in the SmartMDSD Toolchain.
  
  
tutorials/webots/start.1576512775.txt.gz · Last modified: 2019/12/16 17:12 by oshlapak