…because why do anything the easy way?
I’ve switched to using the StereoPi image for MacFeegle Prime as it offers the lowest latency for streaming video, the downside is I can’t get ROS to build on it so I’m using Docker which needs to interface with hardware…
I’m using the RedBoard+ by Red Robotics, it uses the pigpio library which can work over a socket or pipe. I’m trying to figure out how to have the pigpio deamon running on the Pi host and access it from a docker container that’s running ROS.
Security Note Of Doom!
The following changes have security implications, only do this if you’re running on a private, trusted network. I don’t really know what I’m doing so assume the worst and double check everything I suggest!
Things To Tweak
Upon some digging, this wasn’t as evil as I thought it would be. For pigpiod you need to change the service definition to remove the “-l” from the start command:
sudo nano /lib/systemd/system/pigpiod.service
Remove the “-l” from the ExecStart line.
This is needed as by default pigpiod runs in localhost mode which means that it’ll only accept connections from the local machine. When connecting from inside of a docker container, it’s considered another host.
In order for the docker container to access the hardware it’ll need to have privileged status, add this to the command when you create your container. Eg:
docker run --priviledged -d ros
From inside the docker container, and in the same shell instance you’re running the code that calls the RedBoard library, you need to run this:
export PIGPIO_ADDR=[PI IP ADDRESS]
This sets the address used by the pigpio library that RedBoard uses to the host machine.
After doing the above I was able to use the RedBoard keyboard_control.py script to control the robot from inside a docker container. I’ve not tried anything further yet but that proved the concept enough for today!