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::read(Stream&, typename boost::call_traits::reference) [with Stream = ros::serialization::IStream; T = const client::SrvCltRequest_std::allocator<void >; typename boost::call_traits::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::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 them depending on my will.
I have no probs with my tr and pbr pkg.
my CMake File :
cmake_minimum_required(VERSION 2.8.3)
project(communication)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
)
add_message_files(
FILES
MsgPxyPro.msg
MsgProBfr.msg
MsgBfrPrd.msg
MsgPrdAft.msg
MsgAftPro.msg
MsgProPxy.msg
Checkpoint.msg
)
add_service_files(
FILES
SrvPrdSrv.srv
SrvAftSrv.srv
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES communication
CATKIN_DEPENDS roscpp std_msgs message_runtime
# DEPENDS system_lib
)
include_directories(
include/proxy/
include/protocol/
${catkin_INCLUDE_DIRS}
)
add_executable(proxy src/proxy/proxy.cpp src/proxy/proxy_node.cpp)
target_link_libraries(proxy ${catkin_LIBRARIES})
add_dependencies(proxy proxy_generate_messages_cpp)
add_executable(protocol src/protocol/protocol.cpp src/protocol/protocol_node.cpp)
target_link_libraries(protocol ${catkin_LIBRARIES})
add_dependencies(protocol protocol_generate_messages_cpp)
I learned ROS by myself and must miss some specificity. It will be a pleasure to know my mistakes to do a better job
Originally posted by bulgrozer on ROS Answers with karma: 75 on 2015-07-28
Post score: 4
Original comments
Comment by Andromeda on 2015-07-28:
yess....could be that you didn't link the library in CmakeLists file??
Please add it too.
Comment by Andromeda on 2015-07-28:
and the structure of your project too. I mean folders, files....