Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ros service client arduino not publishing

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()
{
  nh.initNode();
  nh.serviceClient(client);
  nh.advertise(chatter);
  while(!nh.connected()) nh.spinOnce();
  nh.loginfo("Startup complete");
}

void loop()
{
  tcpip::Request req;
  tcpip::Response res;
  req.IPaddress = "192.168.0.109";
  req.NETmask = "255.255.255.0";
  req.Gateway = "192.168.0.1";
  req.DNS1 = "209.18.47.61";
  req.DNS2 = "209.18.47.62";
  client.call(req, res);
  int_msg.data = res.success;
  chatter.publish( &int_msg );
  nh.spinOnce();
  delay(100);
}

ros service client arduino not publishing

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()
{
  nh.initNode();
  nh.serviceClient(client);
  nh.advertise(chatter);
  while(!nh.connected()) nh.spinOnce();
  nh.loginfo("Startup complete");
}

void loop()
{
  tcpip::Request req;
  tcpip::Response res;
  req.IPaddress = "192.168.0.109";
  req.NETmask = "255.255.255.0";
  req.Gateway = "192.168.0.1";
  req.DNS1 = "209.18.47.61";
  req.DNS2 = "209.18.47.62";
  client.call(req, res);
  int_msg.data = res.success;
  chatter.publish( &int_msg );
  nh.spinOnce();
  delay(100);
}