This Robocomp component is responsible for communicating Robocomp with Gazebo simulator. You can use it in any Gazebo simulation in order to collect data through other Robocomp components or sending topic and commands to the simulation.
First of all, in order to execute the component you need to install Robocomp.
Next, you need to install the Gazebo simulator. (Gazebo Garden is the latest version tested.)
You need to install the gz-transport12 library also.
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install libgz-transport12
sudo apt-get install libgz-transport12-dev
Lastly, in order to be able to use the bridge resouces like custom meshes in human creation entities you need to add the next environmental variable in ~/.bashrc
export GZ_SIM_RESOURCE_PATH=<YOUR_GAZEBO_BRIDGE_FOLDER>/Resources/Models/:./local_models/
This will allow your .sdf scenes to know where to find the extra resources that gazebo-bridge uses, it will also allow you to create a local_models folder in the root folder of your Gazebo project where you can store your own .sdf models and have Gazebo find them.
Now you are ready to run the component. Remember that for the component to be able to collect data, the component, the simulator and the simulation must be started.
First of all, you need to generate the component files. Go to the file where the component is located and execute
cmake .
make
If the compilation is successful you can now run the component
./bin/Gazebo2Robocomp etc/config
Notice that we enter via parameter a config file. This file can be edited or duplicated for been used with your own parameter values.
Actually, a config file for this component looks like this:
CommonBehavior.Endpoints=tcp -p 10217
# Endpoints for implements interfaces
CameraRGBDSimple.Endpoints=tcp -p 10096
Laser.Endpoints=tcp -p 10003
OmniRobot.Endpoints=tcp -p 10004
IMU.Endpoints=tcp -p 10005
JointMotorSimple.Endpoints=tcp -p 10006
DifferentialRobot.Endpoints=tcp -p 10007
Gazebo2Robocomp.Endpoints=tcp -p 10008
Lidar3D.Endpoints=tcp -p 10009
Camera360RGB.Endpoints=tcp -p 10010
# Endpoints for subscriptions interfaces
JoystickAdapterTopic.Endpoints=tcp -p 11025
# This property is used by the clients to connect to IceStorm.
TopicManager.Proxy=IceStorm/TopicManager:default -p 9999
InnerModelPath = innermodel.xml
# Custom parameters
odometry_target_name = simple_robot
gazebo_world_name = empty
Ice.Warn.Connections=0
Ice.Trace.Network=0
Ice.Trace.Protocol=0
Ice.MessageSizeMax=20004800
This config file is basically a normal Robocomp config file, the only distinction comes through the custom parameters.
# Custom parameters
odometry_target_name = simple_robot
gazebo_world_name = empty
The 'odometry_target_name' parameter determines the model in the Gazebo simulation on which the component will record the odometry data. If your object on which you want to record it has the name of "robot_model" or "car1" or any other name you need to specify it in the odometry_target_name parameter.
On the other hand, the 'gazebo_world_name' parameter determines the Gazebo world over which Gazebo2Robocomp has scope of action.
The recommendation is that when you start working with the component you create your own config file where you can make the changes you need.
cp etc/config etc/config_myconfig
Gazebo2Robocomp communicates Robocomp components with Gazebo through a system of topics using gz-transport, the topics linked to each supported component are the following:
Robocomp Component | Gazebo sensor or plugin | Topic |
---|---|---|
CameraRGBDSimple | camera | /camera |
CameraRGBDSimple | depth_camera | /depth_camera |
Laser | gpu_lidar | /lidar |
IMU | imu | /imu |
JointMotorSimple | DiffDrive | /cmd_vel |
JoystickAdapter | DiffDrive | /cmd_vel |
OmniRobot | model/odometer | /model/ + odometry_target_name + /odometry |
DifferentialRobot | model/odometer | /model/ + odometry_target_name + /odometry |
Lidar3D | gpu_lidar | /lidar |
For example, if you want to use Gazebo2Robocomp to move a robot using a Joystick, you can download this Inverted Pendulum Gazebo world and follow the the following:
Check that in the .sdf file of the simulation there is a sensor or plugin among those supported and that it is sending the information to one of the topics supported by the component.
This differential drive plugin would be valid, for example.
<!-- Differential drive plugin -->
<plugin
filename="libignition-gazebo-diff-drive-system.so"
name="ignition::gazebo::systems::DiffDrive">
<left_joint>left_wheel_joint</left_joint>
<right_joint>right_wheel_joint</right_joint>
<wheel_separation>0.4</wheel_separation>
<wheel_radius>0.07</wheel_radius>
<odom_publish_frequency>1</odom_publish_frequency>
<!-- Subscription to a valid Gazebo2Robocomp topic -->
<topic>cmd_vel</topic>
</plugin>
Now you can start the downloaded world as a normal Gazebo project and start the simulation.
Then, run the Robocomp components involved, so far:
Gazebo2Robocomp for communication between Robocomp and Gazebo
JoystickAdapter for sending inputs from the Joystick. You can find this component among
the standard Robocomp components.
You should now be able to move your robot using the Joystick. Have fun!
Gazebo2Robocomp not only has the ability to collect data from Gazebo sensors and plugins, it also provides interfaces to other Robocomp Components with the ability to call services offered by plugins. Currently the supported services are the following:
Gazebo2Robocomp Interface | Gazebo sensor or plugin | Service |
---|---|---|
CreateBoxEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateCapsuleEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateCylinderEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateSphereEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateHumanEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateRandomBoxEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateRandomCapsuleEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateRandomCylinderEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateRandomSphereEntity |
UserCommand | /world/ + gazebo_world_name + /create |
CreateRandomHumanEntity |
UserCommand | /world/ + gazebo_world_name + /create |
RemoveEntity |
UserCommand | /world/ + gazebo_world_name + /remove |
SetEntityPose |
UserCommand | /world/ + gazebo_world_name + /set_pose |
GetWorldPosition |
EntitiesControl | /world/ + gazebo_world_name + /get_world_position |
SetLinearVelocity |
EntitiesControl | /world/ + gazebo_world_name + /set_linear_velocity |