Join Us and become a Member for a Verified Badge to access private areas with the latest PS4 PKGs.
Earlier this week researcher danielzuegner with help from MaxBandle shared via Twitter a script on his Github repository to control a Roomba robot vacuum cleaner and play MIDI songs using a PS4 DualShock 4 Controller... I bet all my fur babies would love this! :kitty: 🤖

Download: roomba_control-main.zip / GIT

Below is a video of it in action, and from the README.md: Roomba with PS4 Controller

With this small project you can control your Roomba with a PlayStation 4 controller and play Midi songs.

Installation
Code:
git clone https://github.com/danielzuegner/roomba_control.git
cd roomba_control
pip install -r requirements.txt
Setup
  • Check whether your Roomba has a micro USB port. I have a Roomba 960 and the USB port is located under a section of the chassis on the bottom right. See the image below for details:
    PS4 DualShock 4 Controller Script to Control Roomba & Play MIDI Songs 2.jpg

  • Connect a computer with the USB port I've used a Raspberry Pi Zero W with a powerbank, but other options should work.
  • Clone this repo on the computer you want to use to control your Roomba
  • Connect the computer to your PS4 controller, e.g., as described here.
  • Figure out the device interface of the USB connection to your Roomba. For my Raspberry Pi, the port is /dev/ttyACM0.
  • Figure out the device interface of the Bluetooth connection to your PS4 controller. In my case, this is /dev/input/js0.
Usage

Once your setup is complete, simply run:
Code:
python roomba.py --interface /your/roomba/interface --controller-interface /your/ps4/interface
and have fun! Steering is straightforward with the L3 analog stick. Vaccuuming can be turned on with R2. I've added a couple of songs to play on the square, x, circle, triangle, up arrow, and down arrow buttons.

Convert MIDI to Roomba Songs

If you want to teach your Roomba more songs, you can use midi_to_roomba.py to do so:
Code:
python midi_to_roomba.py --file your_midi_file.mid --track TRACK_ID
where TRACK_ID is the ID of the MIDI track you would like to export.

Simply add the output JSON into the SONGS_DICT in songs.py.
PS4 DualShock 4 Controller Script to Control Roomba & Play MIDI Songs.jpg
 

Comments

Top