ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Rostest with a dataset

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

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'

catkin_add_gtest(${PROJECT_NAME}_test
    test/test_pc_merger.cpp
    test/test_pc_merger.h
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test)

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
0

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

Link gravatar image

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

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" />
</test>

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

Comments

Here is my current test file

<launch>
  <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"/>
  </test>
</launch>
TomSon gravatar image TomSon  ( 2020-07-01 09:39:28 -0600 )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 -0600 )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 -0600 )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 -0600 )edit

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

Link gravatar image Link  ( 2020-07-01 11:59:39 -0600 )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 -0600 )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 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 305 times

Last updated: Jul 01 '20