qtcreator 中的 Rosbag 阅读器 [英] Rosbag reader in qtcreator

查看:72
本文介绍了qtcreator 中的 Rosbag 阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Qtcreator 中制作一个 rosbag 阅读器.我创建了一个项目,我只想阅读包内的信息.这是我的专业文件:

I try to make a rosbag reader in Qtcreator. I create a project and I just want to read informations inside the bag. Here is my pro file:

QT += core
QT -= gui

CONFIG += c++11

TARGET = ROSBag_Reader
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app
LIBS += -lboost_system
LIBS+= -lpthread
LIBS+= -L/usr/lib/x86_64-linux-gnu
LIBS+=  -ltf2_ros
LIBS+=  -lrostime
LIBS+=  -lrospack
LIBS+=  -lroslz4
LIBS+=  -lroslib
LIBS+=  -lroscpp_serialization
LIBS+=  -lroscpp
LIBS+=  -lrosconsole_print
LIBS+=  -lrosconsole_bridge
LIBS+=  -lrosconsole_backend_interface
LIBS+=  -lrosconsole
LIBS+=  -lrosbag_storage
LIBS+=  -lrosbag

SOURCES += main.cpp

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

还有我的 main.cpp:

And my main.cpp:

#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <std_msgs/Int32.h>
#include <std_msgs/String.h>

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH


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

   rosbag::Bag bag;
   bag.open("/home/xxx/Bureau/Developpement/ROSBag_Reader/data/dataset_table.bag", rosbag::bagmode::Read);

   std::vector<std::string> topics;
   topics.push_back(std::string("chatter"));
   topics.push_back(std::string("numbers"));

   rosbag::View view(bag, rosbag::TopicQuery(topics));

   foreach(rosbag::MessageInstance const m, view)
   {
      std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>();
//       if (s != NULL)
//           std::cout << s->data << std::endl;
/*
       std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>();
       if (i != NULL)
           std::cout << i->data << std::endl;*/
   }

   bag.close();

}

但是当我尝试运行该项目时,我收到该错误:

But when I try to run the project I get that error:

/home/xxx/Qt/5.7/gcc_64/bin/qmake -spec linux-g++ -o Makefile ../ROSBag_Reader/ROSBag_Reader.pro
g++ -Wl,-O1 -Wl,-rpath,/home/xxx/Qt/5.7/gcc_64/lib -o ROSBag_Reader main.o   -lboost_system -L/usr/lib/x86_64-linux-gnu -ltf2_ros -lrostime -lrospack -lroslz4 -lroslib -lroscpp_serialization -lroscpp -lrosconsole_print -lrosconsole_bridge -lrosconsole_backend_interface -lrosconsole -lrosbag_storage -lrosbag -L/home/xxx/Qt/5.7/gcc_64/lib -lQt5Core -lpthread 
/usr/bin/ld: main.o: référence au symbole non défini «_ZN3ros6HeaderC1Ev»
//usr/lib/x86_64-linux-gnu/libcpp_common.so.0d: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:214 : la recette pour la cible « ROSBag_Reader » a échouée

我不明白这个错误是哪里来的.

I don't understand where this error comes.

推荐答案

您是否尝试过错误消息建议您执行的操作?将 -lcpp_common 添加到您的 LIBS

Did you try what the error messages suggests you to do? add -lcpp_common to your LIBS

这篇关于qtcreator 中的 Rosbag 阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆