|
Working with PlayerThe Player device server treats Gazebo in exactly the same way that it treats real robot hardware: as a device that is a source of data and a sink for commands. A key advantage of this approach is that users may mix Player abstract drivers with simulation drivers. Thus, for example, drivers such as VFH (Vector Field Histogram) and AMCL (adapative Monte-Carlo localization), will work equally well with simulated and real robots. In the following sections, we describe some basic scenarios that demonstate this interaction.Setting up the SimulationThe basic steps for setting up and running a combined Player/Gazebo simulation are as follows.
Note that Gazebo must be started before the Player server, and that the Player server must re-started whenever Gazebo is re-started. Example: Using a Single RobotConsider the case of a single robot with a scanning laser range-finder. The following Gazebo world file snippet will create a Pioneer2DX robot with SICK~LMS200 laser.
<model:Pioneer2DX> <id>robot1_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot1_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> The corresponding snippet of the Player 0.5 configuration file should look like this:
driver ( name "gz_position" provides ["position:0"] gz_id "robot1_position" ) driver ( name "gz_laser" provides ["laser:0"] gz_id "robot1_laser" ) To run this simulation, start Gazebo with:
$ gazebo <myworld>
where
$ player -g 0 <myconfig>
where Example: Using a Single Robot with the VFH driverAbstract devices can be mixed freely with simulated devices in the Player server. Thus, for example, it is possible to use the VFH (Vector Field Histogram) driver with a simulated robot. The following Gazebo world file snippet will create a Pioneer2DX robot with SICK~LMS200 laser.
<model:Pioneer2DX> <id>robot1_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot1_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> The corresponding snippet of the Player configuration file should look like this:
driver ( name "gz_position" provides ["position:0"] gz_id "robot1_position" ) driver ( name "gz_laser" provides ["laser:0"] gz_id "robot1_laser" ) driver ( name "vfh" provides ["position:1"] <vfh driver settings> ) Note that the configuration file is exactly as per the first example; we have simply added another device to the Player server. The VFH driver will use the simulated robot chassis and laser exactly as it would a real robot chassis and laser. To run this simulation, start Gazebo with:
$ gazebo <myworld>
where
$ player -g 0 <myconfig>
where Example: Using Multiple RobotsThere are a number of ways to work with multiple robots. The simplest way is to use multiple instances of the Player server (one for each robot being simulated). The following Gazebo world file snippet will create a pair of Pioneer2DX robots with SICK~LMS200 lasers.
<model:Pioneer2DX> <id>robot1_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot1_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> <model:Pioneer2DX> <id>robot2_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot2_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> Since there will be two instances of the Player server, two different configuration files are required. For the first robot:
driver ( name "gz_position" provides ["position:0"] gz_id "robot1_position" ) driver ( name "gz_laser" provides ["laser:0"] gz_id "robot1_laser" ) and for the second robot:
driver ( name "gz_position" provides ["position:0"] gz_id "robot2_position" ) driver ( name "gz_laser" provides ["laser:0"] gz_id "robot2_laser" )
Note that these files are identical apart from the To run this simulation, start Gazebo with:
$ gazebo <myworld>
where
$ player -p 7000 -g 0 <myconfig1> and
$ player -p 7001 -g 0 <myconfig2>
where Example: Using Multiple Robots with --gazebo-prefixWhen the simulated robots are homogeneous, one may simplify the process somewhat by employing the--gazebo-prefix flag with Player. The following Gazebo world file snippet will create a pair of Pioneer2DX robots with SICK~LMS200 lasers.
<model:Pioneer2DX> <id>robot1_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot1_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> <model:Pioneer2DX> <id>robot2_position</id> <xyz>0 0 0.40</xyz> <rpy>0 0 45</rpy> <model:SickLMS200> <id>robot2_laser</id> <xyz>0.15 0 0.20</xyz> <rpy>0 0 0</rpy> </model:SickLMS200> </model:Pioneer2DX> Since the robots are identical, we can write one Player configuration file for both:
driver ( name "gz_position" provides ["position:0"] gz_id "_position" ) driver ( name "gz_laser" provides ["laser:0"] gz_id "_laser" )
Note that the To run this simulation, start Gazebo with:
$ gazebo <myworld>
where
$ player -p 7000 -g 0 --gazebo-prefix robot1 <myconfig> and
$ player -p 7001 -g 0 --gazebo-prefix robot 2 <myconfig>
where |