Skip to content

Commit

Permalink
Merge branch 'main' into ahcorde/is_light_off
Browse files Browse the repository at this point in the history
  • Loading branch information
ahcorde authored Apr 20, 2022
2 parents 6e3f4b0 + 6bc9542 commit c554e81
Showing 4 changed files with 17 additions and 19 deletions.
15 changes: 7 additions & 8 deletions examples/scripts/python_api/testFixture.py
Original file line number Diff line number Diff line change
@@ -20,21 +20,20 @@
#
# Now you can run the example:
#
# python3 examples/scripts/python_api/helperFixture.py
# python3 examples/scripts/python_api/testFixture.py

import os
import time

from ignition.common import set_verbosity
from ignition.gazebo import TestFixture, World, world_entity
from ignition.math import Vector3d
from sdformat import Element

set_verbosity(4)

file_path = os.path.dirname(os.path.realpath(__file__))

helper = TestFixture(os.path.join(file_path, 'gravity.sdf'))
fixture = TestFixture(os.path.join(file_path, 'gravity.sdf'))

post_iterations = 0
iterations = 0
@@ -69,12 +68,12 @@ def on_post_udpate_cb(_info, _ecm):
print('Post update sim time: ', _info.sim_time)


helper.on_post_update(on_post_udpate_cb)
helper.on_update(on_udpate_cb)
helper.on_pre_update(on_pre_udpate_cb)
helper.finalize()
fixture.on_post_update(on_post_udpate_cb)
fixture.on_update(on_udpate_cb)
fixture.on_pre_update(on_pre_udpate_cb)
fixture.finalize()

server = helper.server()
server = fixture.server()
server.run(False, 1000, False)

while(server.is_running()):
1 change: 0 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ pybind11_add_module(gazebo SHARED

target_link_libraries(gazebo PRIVATE
${PROJECT_LIBRARY_TARGET_NAME}
sdformat${SDF_VER}::sdformat${SDF_VER}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)

12 changes: 6 additions & 6 deletions python/test/testFixture_TEST.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ def test_test_fixture(self):
set_verbosity(4)

file_path = os.path.dirname(os.path.realpath(__file__))
helper = TestFixture(os.path.join(file_path, 'gravity.sdf'))
fixture = TestFixture(os.path.join(file_path, 'gravity.sdf'))

def on_post_udpate_cb(_info, _ecm):
global post_iterations
@@ -49,12 +49,12 @@ def on_udpate_cb(_info, _ecm):
global iterations
iterations += 1

helper.on_post_update(on_post_udpate_cb)
helper.on_update(on_udpate_cb)
helper.on_pre_update(on_pre_udpate_cb)
helper.finalize()
fixture.on_post_update(on_post_udpate_cb)
fixture.on_update(on_udpate_cb)
fixture.on_pre_update(on_pre_udpate_cb)
fixture.finalize()

server = helper.server()
server = fixture.server()
server.run(False, 1000, False)

while(server.is_running()):
8 changes: 4 additions & 4 deletions tutorials/python_interfaces.md
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ step simulation and check entities and components.

```{.python}
file_path = os.path.dirname(os.path.realpath(__file__))
helper = HelperFixture(os.path.join(file_path, 'gravity.sdf'))
fixture = TestFixture(os.path.join(file_path, 'gravity.sdf'))
```

- **Step 2**: Write your `preupdate`, `update` or `postupdate` code:
@@ -25,13 +25,13 @@ def on_post_udpate_cb(_info, _ecm):
- **Step 3**: Register the function.

```python
helper.on_post_update(on_post_udpate_cb)
fixture.on_post_update(on_post_udpate_cb)
```

- **Step 4**: Be sure to call finalize before running the server.

```python
helper.finalize()
fixture.finalize()
```

- **Step 5**: Run the server
@@ -57,7 +57,7 @@ export PYTHONPATH=$PYTHONPATH:<path to ws>/install/lib/python
Now you can run the example:

```bash
$ python3 examples/scripts/python_api/helperFixture.py
$ python3 examples/scripts/python_api/testFixture.py
[Msg] Loading SDF world file[/home/ahcorde/ignition_fortress/src/ign-gazebo/examples/scripts/python_api/gravity.sdf].
[Dbg] [Physics.cc:789] Loaded [ignition::physics::dartsim::Plugin] from library [/home/ahcorde/ignition_fortress/install/lib/ign-physics-5/engine-plugins/libignition-physics-dartsim-plugin.so]
[Dbg] [SimulationRunner.cc:909] Loaded system [ignition::gazebo::systems::Physics] for entity [1]

0 comments on commit c554e81

Please sign in to comment.