Breuil
Posts: 5
Joined: Sat Sep 28, 2019 5:40 pm

Multiprocessing across 2 Pis

Sat Sep 28, 2019 6:02 pm

Looking for help with connecting 2 Pis via ethernet cable to make use of the cores on the second pi. I have a robot application multi-processed on a single pi but need additional parallel processes. Any help is appreciated.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Multiprocessing across 2 Pis

Sat Sep 28, 2019 6:19 pm

Welcome to the Raspberry Pi forums.
Breuil wrote:
Sat Sep 28, 2019 6:02 pm
Looking for help with connecting 2 Pis via ethernet cable to make use of the cores on the second pi. I have a robot application multi-processed on a single pi but need additional parallel processes. Any help is appreciated.

For documentation on a similar topic from Raspberry Pi themselves, see: https://www.raspberrypi.org/blog/octapi/


But it may not work the way you hope...

fruitoftheloom
Posts: 23337
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Multiprocessing across 2 Pis

Sat Sep 28, 2019 6:37 pm

Breuil wrote:
Sat Sep 28, 2019 6:02 pm
Looking for help with connecting 2 Pis via ethernet cable to make use of the cores on the second pi. I have a robot application multi-processed on a single pi but need additional parallel processes. Any help is appreciated.

The first question is can your software support Parallel ( or Distributed ) computing ??
Rather than negativity think outside the box !
RPi 4B 4GB (SSD Boot)..
Asus ChromeBox 3 Celeron is my other computer...

Breuil
Posts: 5
Joined: Sat Sep 28, 2019 5:40 pm

Re: Multiprocessing across 2 Pis

Sat Sep 28, 2019 9:02 pm

Thanks. I'll check out the link.

My code is in python 2.7 and is currently multi-processed using all 4 cores. I have camera processes, dc motor control, servo control, and keyboard input all in separate processes. I want to be able to "parallelize" additional functions as I come up with them.

Breuil
Posts: 5
Joined: Sat Sep 28, 2019 5:40 pm

Re: Multiprocessing across 2 Pis

Sat Sep 28, 2019 9:31 pm

Just for reference...
bot.JPG
bot.JPG (29.57 KiB) Viewed 618 times

Breuil
Posts: 5
Joined: Sat Sep 28, 2019 5:40 pm

Re: Multiprocessing across 2 Pis

Sun Sep 29, 2019 3:02 pm

B.Goode wrote:
Sat Sep 28, 2019 6:19 pm
Welcome to the Raspberry Pi forums.

For documentation on a similar topic from Raspberry Pi themselves, see: https://www.raspberrypi.org/blog/octapi/


But it may not work the way you hope...
Thanks B. Goode...good information. I'm new to multiprocessing so I'm learning. Got it working pretty smoothly on a single raspberry but now having to wrap my tiny brain around the whole clustering thing to get more cores. Also looking at other options like Pyro. My goal isn't so much increasing processing speed but more independent processes. Ex..to move my pan/tilt servos at a controlled rate required incremental commands with delays..other processes (camera stream processing/motor drives) were having to wait around. Got it working smooth now with multiprocessing. Multi threading wasn't as smooth probably because of my lack of coding skill.

I know this is kind of an ambiguous request, but any thoughts are appreciated.

mwrich4
Posts: 115
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Re: Multiprocessing across 2 Pis

Sun Sep 29, 2019 5:45 pm

Last time I did this it was on much less powerful hardware. Instead of thinking about a generalized processing solution such as clustering, I split my design down into an autonomous motor control module instructed by a more general-purpose system controller. This way, high use CPU consumers such as motor control and quadrature sensor monitoring would be more stable. The autonomous idea was that the movement controller was instructed to move for a distance at a speed while monitoring obstacle avoidance. I built a communication bridge between the 2 systems using high-speed UART using RS-485 for simplicity and a human readable command/handshake structure. It made unit testing the motor section much easier.

Breuil
Posts: 5
Joined: Sat Sep 28, 2019 5:40 pm

Re: Multiprocessing across 2 Pis

Sun Sep 29, 2019 7:26 pm

Thanks mwrich4. I hadn't thought down that path....I think the saying is.. I couldn't see the forest because I was focused on the trees. So you're saying set the second pi up to run independently with whatever processes and any required cross-talk is over serial connection.

Initially all of my functionality was in one big serial loop and got pretty laggy. One mode is to drive around, simultaneously pan/tilt the camera and get the video stream. Now my main loop doesn't do much other than instantiate class structures that create independent processes. 1. User control input (keyboard for now) 2. dc motor control 3. camera processing/streaming 4. got the servo control stuck in the "main" process for now...this is why I want more cores. The keyboard input string is shared across all processes using python multi-process Manager.list(). Each process has a "listener" thread waiting for relevant keyboard inputs. There's also the laser range finder and imu (for direction). All the components except for the dc motor controller communicate through i2c through an 8 channel i2c multiplexer to the Pi.

Thanks again

Return to “Advanced users”