Ask Your Question

Rostest with a dataset

asked 2020-07-01 09:10:18 -0500

TomSon gravatar image

Hi, I would like to launch my test with rostest in order to get running gazebo and the tested node.

I succeed to make it work with

catkin_make run_tests

This test requires a dataset in a subdirectory 'data'


When I launch it with rostest, here is the error

[pcl::PCDReader::read] Could not find file 'data/cloud1.pcd'. 
Couldn't read file data/cloud1.pcd

I'm trying to copy this dataset directory with a DIRECTORY copy in the CMakelist but where ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-01 09:30:50 -0500

Link gravatar image

updated 2020-07-01 12:11:15 -0500

Have you tried adding $(find my_package) to find the file relative to the my_package in your test's launchfile? You will also have to add the associated parameter for specifying the file location to the test. Here's an example of what your pc_merger test would look like assuming the package name was 'my_package' and the test node had a local ros parameter called 'sample_pointcloud':

<test pkg="my_package" test-name="pc_merger_test_1" type="pc_merger_node" >
    <param name="sample_pointcloud" value="$(find my_package)/data/cloud1.pcd" />

Another way to handle this would be to specify the current working directory the test is launched in using the cwd attribute. This would allow you to keep a hardcoded relative path to the test file in your test. Here's what that would look like:

 <test pkg="my_package" test-name="pc_merger_test_1" type="pc_merger_node"  cwd="$(find my_package)"/>
edit flag offensive delete link more


Here is my current test file

  <test  test-name="test" pkg="pointcloud_merger"
  type="pointcloud_merger_test" >
    <remap from="cloud1" to="/sensor1/depth/points"/>
    <remap from="cloud2" to="/sensor2/depth/points"/>
TomSon gravatar image TomSon  ( 2020-07-01 09:39:28 -0500 )edit

your answer didn't contain type of the test node, is it a mistake ?

TomSon gravatar image TomSon  ( 2020-07-01 09:40:01 -0500 )edit

finally found it , the path of runtest execution is /home/$USER/.ros What is the ROS environnement variable associated ?

TomSon gravatar image TomSon  ( 2020-07-01 09:55:03 -0500 )edit

Sorry the important part was passing the parameter with the file path relative to the package. Roslaunch uses /home/$USER/.ros as the working directory for all nodes launched, unless specified otherwise.

Link gravatar image Link  ( 2020-07-01 11:59:03 -0500 )edit

Can you add a parameter to the test for the file location?

Link gravatar image Link  ( 2020-07-01 11:59:39 -0500 )edit

I added some more explanation and fixed the launch file errors in the test

Link gravatar image Link  ( 2020-07-01 12:02:39 -0500 )edit

Seems to be ROS_HOME the associated env variable. But in my case it wasn't set. I didn't want to add parameters because at first it's not a node. It's a preliminary test to check the correct sum with PCL. Now that it works well, I have to make another as a node and do the same with the live pointcloud, that's why there is some remap.

TomSon gravatar image TomSon  ( 2020-07-02 02:46:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-07-01 09:10:18 -0500

Seen: 23 times

Last updated: Jul 01