#include "stdafx.h"
#include <ros/ros.h>
#include <custom_msgs\HelloDude.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "client");
ros::spinOnce();
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<custom_msgs::HelloDude>("dude_service");
//ros::ServiceClient client2 = n.serviceClient<custom_msgs::HelloDude>(
custom_msgs::HelloDude srv;
srv.request.greeting = "my testing hello";
//beginner_tutorials::AddTwoInts srv;
ros::service::waitForService("dude_service");
ros::Time begin, end;
for(int i = 0; i < 50; i++) {
begin = ros::Time::now();
if (client.call(srv))
{
ROS_INFO("Sum: %s",srv.response.dude.Dude.c_str());
}
else
{
ROS_ERROR("Failed to call service add_two_ints");
return 1;
}
end = ros::Time::now();
ROS_INFO("ellapsed : %f\n", end.toSec() - begin.toSec());
}
return 0;
}
the function client.call(srv) need around 100ms for a call. On linux the same code needs 10ms.
is there a possibility to get it faster???
many thanks
major
| ServiceClient ros::NodeHandle::serviceClient | ( | const std::string & | service_name, |
| bool | persistent = false, |
||
| const M_string & | header_values = M_string() |
||
| ) |
ros::ServiceClient client = n.serviceClient<custom_msgs::HelloDude>("dude_service",true);
the timing behavior is fine(~5ms).
only disadvantage is:
if connection get broken erors accourt
so you need to Handle these by your own maybe with a try catch block
more information could be found here:
http://answers.ros.org/question/99746/win_ros-service-call-problems-its-reqres-speed-is-very-slow/
ros::ServiceClient client = n.serviceClient<custom_msgs::HelloDude>("dude_service");
new:ros::ServiceClient client = n.serviceClient<custom_msgs::HelloDude>("dude_service",true);
only in the windows version. And now i get on the windows clinet machine a very fast behavior(<5ms).
There is also no use of rosrun and roscore in windows. the nodes are compiled as executable under VS2010 using roslibs:roscpp.lib;roscpp_serialization.lib;rosconsole.lib;rostime.lib;
as explained here
http://wiki.ros.org/win_ros/hydro/Msvc%20SDK%20Projects
I think there is no use of python components under windows. My idea for this slow behavior is another implementation of the persistent option under win_ros, maybe the socket is created new in every call. So the bad timebehavior resulted from the socklet creation, maybe...
--
You received this message because you are subscribed to the Google Groups "Ros on Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to win-ros+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.