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

ros service client arduino not publishing

asked 2012-07-12 21:50:24 -0600

punching gravatar image

updated 2012-07-15 07:36:52 -0600

mjcarroll gravatar image

There's no documentation on the ServiceClient rosserial_arduino script, hoping someone can give me a little help here. I have a Service server running and if I use rosservice call it works so I know the problem is with my Arduino script. It compiles and uploads to the Arduino correctly but nothing shows in the Service server in ROS.

Here's the tcpip.srv file:

string IPaddress
string NETmask
string Gateway
string DNS1
string DNS2
int8 success

Arduino script

#include <ros.h>
#include <std_msgs/Int8.h>
#include <std_msgs/String.h>
//#include <rosserial_arduino/Test.h>
#include <networking/tcpip.h>

ros::NodeHandle  nh;
//using rosserial_arduino::Test;
using networking::tcpip;

//ros::ServiceClient<Test::Request, Test::Response> client("test_srv");
ros::ServiceClient<tcpip::Request, tcpip::Response> client("tcpip_srv");

std_msgs::String str_msg;
std_msgs::Int8 int_msg;
ros::Publisher chatter("chatter", &int_msg);

//char hello[13] = "hello world!";

void setup()
  while(!nh.connected()) nh.spinOnce();
  nh.loginfo("Startup complete");

void loop()
  tcpip::Request req;
  tcpip::Response res;
  req.IPaddress = "";
  req.NETmask = "";
  req.Gateway = "";
  req.DNS1 = "";
  req.DNS2 = "";, res); = res.success;
  chatter.publish( &int_msg );
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2012-07-13 21:42:58 -0600

punching gravatar image

Service names didn't match. In Arduino I had tcpip_srv and in ROS I had tcpip as the Service. Once I fixed that everything started working. Sweet!

edit flag offensive delete link more

answered 2012-07-13 03:18:41 -0600

allenh1 gravatar image

Always have to ask the basics to make sure they don't apply! So, Have you run this:

rosrun rosserial_python /dev/ttyUSB0

after roscore is started? Can you list your rosservices? Topics?

Also, it would be good to verify the port that you communicate through. For me, it seemed to change from /dev/ttyUSB0 to /dev/ttyACM0 to /dev/ttyACM1 and back again (not in that order, it was quite unpredictable). You might also want to adjust your baud rate when connecting.

Also, consider the limitations of rosserial. I had trouble with that. I could not publish information from an IMU due to these limitations.

edit flag offensive delete link more


What IMU are you using? A critical part of my project is a 250G single axis accelerometer that I need to publish into ROS.

punching gravatar image punching  ( 2012-07-13 06:45:54 -0600 )edit

I am using a cheap one that I bought for like 120 money. The issue, however, was not the cheap IMU; rather, it was the rosserial communications. Or my coding... I've asked several questions about it in the forum.

allenh1 gravatar image allenh1  ( 2012-07-15 05:13:08 -0600 )edit

answered 2012-07-13 06:44:24 -0600

punching gravatar image

Yes serial_node is running. Not sure why the publisher isn't showing up though. The publisher isn't that important, it's just echoing back the status of the request. What I'm trying to do is have the user be able to select a Wifi network and manually adjust TCPIP settings on the computer through an Arduino touch screen interface. I just wanted to make sure I could pass basic information before I actually do anything with it.

$ ls -l /dev/ttyAC*
crw-rw---- 1 root dialout 166, 0 2012-07-13 00:34 /dev/ttyACM0
chris@chris-VirtualBox:/opt/ros/electric/stacks/rosserial/rosserial_python/nodes$ rosrun rosserial_python /dev/ttyACM0
[INFO] [WallTime: 1342164886.822488] ROS Serial Python Node
[INFO] [WallTime: 1342164886.825278] Connected on /dev/ttyACM0 at 57600 baud
[INFO] [WallTime: 1342164888.953740] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1342164888.974499] Starting service client, waiting for service 'tcpip_srv'


rostopic list


rosservice list
edit flag offensive delete link more

Question Tools


Asked: 2012-07-12 21:50:24 -0600

Seen: 3,362 times

Last updated: Jul 13 '12