Why the ROS client could fail!
I have implemented a new server and client. The server can work very well but the client always failed!! The errors are shown below:
The srv file is as follows:
float32 cpg1 float32 cpg2 float32 cpg3 float32 cpg4 --- float32 input1 float32 input2 float32 input3 float32 input4
And the crucial part of the client is:
ros::init(argc, argv, "Cpgvalue");
ros::NodeHandle node;
ros::ServiceClient crawling = node.serviceClient<Crawlers::Cpg>("Cpgdata");
Crawlers::Cpg crawlingdata;
std::vector<float> res;
res.resize(4);
ros::Rate loop_rate(1000);
while(ros::ok())
{
crawlingcpg.CpgNetworkCalculation(feedback);
crawlingdata.request.cpg1 = crawlingcpg.CpgResult[0];
crawlingdata.request.cpg2 = crawlingcpg.CpgResult[1];
crawlingdata.request.cpg3 = crawlingcpg.CpgResult[2];
crawlingdata.request.cpg4 = crawlingcpg.CpgResult[3];
res[0] = crawlingdata.response.input1;
res[1] = crawlingdata.response.input2;
res[2] = crawlingdata.response.input3;
res[3] = crawlingdata.response.input4;
loop_rate.sleep();
ROS_INFO("Cpg1:[%f]", crawlingcpg.CpgResult[0]); ROS_INFO("Cpg2:[%f]", crawlingcpg.CpgResult[1]);
if (crawling.call(crawlingdata))
{
ROS_INFO("suceeded!");
}
else{
ROS_INFO("client failed" );
return 1;
}
ros::spin();
}
return 0;
Whatever I modified, I always got the same error:
[ INFO] [1314708828.730975843]: client failed
Can somebody figure out what is the problem?