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?
Could you specify "exact same time"? Are you talking about micro or milliseconds? What is the maximum time difference you can work with?
Working together within a couple milliseconds should be fine, but working as close to the exact same time is preferable.
How are the RPis connected? Could you use additional wires to connect GPIOs between the controller and the two slave RPIs?
Possibly. Could you elaborate on your idea more?
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.
I'm unfamiliar with interrupts. Do you have an example code I could reference?
I haven't used them so far, but this looks promising: Rpi/Interrupt