Ask Your Question
6

How to save file to the current directory with roslaunch?

asked 2013-03-04 20:57:36 -0500

i write a simple C++ program to save an image

cv::imwrite(filename,visual_img);

when i run it directly from Eclipse, the image is saved in the current directory (the directory where the Eclipse project file is in). but when i run it with roslaunch

<node pkg="testProg" type="testProg" name="testProg" />

the image is saved in home/.ros

so what should i do to save it to the current directory?

p.s. i encounter the same problem when i try to load the image. always fail to load if i put the image in the current directory when i run it by roslaunch.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
12

answered 2013-03-05 05:31:58 -0500

See the attributes section on the roslaunch wiki page.

Using the "cwd" attribute, you can specify that the node should be started using the executable's directory as its working-directory. The default behavior is to use $ROS_HOME directory.

For example:

<launch>
  <node name="test" pkg="my_package" type="my_node" cwd="node" />
</launch>
edit flag offensive delete link more

Comments

a million thanks! it works.

yangyangcv gravatar imageyangyangcv ( 2013-03-05 11:42:20 -0500 )edit

However, it is generally better to use $ROS_HOME subdirectories for files you want to write.

joq gravatar imagejoq ( 2013-03-05 14:31:43 -0500 )edit
5

answered 2015-11-11 09:02:55 -0500

lucasw gravatar image

This is what I do to run the nodes in the current directory:

ROS_HOME=`pwd` roslaunch foo.launch
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-03-04 20:57:36 -0500

Seen: 6,769 times

Last updated: Nov 11 '15