Ask Your Question
2

specify rosbag save path in launchfile

asked 2020-10-04 14:36:47 -0500

TheMilkman92 gravatar image

Hey,

I'm trying to specify the path to which my rosbag files will be written to. The call to launch the datalogging is happening in the launch file. The issue I'm having is I want it to be repeatable on other peoples machines so I don't want to have to include the full file path. ie /home/doug/catkin_ws/src/bagfiles/chatter something like /home/(find user)/catkin_ws/src/bagfiles/chatter would be ideal.

the whole section of code that calls rosbag in the launchfile.

<arg name="data_log" default="true" />

  <group if="$(arg data_log)">
    <arg name="topics_logged" default="/chatter"/>

    <node pkg="rosbag" type="record" 
    args="-o /home/doug/catkin_ws/src/bagfiles/chatter /chatter" name="record" output="screen"/>
  </group>

Thanks for any help!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-10-05 00:56:47 -0500

mgruhler gravatar image

updated 2020-10-06 02:03:54 -0500

You can use the $(env ...) substitution arg.

So

<node pkg="rosbag" type="record" 
args="-o /home/$(env USER)/catkin_ws/src/bagfiles/chatter /chatter" name="record" output="screen"/>

Then again, that user would need to have the directory structure ~/catkin_ws/src/bagfiles/chatter present. I suggest to use something that is definitiely available, i.e. either directly storing into the home directory, or something read-writable by any user...

edit flag offensive delete link more

Comments

3

Then again, that user would need to have the directory structure ~/catkin_ws/src/bagfiles/chatter present.

Exactly. This is only a partial solution I would say.

I suggest to use something that is definitiely available, i.e. either directly storing into the home directory, or something read-writable by any user...

why not use a roslauncharg and specify the full path when starting the .launch file?

gvdhoorn gravatar image gvdhoorn  ( 2020-10-05 05:19:38 -0500 )edit
1

@mgruhler Thanks for you help! You should change the ($env USER) to $(env USER) in your response. otherwise that works perfectly!

@gvdhoom That's completely fair, but it would be a rare case that someone would call the workspace something other than catkin_ws right? I can just put that in our documentation. Unless, is there another directory that would make more sense for something like this?

TheMilkman92 gravatar image TheMilkman92  ( 2020-10-05 13:51:52 -0500 )edit
1

but it would be a rare case that someone would call the workspace something other than catkin_ws right?

no, that's not rare at all.

At this moment I have 43 workspaces, none of which are called catkin_ws.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-05 14:43:29 -0500 )edit
1

You should change the ($env USER) to $(env USER) in your response.

@TheMilkman92 whoops, you are right. Sorry about that.

no, that's not rare at all.

I totally agree with @gvdhoorn (though I don't have THAT many workspaces :-D ). I never call my workspaces catkin_ws. This is merely something like a "tutorial convention"...

mgruhler gravatar image mgruhler  ( 2020-10-06 02:05:53 -0500 )edit

I see @gvdhoorn and @mgruhler, I'll put it outside the workspace in the USER directory. Thanks for the help!

TheMilkman92 gravatar image TheMilkman92  ( 2020-10-08 13:55:21 -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

1 follower

Stats

Asked: 2020-10-04 14:36:47 -0500

Seen: 92 times

Last updated: Oct 06 '20