0
$\begingroup$

I would like to be able to edit model parameters in a simulation using Python scripts. For example I want to change a models particle emitter to False which seems like it should be a simple task but I really do not know where to start.

I know Gazebo does not natively interact with Python and I will need something like ROS but I have become very confused by what ROS version and libraries I will actually need. I would appreciate some guidance to install the right libraries and use them in Python.

My Ubuntu version is Ubuntu 24.04.1 LTS

My Python version is 3.12.3

My Gazebo version is harmonic 8.6.0

$\endgroup$
2
  • $\begingroup$ have you looked at any tutorials? $\endgroup$ Commented Oct 8, 2024 at 2:50
  • $\begingroup$ @jstola Getting started with ROS / Gazebo can be very overwhelming, especially if you have limited programming knowledge. He probably does not even know where to find the correct examples. $\endgroup$ Commented Oct 10, 2024 at 13:13

1 Answer 1

1
$\begingroup$

Best to get started is to look at the demo worlds.

E.g. the particle emitter demo world shows the command line syntax to change emittor behavior.

Another way to get info on the plugins is to look at their source code. Typically you will find some info in the header files. E.g. see here for the particle emittor plugin, which shows that the plugin creates a /model/{model_name}/link/{link_name}/particle_emitter/{emitter_name}/cmd topic.

Now, to call this from a Python script, the easiest solution would be to look up a way to call the bash command (gz topic -t /model/fog_generator/link/fog_link/particle_emitter/emitter/cmd -m gz.msgs.ParticleEmitter -p 'emitting: {data: false}') from your script.

Alternatively, have a look of some python code that creates a Gazebo node (not a ROS node!) and sends messages through the gz_transport library, see e.g. here.

Or, you can use a ROS node and use the ros_gz_bridge, but that has some complexity of its own (so you will need to look up documentation and ask separate questions if needed).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.