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

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

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

albanderuaz gravatar image

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

Comments

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

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

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 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

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

qTHqq gravatar image

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

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

Question Tools

1 follower

Stats

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

Seen: 105 times

Last updated: Jan 13 '21