gazebosim / ros_gz

Integration between ROS (1 and 2) and Gazebo simulation
https://gazebosim.org
Apache License 2.0
259 stars 138 forks source link

URDF Spawner #27

Closed BriceRenaudeau closed 5 years ago

BriceRenaudeau commented 5 years ago

Hello, I am trying to use Gazebo ignition instead of gazebo and I would like to know if there exists a model spawner that takes urdf input like in gaezbo-ros ?

chapulina commented 5 years ago

You can spawn URDF just like you would spawn SDF using just Ignition, you can try:

ign gazebo empty.sdf

then

ign service -s /world/empty/create \
--reqtype ignition.msgs.EntityFactory \
--reptype ignition.msgs.Boolean \
--timeout 300 \
--req 'sdf: '\
'"<?xml version=\"1.0\" ?>'\
'<robot name=\"will_be_ignored\">'\
'<link name=\"link\">'\
'<visual>'\
'<geometry>'\
'<sphere radius=\"1.0\"/>'\
'</geometry>'\
'</visual>'\
'<collision>'\
'<geometry>'\
'<sphere radius=\"1.0\"/>'\
'</geometry>'\
'</collision>'\
'<inertial>'\
'<mass value=\"1\"/>'\
'<inertia ixx=\"1\" ixy=\"0.0\" ixz=\"0.0\" iyy=\"1\" iyz=\"0.0\" izz=\"1\"/>'\
'</inertial>'\
'</link>'\
'</robot>" '\
'pose: {position: {z: 10}} '\
'name: "new_name" '\
'allow_renaming: true'

This will work for the simulation side. If you need the URDF for RViz for example, you'll need to set the robot_description parameter separately.

There isn't a pure ROS way of calling the Ignition service yet

BriceRenaudeau commented 5 years ago

I can spawn my robot using robot.sdf but I would like to know if I can use my previous robot.gazebo file and its plugins.

chapulina commented 5 years ago

What format does the .gazebo file use? If it's SDF or URDF then it should work.

Plugins will not work though. Ignition's C++ API is completely different from classic Gazebo, so all plugins must be rewritten.

BriceRenaudeau commented 5 years ago

It's SDF format using balise. What is the command line to spawn from a file ?

chapulina commented 5 years ago

It's SDF format using balise.

What's "balise"?

What is the command line to spawn from a file ?

Use the sdf_filename field. The whole message is documented here.

BriceRenaudeau commented 5 years ago

What's "balise"?

Sorry I meant <robot > Markup

Use the sdf_filename field.

I tried but it gives me an error :

[libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format ignition.msgs.EntityFactory: 1:5: Message type "ignition.msgs.EntityFactory" has no field named "from".

Thanks

chapulina commented 5 years ago

Sorry I meant <robot > Markup

The <robot> tag is present on URDF but not on SDF. I suggest you go through some tutorials.

I tried but it gives me an error

It's hard to tell what's going on without knowing the exact command you sent. How about we follow up on Gazebo Answers? You can ask a new question detailing what you're trying to do and what steps you've taken.

I'll leave this issue here since it's a valid request for a ROS interface to the entity create service.

BriceRenaudeau commented 5 years ago

Sorry for bothering you. I succeeded in using a file. I still have trouble going from my previous Gazebo file to the new Ignition one. For exemple :

Thanks.

chapulina commented 5 years ago

http://answers.gazebosim.org/ is the best place to follow up on these issues :wink:

caguero commented 5 years ago

I'm closing this one, feel free to follow-up on http://answers.gazebosim.org/ .

chapulina commented 4 years ago

51 adds an executable to spawn SDF / URDF which can be used inside launch files and take the model description from a ROS param.