HOW DOES ARDUINO COMMUNICATE DIRECTLY WITH ROS WITHOUT ROS LIB?


Hello everbody.

Using ROS libraries to broadcast ROS after reading sensor data in Arduino is a bit annoying in complex systems. Data losses, involuntary behaviors, etc. And especially when I used RVIZ, I encountered serious problems.  I have had such problems.

As a solution, I decided to try a method like this:I decided it was unnecessary to publish the sensor data directly on the arduino “ROS”. Instead, I decided to send the data to the ROS by serial connection and then to make a new publishing from the ROS after processing the incoming data on the ROS. I don’t want to extend of this topic too much. When you examine the codes below, you will see how I want to do it.

In this example, I read the encoder data with arduino and sent it to the computer(ROS) via serial communication via USB.

VIDEO OF THE PROJECT:

 

 

WIRING DIAGRAM:

ARDUINO CODE:

Interrupt Numbers

Normally you should use digitalPinToInterrupt(pin), rather than place an interrupt number directly into your sketch. The specific pins with interrupts, and their mapping to interrupt number varies on each type of board. Direct use of interrupt numbers may seem simple, but it can cause compatibility trouble when your sketch is run on a different board.

However, older sketches often have direct interrupt numbers. Often number 0 (for digital pin 2) or number 1 (for digital pin 3) were used. The table below shows the available interrupt pins on various boards.

Note that in the table below, the interrupt numbers refer to the number to be passed to attachInterrupt(). For historical reasons, this numbering does not always correspond directly to the interrupt numbering on the atmega chip (e.g. int.0 corresponds to INT4 on the Atmega2560 chip).

BOARD INT.0 INT.1 INT.2 INT.3 INT.4 INT.5

Uno, Ethernet

2

3

Mega2560

2

3

21

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

20

19

18

32u4 based (e.g Leonardo, Micro)

3

2

0

1

7

For Due, Zero, MKR1000 and 101 boards the interrupt number = pin number.

See for detail

ROS ENCODER CODE:

 

I use “sensor_msgs :: JointState” to broadcast the encoder message on the ROS.  Here, the data received via usb is converted to the message type “sensor_MSGS :: JointState”. See for detail .

 

 

 

ROS CMakeList.txt Add SERIAL LIBRARY FOR USB COMMUNICATION:

 

You must install serial communication libraries before you run the application.

click here to follow the directions.

 

Please contact us for any incorrect information and suggestions.

Do not forget !!! As information is shared, it multiplies.

Thanks a lot to Ahmet KAĞIZMAN for his help.

 

Bir yorum ekleyin

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

twelve − five =

This site uses Akismet to reduce spam. Learn how your comment data is processed.