0
$\begingroup$

Rosanswers logo

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 function auto_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 function begin<rosbag::View, mpl_::bool_ >': /usr/include/boost/foreach.hpp:650: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function range_endrosbag::View': /usr/include/boost/range/end.hpp:50: undefined reference to rosbag::View::end()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function auto_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 function end<rosbag::View, mpl_::bool_ >': /usr/include/boost/foreach.hpp:690: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function incrementrosbag::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 function equal<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 function dereferencerosbag::View::iterator': /usr/include/boost/iterator/iterator_facade.hpp:517: undefined reference to rosbag::View::iterator::dereference() const' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function main': /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:55: undefined reference to rosbag::MessageInstance::getTopic() const' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function ~auto_any': /usr/include/boost/foreach.hpp:247: undefined reference to rosbag::View::iterator::~iterator()' /usr/include/boost/foreach.hpp:247: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function main': /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:65: undefined reference to rosbag::Bag::close()' /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:67: undefined reference to rosbag::View::~View()' /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:67: undefined reference to rosbag::Bag::~Bag()' /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:67: undefined reference to rosbag::Bag::~Bag()' /home/parcon/ros_workspace/arl_rosbag/src/make_csv.cpp:67: undefined reference to rosbag::View::~View()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function begin<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 function ~auto_any': /usr/include/boost/foreach.hpp:247: undefined reference to rosbag::View::iterator::~iterator()' CMakeFiles/rosbag_to_csv.dir/src/make_csv.o: In function end<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 function ~auto_any': /usr/include/boost/foreach.hpp:247: undefined reference to rosbag::View::iterator::~iterator()' collect2: ld returned 1 exit status make[3]: *** [../bin/rosbag_to_csv] Error 1 make[3]: Leaving directory /home/parcon/ros_workspace/arl_rosbag/build' make[2]: *** [CMakeFiles/rosbag_to_csv.dir/all] Error 2 make[2]: Leaving directory /home/parcon/ros_workspace/arl_rosbag/build' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/parcon/ros_workspace/arl_rosbag/build' make: *** [all] Error 2 parcon@parcon-MBA:~/ros_workspace/arl_rosbag$


Originally posted by 0pc0 on ROS Answers with karma: 78 on 2012-12-13

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by Mac with karma: 4119 on 2012-12-13

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by 0pc0 on 2012-12-13:
arl_rosbag parcon BSD http://ros.org/wiki/arl_rosbag I have tried to depend on boost.

Comment by PerkinsJames on 2012-12-13:
You should add rosbag to your dependencies here. Does that solve it?

Comment by 0pc0 on 2012-12-14:
I tried compiling on a different system, and it worked. Must be something with my install.

Comment by 0pc0 on 2012-12-14:
I tried compiling on a different system, and it worked. Must be something with my install.

Comment by Winston on 2014-08-11:
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.