Webot and ROS communication
1 Webot Ubuntu client communicates with ROS
1.1 Configure webots_ros package
Step1 : Download the webot code on github: https://github.com/cyberbotics/webots (This file is about 4GB, if the download fails on github, you can download it from Baidu network disk)
Step2 : In the directory projects/languages/ ros find the webots_ros directory and copy the entire webots_ros directory to your own ros workspace.
Step3 : the directory projects / default / controllers / ros / include directory srv and msg folder to catkin_ws / src / webots_ros / in
1.2 Start the webots_ros package
Step1 : Compile the workspace
cd catkin_ws
catkin_make
Step2 : New terminal start
roscore
Step3 : Load the model
in the customer service terminal. Open the new world model in the ubuntu client. The selected pioneer3at.wbt model, make sure that the bottom of the interface after loading the model shows that it is connected to ROS. At this time, the car should be in a static state.
Step4 : Start the node
Return to the ROS environment and create a new terminal
source devel/setup.bash
rosrun webots_ros pioneer3at
You can see that the car is already moving at this time. We can use rostopic llist to see the topics published by webot:
1.3 gmapping mapping test
Next, we use the lidar data output by the simulation environment to build a 2D map:
step1: create a new terminal to start ros
roscore
step 2: start the webot client
step 3: create a new terminal
source devel/setup.bash
rosrun webots_ros pioneer3at
step 4: Start the gmapping node and subscribe to the lidar topic (/pioneer3at/Sick_LMS_291/laser_scan/layer0)
rosrun gmapping slam_gmapping scan:=/pioneer3at/Sick_LMS_291/laser_scan/layer0 _xmax:=30 _xmin:=-30 _ymax:=30 _ymin:=-30 _delta:=0.2
You can see the following phenomena by adding the topic of the map in RVIZ
1.4 Keyboard remote control webot robot
Create a new terminal, note that environment variables need to be set here [4]
source devel/setup.bash
export WEBOTS_HOME=/usr/local/webots
roslaunch webots_ros keyboard_teleop.launch
This command will automatically start the webots client, and then use the mouse to select the webots interface. At this time, use the arrow keys on the keyboard to control the robot to move forward, backward, left, and right. The keyboard data will be sent to a topic named "/XXX/keyboard/key" .
2 Webot Windows client communicates with ROS
For the ROS service shared between Webots devices, configure the webots_ros code on ubuntu, such as the previous step1-step5.
Step1 : Download the webot code on github: https://github.com/cyberbotics/webots (This file is about 4GB, if the download fails on github, you can download it in Baidu network disk)
Step2 : In the directory projects/languages/ ros find the webots_ros directory and copy the entire webots_ros directory to your own ros workspace.
Step3 : the directory projects / default / controllers / ros / include directory srv and msg folder to catkin_ws / src / webots_ros / in
Step4 : Compile the workspace
cd catkin_ws
catkin_make
Step5 : Load the model in the customer service
Open the pioneer3at.wbt model in the new world model (address: C:\Program Files\Webots\projects\languages\ros\worlds) in the windows client .
Step6 : Start the node.
Return to the ROS environment and create a new terminal
source devel/setup.bash
rosrun webots_ros pioneer3at
Note here: the name of the node started in ROS is the same as the name of the model we loaded. For example, in the above case, the name of the model we loaded is pioneer3at , and the ROS startup command we use is rosrun webots_ros [node_name]
step7: modify the environment ROS host address in:
modify the controller, select ros (you need to copy from ubuntu) or ros_python, modify the host address in the controller;
3 references
[1] http://docs.ros.org/kinetic/api/webots_ros/html/index-msg.html
[2] webots manual: https://www.cyberbotics.com/doc/reference/index
[3] webots user guide: https://www.cyberbotics.com/doc/guide/using-ros
[4] https://blog.csdn.net/weixin_38172545/article/details/105212645Previous
: Webot robot simulation platform ( 1) System installation Next: Webot robot simulation platform (3) New environment model
If you think the article is helpful to you, please give me a like. O(∩_∩)O
Welcome everyone to exchange and discuss in the comment area ([email protected])