2013-12-09 34 views
5

Sto sviluppando un'applicazione ROS Qt GUI e ho un problema con ROS Hydro (ho avuto lo stesso problema mentre lavoravo su ROS Fuerte). Il mio progetto non riconosce la mia libreria come image_transport.h. L'ho aggiunto all'inizio del file qnode.hpp ma non ha risolto il problema.riferimento non definito a image_transport

Il mio problema principale:

/home/attila/catkin_ws/src/arayuz/src/qnode.cpp:-1: error: undefined reference to `image_transport::ImageTransport::ImageTransport(ros::NodeHandle const&)'

Questo è il codice che genera l'errore:

#include "ros/ros.h" 
#include "ros/network.h" 
#include "string" 
#include "std_msgs/String.h" 
#include "sstream" 
#include "../include/arayuz/qnode.hpp" 

namespace enc=sensor_msgs::image_encodings; 

static const char WINDOW[ ]="Kinect"; 

namespace arayuz { 

QNode::QNode(int argc, char** argv) : 
    init_argc(argc), 
    init_argv(argv) 
    {} 

QNode::~QNode() { 
    if(ros::isStarted()) { 
     ros::shutdown(); // explicitly needed since we use ros::start(); 
     ros::waitForShutdown(); 
    } 
    cv::destroyWindow(WINDOW); 
    wait(); 
} 

bool QNode::init() { 
    ros::init(init_argc,init_argv,"arayuz"); 

    if (! ros::master::check()) { 
     return false; 
    } 

    ros::start(); // explicitly needed since our nodehandle is going out of scope. 

    ros::NodeHandle n; 
    // Add your ros communications here. 

    image_transport::ImageTransport it(n); 
    imagesub = it.subscribe("/kinectCamera", 1,&QNode::chatterimage,this); 

    start(); 

    return true; 
} 


bool QNode::init(const std::string &master_url, const std::string &host_url) { 
    std::map<std::string,std::string> remappings; 

    remappings["__master"] = master_url; 
    remappings["__hostname"] = host_url; 

    ros::init(remappings,"arayuz"); 

    if (! ros::master::check()) { 
     return false; 
    } 

    ros::start(); // explicitly needed since our nodehandle is going out of scope. 

    ros::NodeHandle n; 
    // Add your ros communications here. 

    image_transport::ImageTransport it(n); 

    imagesub = it.subscribe("/kinectCamera",1,&QNode::chatterimage,this); 

    start(); 

    return true; 
} 

void QNode::chatterimage(const sensor_msgs::ImageConstPtr& msg) 
{ 
    rgbimage=cv_bridge::toCvCopy(msg,enc::BGR8); 

    Q_EMIT chatterimageupdate(); 
} 

void QNode::run() { 
    while (ros::ok()) { 
     ros::spin(); 
    } 

    std::cout << "Ros shutdown, proceeding to close the gui." << std::endl; 
    Q_EMIT rosShutdown(); // used to signal the gui for a shutdown (useful to roslaunch) 
} 
} 
+0

si prega di aggiungere il codice che genera tale errore – Hilikus

risposta

9

Al fine di collegare contro ROS librerie è necessario aggiungere la dipendenza al file package.xml:

<build_depend>image_transport</build_depend> 

<run_depend>image_transport</run_depend> 

e alla vostra CMakeLists.txt:

find_package(catkin REQUIRED COMPONENTS 
    ... 
    image_transport 
    ... 
) 
+0

io Ho provato ad aggiungere le righe al mio pacchetto.xml ma non è cambiato nulla :(Questo problema può essere collegato a automoc –

+1

L'ho risolto finalmente .. Hai ragione, aggiungo i codici a package.xml e ho aggiunto anche find package (. ... imagetransport ...) al mio CMakeList.txt Finalmente risolto il problema ... –

+0

Ho modificato la nota mancante su CMakeLists.txt nella tua risposta. Spero che tu stia bene con questo. – luator

0

Basta aggiungere l'intestazione alla compilation non è sufficiente: il messaggio di errore indica che è successo compilato il codice ma non è riuscito a collegare l'eseguibile. Dovrai anche trovare la libreria che implementa il codice image_transport e collegarlo al tuo eseguibile. Non ho idea di ros ma here è un collegamento che sembra descrivere come creare codice usando questa libreria.

Problemi correlati