Thursday, July 13, 2023

Setting up Raspberry Pi with iRobot Create3

I recently decided to change my robotics course to use the iRobot Create3 educational robot. There are a number of reasons for this decision:

  • The excellent Lego Mindstorms EV3 robot has reached its product end-of-life.
  • The Lego Mindstorms Robot Inventor, in my experience, was a largely inferior robot in comparison.
  • Even the Robot Inventor has been canceled - Lego seems to be getting out of the educational robot business entirely.
  • The iRobot Create3 is comparably priced to the Mindstorms robots.
  • The iRobot Create3 has a good path to student professional development due to the ability to control it using ROS2.
  • I was able to obtain sufficient internal funding for this purpose.
The robots work pretty well using the Python Playground. The playground is a web-based Python IDE that connects to a robot via Bluetooth. It works really well as long as one is using the built-in Create3 sensors. 

Particularly exciting with the Create3 is the ability to control it using ROS2. This enables the integration of other sensors, including computer vision, as well as access to a large number of ROS2 modules that incorporate a variety of robot control algorithms. 

The best-supported operating system for ROS2 is Ubuntu Linux. A Raspberry Pi running Ubuntu Linux riding aboard the Create3 can be both powered by the Create3 as well as control it via ROS2 using a single USB-C cable. 

Setting up the Raspberry Pi for this purpose is a little tricky. The instructions provided by iRobot are very helpful, but there are a few missing details that I will supply here:
  • In their instructions, they suggest installing Ubuntu Server. I personally am using Ubuntu Desktop - for experimenting with computer vision algorithms, being able to open desktop windows is essential, and with Remote Desktop it has never been easier.
  • There are three system files to modify to get the wired USB-C connection to work mentioned in Steps 6-8: 
    • The file to modify in Step 6 is /boot/firmware/config.txt
    • The file to modify in Step 7 is /boot/firmware/cmdline.txt.
    • The file to modify in Step 8 is /etc/netplan/01-network-manager-all.yaml. In addition to the file contents provided, you'll need to add the ethernets and usb0 headers, as I learned from this very helpful forum thread.
  • In Step 12, right before running sudo apt install -y ros-humble-desktop, run sudo apt upgrade. This is suggested on the ROS2 installation page.
  • To access the Raspberry Pi remotely, I use ssh. To set up ssh, use sudo apt install openssh-server
  • Be sure to reboot the Raspberry Pi after setting up everything. 
  • Also make sure to set the USB/Bluetooth toggle to USB (on the left).
  • If ros2 topic list doesn't show anything beyond /parameter_events and /rosout after a few attempts, use ping 192.168.186.2 to see if there is a live wired connection to the robot. If there is, you'll need to reboot the robot. 
    • Press the two small buttons simultaneously until the blue ring appears to set up the robot's access point. 
    • Then navigate to 192.168.10.1. 
    • From Applications, select Reboot Robot. It will take a few minutes.
    • Once it chimes, try ros2 daemon stop && ros2 topic list && ros2 topic list. You should see your robot's topics at this point.
To set up OpenCV for use with a webcam:
  • sudo apt install python3-pip
  • pip3 install opencv-python
  • sudo chmod 666 /dev/video0
    • Without adding read/write permission to the camera, it will be necessary to run all OpenCV scripts using sudo
To view OpenCV windows, follow the instructions at the link to enable Remote Desktop