Skip to main content

Synchronization between Python and Gazebo Classic via YARP.

Project description

gazebo-yarp-synchronizer

Version Python versions Status Format License Python CI/CD

Synchronization with Gazebo Classic via YARP. With Python batteries.

This project is the client side of the Clock Plugin included in robotology/gazebo-yarp-plugins, with some sugar on top. It provides GazeboYarpSynchronizer, a new class that extends the automatically generated resources from the thrift service and provides initialization and termination helpers.

The main scope of this repository is providing a PyPI package for Python usage, but nothing prevents importing and using it from plain C++.

Dependencies

gazebo-yarp-synchronizer expects to find installed and configured the following dependencies:

Installation

pip3 install gazebo-yarp-synchronizer

Usage

In different terminals, execute:

# 1. Start the YARP server
yarpserver

# 2. Open Gazebo paused
gazebo -u -slibgazebo_yarp_clock.so

# 3. Make sure that YARP is running
yarp detect

# 4. Open the Python interpreter
ipython

Then, in the Python interpreter:

# Import the module
>>> from gazebo_yarp_synchronizer import GazeboYarpSynchronizer

# Create the Gazebo synchronizer
>>> gys = GazeboYarpSynchronizer(gazebo_rpc_port_name="/clock/rpc")

# Initialize the Gazebo synchronizer
>>> gys.init()
# [INFO] |yarp.os.Port| Port /tmp/port/1 active at tcp://192.168.8.102:10056/
# [INFO] |yarp.os.impl.PortCoreOutputUnit| Sending output from /tmp/port/1 to /clock/rpc using tcp

# Inspect simulation status
>>> gys.get_step_size(), gys.get_simulation_time()
# (0.001, 0.0)

# Advance the simulation synchronously
>>> gys.step_simulation_and_wait(number_of_steps=250)

# Print time
>>> gys.get_simulation_time()
# 0.25

# Advance the simulation synchronously
>>> gys.run_simulation_and_wait(duration=0.75)

# Print time
>>> gys.get_simulation_time()
# 1.0

# Terminate the synchronizer
>>> gys.fini()
# [INFO] |yarp.os.impl.PortCoreOutputUnit| Removing output from /tmp/port/1 to /clock/rpc

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gazebo-yarp-synchronizer, version 0.9.1
Filename, size File type Python version Upload date Hashes
Filename, size gazebo_yarp_synchronizer-0.9.1.tar.gz (21.0 kB) File type Source Python version None Upload date Hashes View
Filename, size gazebo_yarp_synchronizer-0.9.1-cp39-cp39-manylinux_2_24_x86_64.whl (1.3 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size gazebo_yarp_synchronizer-0.9.1-cp38-cp38-manylinux_2_24_x86_64.whl (1.3 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size gazebo_yarp_synchronizer-0.9.1-cp37-cp37m-manylinux_2_24_x86_64.whl (1.3 MB) File type Wheel Python version cp37 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page