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

Revision history [back]

click to hide/show revision 1
initial version

You will need to make an adapter that allows you to use rosserial_arduino with the WiFi shield.

As described in rosserial (new hardware support guide)[http://wiki.ros.org/rosserial_client/Tutorials/Adding%20Support%20for%20New%20Hardware], you will need to add a class that provides the interface between your WiFi shield and rosserial_arduino.

(This answer)[http://answers.ros.org/question/198247/how-to-change-the-serial-port-in-the-rosserial-lib-for-the-arduino-side/] provides a more complete example of how to define a new hardware class, but it's using Serial1 instead of Serial on the Arduino Mega, and so it re-uses the existing class instead of defining a completely new interface.

Since it doesn't look like the WiFi library behaves like a serial port, you'll probably need to implement the methods in the Hardware class directly.

It sounds like rosserial_python is expecting to connect to a TCP server, so you should probably use the WiFiServer class as the starting point for your implementation.

You will need to make an adapter that allows you to use rosserial_arduino with the WiFi shield.

As described in rosserial (new new hardware support guide)[http://wiki.ros.org/rosserial_client/Tutorials/Adding%20Support%20for%20New%20Hardware], guide, you will need to add a class that provides the interface between your WiFi shield and rosserial_arduino.

(This answer)[http://answers.ros.org/question/198247/how-to-change-the-serial-port-in-the-rosserial-lib-for-the-arduino-side/] This answer provides a more complete example of how to define a new hardware class, but it's using Serial1 instead of Serial on the Arduino Mega, and so it re-uses the existing class instead of defining a completely new interface.

Since it doesn't look like the WiFi library behaves like a serial port, you'll probably need to implement the methods in the Hardware class directly.

It sounds like rosserial_python is expecting to connect to a TCP server, so you should probably use the WiFiServer class as the starting point for your implementation.

You will need to make an adapter that allows you to use rosserial_arduino with the WiFi shield.

As described in rosserial new hardware support guide, you will need to add a class that provides the interface between your WiFi shield and rosserial_arduino.

This answer provides a more complete example of how to define a new hardware class, but it's using Serial1 instead of Serial on the Arduino Mega, and so it re-uses the existing class instead of defining a completely new interface.

Since it doesn't look like the WiFi library behaves like a serial port, you'll probably need to implement the methods in the Hardware class directly.

It sounds like rosserial_python is expecting to connect to a TCP server, so you should probably use the WiFiServer class as the starting point for your implementation.

UPDATE

The Hardware implementation that you want to create should go in your sketch, and it should look something like this. You'll need to fill in the init(), read() and write() methods:

class WiFiHardware {

    WiFiHardware() {};

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

    // 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
    }

    // 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
    }

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

private:
    // declare any class variables that you use here; this probably includes the variable for your TCP client/server object
};