Ask Your Question
1

Send array of three numbers from ROS to Arduino?

asked 2016-12-06 03:46:19 -0600

MartinSA gravatar image

Hey all. We are currently working on getting a serial communication through ROS to an Arbotix-M type board through an FTDI adapter. We have looked into rosserial and other packages but it seems rather complicated and unnecessary since we only want to send an array of three integers to the Arbotix board. We're thinking something like:

ROS-side: Serial write int test[1, 2, 1];

Arduino-side: Serial.read(something).

Is this possible or something similar?

Thanks in advance!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-12-08 15:14:21 -0600

MartinSA gravatar image

updated 2016-12-08 15:15:17 -0600

Thank you for your answers! I found a possible solution. As there would be no need for two way communication and no ROS on the arduino all i needed to do was basically pass three integers over the serial port. Turned out there was a much simpler way to do that, simply by importing the "Serial" library in the python script in ROS.

The transmitting end in python(ROS):

import serial

import time

arduino = serial.Serial(dev/ttyUSB0, 115200, timeout = 1)

time.sleep(2)

arduino.write(integer)

Receiving end on arduino:

if (Serial.available() > 0) {

Serial.read();

integer = Serial.parseInt();

}

Hope this can help others in the future.

edit flag offensive delete link more
0

answered 2016-12-08 10:58:21 -0600

BrettHemes gravatar image

You could also simply write a ROS wrapper for some other application-specific serial interface code. It sounds like you don't really need ROS capabilities ON the Arduino so just write your own serial interface for exactly what you need and then do any ROS-specific communication from within the node.

edit flag offensive delete link more
0

answered 2016-12-06 17:12:29 -0600

paulbovbel gravatar image

updated 2016-12-06 17:13:03 -0600

It is definitely possible, and would be trivial through ROS+rosserial pub/sub using a message containing an int[] array, or reading parameters from the rosparam server.

Implementing a bespoke communication protocol over the serial link is not in scope for this QA board.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-12-06 03:46:19 -0600

Seen: 548 times

Last updated: Dec 08 '16