Creating synchronized tasks with multiple devices.
I'm new to ROS and and want to communicate between 3 Raspberry Pi 3's. 2 of my pis each control a motor, and I want the third pi to communicate to them to start turning the motors at the exact same time.
My initial idea was to have the third pi, the master pi, calculate and publish a specific timestamp for the other pis to start sending commands to their motors, and the two motor pis would just sleep until that time is reached.
Is there a better way to synchronize tasks using ROS?
Asked by Passless11 on 2018-07-13 15:52:42 UTC
Answers
You can set them all up on a single network as is given here http://wiki.ros.org/ROS/NetworkSetup and they'll all be synchronized. Then you can have a simple subscriber on each pi that will start turning the motors whenever they receive a message. The third pi can be used as a master to publish a message when the motors are to be turned.
Asked by nkhedekar on 2018-07-13 17:56:58 UTC
Comments
Could you specify "exact same time"? Are you talking about micro or milliseconds? What is the maximum time difference you can work with?
Asked by NEngelhard on 2018-07-14 01:21:59 UTC
Working together within a couple milliseconds should be fine, but working as close to the exact same time is preferable.
Asked by Passless11 on 2018-07-14 14:27:15 UTC
How are the RPis connected? Could you use additional wires to connect GPIOs between the controller and the two slave RPIs?
Asked by NEngelhard on 2018-07-14 14:42:43 UTC
Possibly. Could you elaborate on your idea more?
Asked by Passless11 on 2018-07-19 14:07:06 UTC
You could set up the next move command through any connection (e.g. a ros-topic) and trigger it by an interrupt. For this you'd have to connect GPIOs from the master-RPI to the slaves.
Asked by NEngelhard on 2018-07-19 14:53:15 UTC
I'm unfamiliar with interrupts. Do you have an example code I could reference?
Asked by Passless11 on 2018-07-19 15:14:56 UTC
I haven't used them so far, but this looks promising: Rpi/Interrupt
Asked by NEngelhard on 2018-07-20 02:27:36 UTC