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

rderensy's profile - activity

2021-05-14 05:14:22 -0500 received badge  Student (source)
2021-01-24 03:12:07 -0500 received badge  Good Answer (source)
2019-08-18 06:49:56 -0500 received badge  Nice Answer (source)
2017-04-04 16:07:34 -0500 received badge  Self-Learner (source)
2017-04-04 16:07:34 -0500 received badge  Teacher (source)
2016-05-19 02:17:28 -0500 commented answer Launch a ros node over wifi

@johnrom My last post (on April 18) is exactly what I wrote into these functions

2016-04-29 02:22:46 -0500 received badge  Scholar (source)
2016-04-29 02:22:41 -0500 received badge  Supporter (source)
2016-04-29 01:51:28 -0500 commented answer Launch a ros node over wifi

Okay ... I replaced client.println() to client.write() and it works fine, thank you !

2016-04-29 01:36:01 -0500 received badge  Enthusiast
2016-04-29 00:32:45 -0500 received badge  Famous Question (source)
2016-04-28 02:32:45 -0500 answered a question Launch a ros node over wifi

@ahendrix

#include <ros.h>
#include <std_msgs/String.h>
#include <Arduino.h>
#include <SPI.h>
#include <WiFi.h>
#include <Servo.h>

IPAddress server(192, 168, 0, 10);
WiFiClient client;

class WiFiHardware {

  public:
  WiFiHardware() {};

  void init() {
    // do your initialization here. this probably includes TCP server/client setup
    client.connect(server, 11411);
  }

  // read a byte from the serial port. -1 = failure
  int read() {
    // implement this method so that it reads a byte from the TCP connection and returns it
    //  you may return -1 is there is an error; for example if the TCP connection is not open
    return client.read();         //will return -1 when it will works
  }

  // write data to the connection to ROS
  void write(uint8_t* data, int length) {
    // implement this so that it takes the arguments and writes or prints them to the TCP connection
    for(int i=0; i<length; i++)
      client.write(data[i]);
  }

  // returns milliseconds since start of program
  unsigned long time() {
     return millis(); // easy; did this one for you
  }
};

Servo s;
int i;

void chatterCallback(const std_msgs::String& msg) {
  i = atoi(msg.data);
  s.write(i);
}

char ssid[] = "ssid";
char pass[] = "password";
ros::Subscriber<std_msgs::String> sub("message", &chatterCallback);
ros::NodeHandle_<WiFiHardware> nh;

void setup() {
  WiFi.begin(ssid, pass);
  s.attach(9);
  nh.initNode();
  nh.subscribe(sub);
}

void loop() {
  nh.spinOnce();
  delay(500);
}

I've done that, the connection works but the rosrun rosserial_python serial_node.py tcp still doesn't work, always the same message

2016-04-27 02:00:43 -0500 commented answer Launch a ros node over wifi

Atm, I put the WiFiHardware.cpp in my sketchbook/libraries/ros_lib with the connection to the socket in init(), my client.read() in read() and client.print(data[i]) in a for loop in write(). I don't know if it's right

2016-04-26 03:05:03 -0500 received badge  Notable Question (source)
2016-04-26 01:47:44 -0500 commented answer Launch a ros node over wifi

I understood that with the links you gave me, I'll try with that and see, thank you! When I put it in my sketch, is it "auto-included" by the ros.h or must I modify it? Do I compile the WiFiHardware to .h? I don't understand how create a hardware class could help me to launch the ros-node via wifi

2016-04-25 04:04:19 -0500 received badge  Popular Question (source)
2016-04-25 03:37:11 -0500 commented answer Launch a ros node over wifi

I began the ROS/C++/Arduino 3 weeks ago for a work experience, I had never dev in C++/for Arduino before that. So, I have no idea how to do that, I don't know what is Serial and Serial1, what put inside the Hardware class, etc etc .. Firstly, where do I put the Hardware class ?

2016-04-25 03:03:02 -0500 commented question Launch a ros node over wifi

In the serial_node.py, there's

if port_name == "tcp" : server = RosSerialServer(tcp_portnum, fork_server)

try : server.listen()

so I guess that's for wireless connection. How is it supposed to work ?

2016-04-25 02:46:33 -0500 edited question Launch a ros node over wifi

Hello,

I want to link my Arduino Uno (with a wifi-shield) with my PC (on Ubuntu 14.04, ROS Indigo) over wifi and run the ROS-node on the Arduino with the following command :

rosrun rosserial_python serial_node.py tcp

or

rosrun rosserial_python serial_node.py _port:=tcp _baud:=57600

But when I launch that, the Arduino open the socket on the port 11411, the serial_node.py say calling startSerialClient and I get the message Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino.

I don't understand that error because when I link them using USB connection, I don't have any problem. I searched on Google but nothing solved this problem.

Thank you !