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

No return from arduino service server

asked 2019-11-13 08:55:09 -0600

Hello, I just ran in a similar isse like this one.

I configured a service server on my arduino and trying to make a service call from my PC using python. The content inside of my service callback function gets executed properly. However, the service request gets stuck and does not return any kind of response.

A minimal example of my arduino code looks like this:

#include <ros.h>
#include <std_srvs/Empty.h>
#include <std_msgs/String.h>
#include <rosserial_arduino/Test.h>

// ROS initialization
ros::NodeHandle  nh;
using rosserial_arduino::Test;

ros::ServiceClient<Test::Request, Test::Response> service_client("service_client_name");
Test::Request test_req;
Test::Response test_resp;

void service_callback(const Test::Request & req, Test::Response & res){
// Perform some operations here

ros::ServiceServer<Test::Request, Test::Response> service_server("service_server_name",&service_callback); 

void setup()
 Ethernet.begin(mac, ip);
 // give the Ethernet shield a second to initialize:
 nh.getHardware()->setConnection(server, serverPort);
 while(!nh.connected()) nh.spinOnce();

void loop()

FYI, the service client is called in another interrupt routine which I have not mentioned in my minimal example.

So using python from y PC, the service gets stuck. However, when I am calling the ervice using the terminal

rosservice call /service_server_name "input: 'some_request'"

everything works fine and I get a proper return message from the arduino.

Any Ideas? Is this a well known bug from rosserial using python?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-05-22 07:52:07 -0600

flo gravatar image

The rosservice call <service_name> <request> is in fact a python script:

So I would suggest that you are either not in the same network setup with your other python script or you misspelled the used .srv or service_name. There is no point why the ros_comm cli tools work from the same shell and a custom written python client would not.

Maybe you want to check out the new Micro-ROS for ROS2:

rosserial is known to be a bit buggy on Arduinos. At least to my knowledge. Consider upgrading to a more powerful STM32 or Teensy. They have faster clock rates that helps to come up with more complex protocols etc.

You can see here a similar situation where we believed that there was some error between cli and a python client node:

In the end it was just a wrong spelled server_name ..

edit flag offensive delete link more

Question Tools



Asked: 2019-11-13 08:55:09 -0600

Seen: 711 times

Last updated: May 22 '20