Ask Your Question

ROS on Windows: passing std::string to rosbag::open returns garbage

asked 2021-01-13 06:39:22 -0600

Hi all, I followed the chocolatey procedure to install ros on windows, I am compiling with visual studio 2019. The code is quite simple:

std::string filename = "log.bag";
rosbag::Bag bag(filename);

The second lines throws the following exception: Error opening file: Ó¨Ê}┌

Could it be that the stl is different than the one in visual studio 2019? Thanks for your help!

edit retag flag offensive close merge delete


I can confirm this, though I don't get weird characters:

    std::string logbagfile = "C:\\usr\\scratch\\log.bag";
    rosbag::Bag bag(logbagfile);
    ROS_INFO_STREAM("Opened " << logbagfile);
catch(const std::exception& e)

results in

[ERROR] [1610576413.046326600]: Error opening file: C:\usr\scratch\log.bag

Edit: I'm compiling with catkin_make which is using the MSVC compiler, but I didn't build in Visual Studio.

qTHqq gravatar image qTHqq  ( 2021-01-13 16:21:12 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-01-13 16:56:38 -0600

qTHqq gravatar image

updated 2021-01-13 16:58:47 -0600

This is because the rosbag::Bag constructor tries to Read the bag by default.

try rosbag::Bag bag(filename, rosbag::bagmode::Write) (or rosbag::bagmode::Append)

It works for me on Windows 10 fine, including exactly as we wrote it above with no mode, once log.bag exists in the directory.

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


Asked: 2021-01-13 06:38:38 -0600

Seen: 11 times

Last updated: Jan 13