Ask Your Question
1

ROSbag c++ boost compiling problems

asked 2012-12-13 06:55:03 -0500

0pc0 gravatar image

Hi folks,

Thanks for looking at my problem. I've been trying to write some code to convert .bags to csv files and have run into some problems. When I make the code, I get a large amount of errors when creating the .o. It's got to be in how I'm linking to the boost libraries...but I'm unskilled in this. My Cmake :

rosbuild_add_boost_directories()
rosbuild_add_executable(rosbag_to_csv src/make_csv.cpp)
rosbuild_link_boost(rosbag_to_csv system )

MY code:

#include <fstream>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <boost/foreach.hpp>
#include <std_msgs/Int32.h>

//or just use $ rostopic echo -b file.bag -p /topic

int main(int argc, char *argv[])
{

    if (argc > 1 || argc == 0)
    {
        std::cout << "Too many (or no) arguments........arg= filename.bag";
        return -1;

    }

    std::cout << "Extracting data from: " << argv <<std::endl;

    std::stringstream ss;
    std::string argv_name;
    std::string argv_fullname;
    std::ofstream myfile;
    time_t rawtime;
    struct tm * timeinfo;
    char str_now [80];

    ss << argv;
    ss >> argv_name;
    argv_fullname=argv_name;
    argv_name.erase(argv_name.end()-4,argv_name.end());

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );

  strftime (str_now,80,"%c",timeinfo);

    myfile.open ((argv_name+ ".csv").c_str(), std::ios::out | std::ios::app);
    myfile  << str_now << "," << "ROSBAG decomposition: " << argv_name ;

    rosbag::Bag bag;
    bag.open(argv_fullname, rosbag::bagmode::Read);
    rosbag::View view(bag);

    BOOST_FOREACH(rosbag::MessageInstance const m, view)
    {
        if (m.getTopic() == "/cmd_vel/x")
        {
            std_msgs::Int32::ConstPtr value = m.instantiate<std_msgs::Int32>();
            if (value != NULL)
            {   
                myfile << value->data<< std::endl;
            }
        }//if topic
        //else if (other topics) {}
    }//boost
    bag.close();
    myfile.close();
    return 0;
}//

Errors:

ew>': /usr/include/boost/range/begin.hpp:49: undefined reference to rosbag::View::begin()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionauto_any': /usr/include/boost/foreach.hpp:250: undefined reference to rosbag::View::iterator::iterator(rosbag::View::iterator const&)' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionbegin<rosbag::view, mpl_::bool_<false=""> >': /usr/include/boost/foreach.hpp:650: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionrange_end<rosbag::view>': /usr/include/boost/range/end.hpp:50: undefined reference to rosbag::View::end()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionauto_any': /usr/include/boost/foreach.hpp:250: undefined reference to rosbag::View::iterator::iterator(rosbag::View::iterator const&)' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionend<rosbag::view, mpl_::bool_<false=""> >': /usr/include/boost/foreach.hpp:690: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionincrement<rosbag::view::iterator>': /usr/include/boost/iterator/iterator_facade.hpp:523: undefined reference to rosbag::View::iterator::increment()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functionequal<rosbag::view::iterator, rosbag::view::iterator="">': /usr/include/boost/iterator/iterator_facade.hpp:535: undefined reference to rosbag::View::iterator::equal(rosbag::View::iterator const&) const' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In functiondereference<rosbag::view::iterator>': /usr/include/boost/iterator/iterator_facade.hpp:517: undefined reference to rosbag::View::iterator::dereference() const' CMakeFiles/rosbag_to_csv.dir ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-12-13 07:39:38 -0500

Mac gravatar image

What do your dependencies (in manifest.xml) look like?

edit flag offensive delete link more

Comments

1

<package> <description brief="arl_rosbag"> arl_rosbag </description> <author>parcon</author> <license>BSD</license> <review status="unreviewed" notes=""/> <url>http://ros.org/wiki/arl_rosbag</url> <depend package="roscpp"/> </package> I have tried to depend on boost.

0pc0 gravatar image 0pc0  ( 2012-12-13 08:23:43 -0500 )edit
1

You should add rosbag to your dependencies here. Does that solve it?

PerkinsJames gravatar image PerkinsJames  ( 2012-12-13 09:32:25 -0500 )edit

I tried compiling on a different system, and it worked. Must be something with my install.

0pc0 gravatar image 0pc0  ( 2012-12-14 12:22:52 -0500 )edit

I tried compiling on a different system, and it worked. Must be something with my install.

0pc0 gravatar image 0pc0  ( 2012-12-14 12:22:58 -0500 )edit

I have a similar problem but can you tell me in detail how you solve the problem, what is compiling on a different system? Thanks. @0pc0

Winston gravatar image Winston  ( 2014-08-11 17:44:37 -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

Stats

Asked: 2012-12-13 06:55:03 -0500

Seen: 1,443 times

Last updated: Dec 13 '12