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

Problem with serialization.h

asked 2015-07-28 07:22:55 -0600

bulgrozer gravatar image

updated 2015-07-30 15:23:41 -0600

Andromeda gravatar image

Hi,

I've tried to code a simple service between a client node and a proxy node and i have this error :

In file included from /opt/ros/indigo/include/ros/publisher.h:34:0, from /opt/ros/indigo/include/ros/node_handle.h:32, from /opt/ros/indigo/include/ros/ros.h:45, from /home/mamy/ftm_ws/src/pbr/src/proxy/proxy.cpp:1: /opt/ros/indigo/include/ros/serialization.h: In instantiation of ‘static void ros::serialization::Serializer<t>::read(Stream&, typename boost::call_traits<t>::reference) [with Stream = ros::serialization::IStream; T = const client::SrvCltRequest_<std::allocator<void> >; typename boost::call_traits<t>::reference = const client::SrvCltRequest_<std::allocator<void> >&]’: /opt/ros/indigo/include/ros/serialization.h:163:32: required from ‘void ros::serialization::deserialize(Stream&, T&) [with T = const client::SrvCltRequest_<std::allocator<void> >; Stream = ros::serialization::IStream]’ /opt/ros/indigo/include/ros/serialization.h:900:25: required from ‘void ros::serialization::deserializeMessage(const ros::SerializedMessage&, M&) [with M = const client::SrvCltRequest_<std::allocator<void> >]’ /opt/ros/indigo/include/ros/service_callback_helper.h:176:49: required from ‘bool ros::ServiceCallbackHelperT<spec>::call(ros::ServiceCallbackHelperCallParams&) [with Spec = ros::ServiceSpec<const client::srvcltrequest_<std::allocator<void=""> >, client::SrvCltResponse_<std::allocator<void> > >]’ /home/mamy/ftm_ws/src/pbr/src/proxy/proxy.cpp:44:2: required from here /opt/ros/indigo/include/ros/serialization.h:136:5: error: ‘const struct client::SrvCltRequest_<std::allocator<void> >’ has no member named ‘deserialize’ t.deserialize(stream.getData());

here is my code and I don't understand this problem :

#include "ros/ros.h"
#include <iostream>
#include <stdio.h>
#include "std_msgs/String.h"
#include "std_msgs/Header.h"

#include "proxy.h"

#include "communication/MsgPxyPro.h"
#include "communication/MsgProPxy.h"
#include "client/SrvClt.h"

Proxy::Proxy(){
// Initialisation of Publisher on topic "Proxy - Protocol"  
//pub_pxy_pro = nh.advertise<communication::MsgPxyPro>("/pxy2pro", 10);     
// Initialisation of Subscriber on topic "Client - Proxy"
//sub_pro_pxy = nh.subscribe("/pro2pxy", 10, &Proxy::receiveAnswer,this);   
// Init of the Server on service "Client - Proxy"
ser_clt = nh.advertiseService("clt2pxy", &Proxy::addId,this);
};


bool Proxy::addId(const client::SrvClt::Request  &req, client::SrvClt::Response &res)
{
  /*//msg_pxy_pro.request = req.request;
   //msg_pxy_pro.id = req.header.seq; // A retravailler...
  pub_pxy_pro.publish(msg_pxy_pro);
 while (flag!=true)
 {
    usleep(100);
 }  
 //for(int i = 0;sizeof(answer);i++){
      //    res.answer[i] = *(answer+i);
//}
    flag = false;   */
 };

 void Proxy::receiveAnswer(const communication::MsgProPxy msg_pro_pxy)
{
/*for(int i = 0;sizeof(msg_pro_pxy.answer);i++){
    *(answer+i) = msg_pro_pxy.answer[i];
}
flag = true;*/
};

When I delete the line where I initiate my ser_clt, it compile without any problem, do you have a solution ?

Thx

Ps : Yes I've looked at my .h and everything should be alright

Edit :

For my organization I have 4 packages : - client - communication - pbr - tr - server

I dissociated the client and the server because they're should be independent at the end. I have, in my communication pkg, my proxy, my protocol and every msg and srv that not belong to the client and the server because they should be the same in my pbr pkg and tr pkg and I want to switch ... (more)

edit retag flag offensive close merge delete

Comments

yess....could be that you didn't link the library in CmakeLists file?? Please add it too.

Andromeda gravatar image Andromeda  ( 2015-07-28 17:00:10 -0600 )edit

and the structure of your project too. I mean folders, files....

Andromeda gravatar image Andromeda  ( 2015-07-28 17:01:08 -0600 )edit

1 Answer

Sort by » oldest newest most voted
8

answered 2015-07-29 04:31:43 -0600

mgruhler gravatar image

I guess this problem comes from you having the Request in the callback defined to be const.

According to the API documentation there is no version of the advertiseService function with a callback having a const Request.

Doing a quick check in one of my nodes seems to confirm this.

edit flag offensive delete link more

Comments

Damn ! Yes that the problem...i feel stupid right now thanks a lot

bulgrozer gravatar image bulgrozer  ( 2015-07-29 07:46:02 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-28 07:22:55 -0600

Seen: 4,197 times

Last updated: Jul 30 '15