Ask Your Question
0

How to set up an Arduino sub-node which is connected to raspberry pi via usb.

asked 2019-01-26 00:28:19 -0500

iamashwin99 gravatar image

updated 2019-01-26 03:22:24 -0500

I want to set up a remote pick and place bot (Arduino+Raspberry pi) whose angle parameters are controlled by potentiometer values of another bot (Arduino+Raspberry pi) both of which are on the same network. The following image might help visualise what I mean.

Setup

So what I want is to make 2 Raspi nodes (publishers and subscriber) which relay data obtained from Arduino connected to them via USB. Now I'm not sure how I can make the setup as most of the tutorials I've found use Arduino as the node and raspi as the roscore. In my case that is not possible as the two raspberry pis are at two different locations (but on the same network). Can someone please guide me in this regard

edit retag flag offensive close merge delete

Comments

check the sample code, I've updated the wrong download path :-)

ChriMo gravatar imageChriMo ( 2019-01-26 16:34:07 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-01-26 05:16:37 -0500

This is definitely achievable using the rosserial package as described here along with the tutorials here.

Using rosserial a pseudo node runs on the arduino and is able to publish and receive messages itself, however it needs a regular ROS node running on the device it is directly connected to using a serial (or serial over USB) the rosserial_python node is generally used for this.

Since ROS is a distributed network system it does not matter which device on the network is running roscore as long as every device can connect to it.

In your use case you could run the roscore on either of the Raspberry PIs or the laptop. Each of the PIs would need to run the rosserial_python node to connect to their respective Arduinos. You would then write a rosserial publisher node as described here on one Arduino and a subscriber node on the other.

Hope this gives you a good idea how to do this.

edit flag offensive delete link more
0

answered 2019-01-26 05:13:41 -0500

ChriMo gravatar image

updated 2019-01-26 16:43:11 -0500

Easy task without rosserial :-)

because of a lot of pain with rosserial, I prefer an alternate solution for ROS and ARDUINO.

Arduino + Firmata

PyMata (Python2) or PyMata-AIO(Python3)

you can do it with the following componenets:

Arduinos flashed with Firmata

Raspis with simple python pymata node ( https://github.com/MrYsLab/PyMata )

  • one RPI node reads ADC and publish it to topic.

  • one RPI node subscribe to topic and writes data to Arduino

export ROS_MASTER_URI=http://notebook:11311

Done.

Advantage of this solution:

you need to program simple nodes with pymata only.

Example

Connect Potentiometer to ARDUINO 1 or 2 at Pin A1

Connect Servomotor to ARDUINO 1 or 2 Pin D9

Edit sample code for correct USB port

export your ROS_MASTER_URI=http://roscore_ip:11311

Code

https://github.com/mockbot/MockBot/bl...

Enjoy it.

Chrimo

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: 2019-01-26 00:28:19 -0500

Seen: 419 times

Last updated: Jan 26