gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.19k stars 481 forks source link

Launching headless gazebo simulator as part of rostest unit test #1741

Closed osrf-migration closed 9 years ago

osrf-migration commented 9 years ago

Original report (archived issue) by Jordan Lack (Bitbucket: jordanlack).

The original report had attachments: gazebo_test.tar.gz


In order to comprehensively test things like gazebo plugins, I would like to be able to run a rostest unit test that launches a headless gazebo simulator with a robot in it. From that I would be able to create end to end tests of gazebo plugins as well as other software components such as controllers using gtest.

I am having a bit of trouble figuring out how to get the gazebo simulator to launch as part of a rostest though. Maybe I am going about this the wrong way and rostest is not the way to do this, but currently its the only way I have found. When I try to launch a gazebo sim as part of a rostest, I get an exception that tells me there has been a keyboard interrupt.

I have attached a catkin package that can be used to reproduce the issue I am having. To run, put the catkin package in a catkin workspace, then run the following commands from the top level of the catkin workspace,

#!bash

catkin_make
source devel/setup.bash
rostest gazebo_test gazebo_test.test
#!bash

[ROSUNIT] Outputting test results to /home/jordan/.ros/test_results/gazebo_test/rostest-test_gazebo_test.xml
[ INFO] [1442407569.357707095]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1442407569.359898067]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/gazebo_ros/spawn_model", line 31, in <module>
    import tf.transformations as tft
  File "/opt/ros/indigo/lib/python2.7/dist-packages/tf/__init__.py", line 29, in <module>
    from listener import TransformListener, TransformerROS
  File "/opt/ros/indigo/lib/python2.7/dist-packages/tf/listener.py", line 30, in <module>
    roslib.load_manifest(PKG)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/launcher.py", line 62, in load_manifest
    sys.path = _generate_python_path(package_name, _rospack) + sys.path
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/launcher.py", line 93, in _generate_python_path
    m = rospack.get_manifest(pkg)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 163, in get_manifest
    return self._load_manifest(name)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 207, in _load_manifest
    retval = self._manifests[name] = parse_manifest_file(self.get_path(name), self._manifest_name, rospack=self)
  File "/usr/lib/python2.7/dist-packages/rospkg/manifest.py", line 393, in parse_manifest_file
    _static_rosdep_view = init_rospack_interface()
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospack.py", line 59, in init_rospack_interface
    return lookup.get_rosdep_view(DEFAULT_VIEW_KEY)
  File "/usr/lib/python2.7/dist-packages/rosdep2/lookup.py", line 595, in get_rosdep_view
    self._load_view_dependencies(view_key, self.loader)
  File "/usr/lib/python2.7/dist-packages/rosdep2/lookup.py", line 522, in _load_view_dependencies
    loader.load_view(view_key, db, verbose=self.verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospkg_loader.py", line 92, in load_view
    if not view_name in self.get_loadable_views():
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospkg_loader.py", line 110, in get_loadable_views
    return list(self._rosstack.list()) + [DEFAULT_VIEW_KEY]
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 188, in list
    self._update_location_cache()
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 180, in _update_location_cache
    list_by_path(self._manifest_name, path, cache)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 67, in list_by_path
    root = ElementTree(None, os.path.join(d, PACKAGE_FILE))
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 611, in __init__
    self.parse(file)
  File "<string>", line 38, in parse
KeyboardInterrupt
testsim_interface_test ... ok

[ROSTEST]-----------------------------------------------------------------------

SUMMARY
 * RESULT: SUCCESS
 * TESTS: 0
 * ERRORS: 0
 * FAILURES: 0

rostest log file is in /home/jordan/.ros/log/rostest-Jordan-Workstation-22453.log
osrf-migration commented 9 years ago

Original comment by Jordan Lack (Bitbucket: jordanlack).


osrf-migration commented 9 years ago

Original comment by Jordan Lack (Bitbucket: jordanlack).


Issue was unit test was finishing before gazebo had a chance to actually launch. Adding pause statements in the unit tests has fixed this. As far as I am concerned you can close this. Thanks!

osrf-migration commented 9 years ago

Original comment by Jordan Lack (Bitbucket: jordanlack).


Pause in unit tests to give gazebo a chance to spawn fixed the issue.

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).