You could use one of the opaque drivers (flexiport or serialstream) to handle the serial port communications, and write other drivers that each handle part of your robot. These other drivers would subscribe to the opaque driver to receive data from the serial port. Any data that they don't understand (i.e. it's for another part of the hardware), they would ignore. They would also write data back to the opaque driver anything they want written to the serial port. With this approach you need to be careful about whether bursts of communication to the robot can be interleaved.
The alternative is to write a monolithic driver that provides all the interfaces of your robot. It would handle all the types of data your robot can send and receive (although you might still want to use an opaque driver for talking to the robot; an alternative is to write the serial comms yourself or use a portable library such as flexiport). The downside of this approach is that a monolithic driver tends to be a bit messier to maintain and more complex to design.
On Thu, 18 Feb 2010 14:31 +0100, "Ruffieux Simon" <> wrote:

Hello !


I am trying to understand how to retrieves the information from my (real) IR sensors. And I am not exactly sure if I understood everything correctly. ..


Let me describe you a bit the setup:


I have a wheelchair that has a board on it. This board controls the sensors and the motors (as well as some other functions.)

I have a laptop (under ubuntu 9.04). On this laptop player/stage is installed and runs my simulation with a simulated environment, robot and sensors. (Until here, it works perfectly as I am only simulating)

The laptop is connected to the board through a serial connection. (with a serial to usb converter). The board constantly sends the sensors values over the serial port. I can retrieve those information from the laptop with a simple c++ code polling the ttyUSB0 port.

The information sent over the serial port are “custom” ( [START][IDSENSOR][RANGE][IDSENSOR][RANGE][IDSENSOR][RANGE] …[END]), each [] being a Byte and representing a value as an ASCII Dec .



What I want:

(Final goal) Instead of controlling the simulated robot, I want control the real one with the laptop connected through serial.


For now I already want to be able to retrieve the information coming from my real IR sensors in Player. (I’ll see later for motor controls and so, should be approximately the same kind of mechanism as reading from real sensors …)  

As I understood, I have to write a new specific driver providing an ir:0 interface. It seems to me I can use approximately this example to make the driver:

Or more precisely as I am using ranger: the PBS-03JN driver given here: can be partially reused to do my driver.


I see a few problems coming:

I will also have to use this serial link to receive the encoders values (next step) and also to send the motor control data (next step also).

I think that if I do the driver this way, I will have problem when trying to open the ttyUSB0 port for the other drivers. Should I do one driver that dispatches/handles all the information ?


A few hints would be appreciated


Hope I was clear enough … and sorry for the question being a bit imprecise.


Thanks !