Servers by jDrones

Scripting Gazebo JSON-SITL models with Python

It’s possible to define and simulate a Gazebo model with ArduPilot integration entirely from within a Python environment using pcg_gazebo. This could make it easier to set up simple models for testing and run them automatically as it can be done without having to switch between different languages and tool sets (URDF, SDF, roslaunch etc), although it does use these under the hood.

Where I have found it useful is when you need to make a number of small tweaks to the physics parameters and rerun: I’ve found this is faster using Python. You can also easily make a number of copies of the models with parameter variations (say friction or damping) and then run them together for comparison. It may even be useful for setting up swarms (but I’ve not tried that).

The link below is to a Jupyter notebook for the fan car model and simulation. It probably won’t render well in Discourse but GitHub will render the page (but it’s not executable).

@khancyr and @tridge if you think there is an interest in using this I’d be happy to get the code and dependencies moved into the ardupilot.org area.

that is cool !
I had had find another python launcher for ignition previously but it get heavy dependency on machin learning framework, so I forget it.

I hope we could have an official python backend for Ignition.
The main issue with this solution that it relies on gazebo-ros as proxy for Gazebo… so it will be discontinue with ROS and gazebo …
I need to secure some time to finish with you the JSON support and migration to ignition

I put a lot of thought on whether I should do away with ROS in my workflow for making simulations and only deal with Gazebo.
But as Gazebo doesn’t provide for Python in its plugins and since ROS will always contain all of the packages made by other people that make your life easier, I made my peace and run my dynamics in ROS and send the wrenches to Gazebo for the kinematics simulation.

And yes, I do use pcg_gazebo for generating complex models and worlds.

Yes, it would good to not depend on ROS but a large part of pcg_gazebo doesn’t depend on it and is concerned with manipulating sdf and urdf.

I haven’t looked at what would be needed to jump to ignition and ROS2. Ignition still has some catching up to Gazebo11 from what I can see, but as long as there is service interface for spawning models there should be a path to upgrade.

Let me know when you have some time to review the SITL-JSON changes. Would be nice to have that merged.

Servers by jDrones