Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

rostest is specifically designed not to interfere with a running ROS system, and to be stateless. To achieve this, it runs its own roscore on a different port. There is currently no way to turn off this feature.

What this means is that your test files must do everything to set up the parameters, environment and any simulation or robot that your test needs in order to run.

I suspect that your original test had an include for the PR2 launch file, and you simply removed that when trying to run it on a real robot. This approach fails, because your nodes will now be running on a separate roscore, without a robot to talk to at all.

Instead, I recommend setting up three launch/rostest files:

  1. A core test which includes the nodes you're testing, and your test nodes
  2. A simulation rostest file which sets up the simulation by including the appropriate PR2 gazebo launch files, and then includes your core test file (#1)
  3. An optional PR2 rostest file which includes the PR2 launch file (the one normally run by robot start), and your core test file (#1)

Your simulation test is then simply invoking rostest #2

If you want to run your tests on a real robot, you have a few choices:

  • Start the robot normally, and use roslaunch to run your core test file (#1). This will run all of the regular nodes in that file, but not the test nodes
  • Stop the robot, and use rostest to run your PR2 rostest file (#3). This file will then start all of the PR2 processes, and along with your nodes and tests, run them, and produce a test result.