How do you spawn an sdf in an already running simulation in gazebo garden?
Hello,
I want to load an sdf model into a gazebo world dynamically, but I haven't figured out how. There are tutorials, but they're outdated.
and that leads to a github page which says the ability to do so is implemented: https://github.com/robotology/gym-ignition/pull/50
but it doesn't say "how" to spawn a model via its sdf.
I know there's fuel, but thats not for loading sdfs/urdfs locally
Asked by ryn on 2023-03-03 13:55:50 UTC
Answers
It's not clear what dynamically
means in your question, but whether you want to spawn a model from code or from the command line, the best way is to use the /world/<world name>/create
service.
Asked by azeey on 2023-03-03 16:07:23 UTC
Comments
I'll look at that. I also clarified my title
Asked by ryn on 2023-03-03 16:17:06 UTC
I looked at the UserCommands class and im not sure how to call it? Is there a python api or some other way to call the gazebo service?
Asked by ryn on 2023-03-03 16:20:03 UTC
If you want to spawn a model from the command line, you can run
gz service -s /world/empty/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/path/to/model", name: "my_model"'
If you want to do it from C++, here is an example. There is no python API for that currently.
Asked by azeey on 2023-03-03 17:16:27 UTC
I tried the command you suggested and all I get is "service call timed out"
sudo gz service -s /world/empty/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 1000 --req 'sdf_filename: "<full_path_to_sdf_file>", name: "diff_sdf_2"'
Asked by ryn on 2023-03-10 15:00:27 UTC
You need to change the "empty" in /world/empty/create
to the correct name of your world. Also, I wouldn't recommend using sudo
with Gazebo. Do you get any messages from the terminal that's running Gazebo? It's helpful to run it using -v4
.
Asked by azeey on 2023-03-11 00:28:05 UTC
Comments