Summarized using AI

RoRoRoomba - Ruby on Rails on Roomba

Charles Abbott • April 23, 2012 • Austin, TX • Talk

In this presentation titled 'RoRoRoomba - Ruby on Rails on Roomba,' Charles Abbott discusses the integration of Ruby on Rails with Roomba robotic vacuums. The talk highlights how RoR can facilitate innovative projects that involve repurposing robots, such as Roombas, to create unique web-controlled applications. Key points include:

  • Introduction and Acknowledgements: Abbott begins by expressing gratitude to iRobot for providing Roombas for the demonstrations and to Cookpad for supporting his participation at RailsConf 2012.
  • Personal Journey: He shares his background and initial ignorance regarding physical computing and robotics, emphasizing the importance of overcoming barriers to discovery as essential to learning and innovation.
  • Hacking Roombas: Abbott explains his journey in hacking a Roomba, which started with understanding its API and getting the hardware components to work together, including connecting an Arduino microcontroller to the Roomba.
  • Technical Details: He goes into specifics about wiring, the need for various serial connections, and the importance of understanding Arduino sketches to control the Roomba.
  • Control Mechanisms: Various control methods are discussed, including using Bluetooth and Wi-Fi adapters for wireless communication. Abbott illustrates how to abstract complex commands into simpler movements for the Roomba.
  • Rails Integration: He demonstrates how to interact with the Roomba using a Rails application, detailing how to maintain TCP connections and handle concurrent requests efficiently. He addresses potential pitfalls and latency issues encountered when sending commands to the Roomba.
  • Interactive Demos: Throughout the presentation, live coding demos showcase the control of the Roomba, including movement commands and sensor data collection.
  • Conclusion: Abbott concludes with the philosophy that engaging with such projects not only enhances programming skills but also fosters an environment for creativity and self-improvement. He emphasizes that knowledge in physical computing is crucial for today’s increasingly interconnected world, urging the audience to explore these opportunities as a means to innovate and learn.

RoRoRoomba - Ruby on Rails on Roomba
Charles Abbott • April 23, 2012 • Austin, TX • Talk

RoR makes an excellent framework for off-the-beaten-path type of projects, like hacking Roombas and other robots. In this presentation, I'll demonstrate how our soon to be robot overlords will be happy when we gift them with RoR and a connection to the internet. The presentation will include working examples and demonstrations of:

communicating with an Arduino chip via Ruby tethered serial and wireless bluetooth control of a Roomba via Ruby and Arduino two-way communication with our robot friends over the web using Ruby on Rails and popular web services useful applications of robots controlled over the web 3 RoRoR pitfalls to watch-out for live performance of "Chiron Beta Prime" by Jonathan Coulton* The presentation will close with an argument for why hacking on fun, often eccentric, projects in your spare time is essential for staying motivated, habitual improvement, and tangential learning -- i.e., being a real pragmatic programmer.

*not included, perhaps

RailsConf 2012

00:00:24.680 Today, I'm going to talk about RoRoRoomba, which stands for Ruby on Rails on Roomba. This is a rather different presentation from what you might be used to.
00:00:30.449 First, I want to start off by expressing my gratitude to iRobot, especially Nancy and Joshua, for supplying us with two brand new Roombas for RailsConf. It was wonderful of them to support our demos, and we contacted them only three or four weeks ago, and they were more than gracious in sending us the Roombas.
00:00:51.030 Next, I want to thank Cookpad. After my presentation proposal was accepted, I was trying to figure out how to travel to the U.S., book hotels, and take care of everything else, and Cookpad did an amazing job of supporting and encouraging me. It was heartwarming to see the company I work for giving back to the community in such a significant way.
00:01:14.940 Now, without further ado, I would like to start with some introductions. These Roombas are not the ones I have been working with. In fact, the Roomba I have been working on the most is still in Japan. His name is Roo, and as you can see, I have attached a butter knife to him as a means of arming him for the robot uprising.
00:01:33.060 I thought that merely giving him a single knife wasn't enough considering how impressive a Roomba is. So I decided to up the ante by giving him more utensils; he looks a bit more fearsome this way. So that is my Roomba. Konnichiwa! My name is Charles Abbott, and I work for Cookpad in Tokyo. I've been there for a little over a year.
00:01:56.640 I run a blog called Before the Code, which has almost nothing to do with coding. It’s somewhat oxymoronic, but the blog chronicles my journey moving to Japan three years ago, diving into Japanese culture, and exploring the trials I faced while living here. If any of you are even slightly interested in Japan, I encourage you to check it out. I still write two or three times a week about new and interesting things I encounter.
00:02:19.520 Since the fifth or sixth grade, one of my favorite quotes has been by Daniel J. Boorstin, who wrote an incredible series of historical books. He was the historian at the Library of Congress, and my favorite quote comes from him: "The greatest obstacle to discovery is not ignorance, but the illusion of knowledge." This essentially means that through history, the biggest barriers to new ideas and paradigm shifts were people clinging to old notions.
00:02:42.660 I find this quote to be very applicable to my life and particularly to this presentation because, six months ago, when I began my journey of hacking Roombas, my knowledge of physical computing was non-existent. I had no experience with wiring or soldering whatsoever. Ignorance became my closest ally, and I hope that throughout this presentation, I can encourage any of you who have never attempted something like this to step out of your comfort zone and just try.
00:03:03.000 When I first received my Roomba about six or seven months ago, I noticed a sticker on the packaging stating, 'This robot has an API and can be hacked.' It also noted that by opening the box, I was accepting an end-user license agreement that encouraged hacking the Roomba. I thought it was fantastic that iRobot promotes such an open interface, so I peeled the sticker off and placed it on my Roomba as a reminder while I was hacking.
00:03:30.050 Around four months ago, during the Tokyo Rails meetup we hosted, there was a call for project ideas. I decided to propose hacking Roombas with Ruby. My presentation was titled 'Three R's,' highlighting my idea of using Ruby, along with the Serial Port gem, to control my Roomba and prove that it could be done. The plan was simple: use Ruby to communicate with the Roomba via the serial port, creating a site that would remotely send commands to the Roomba and trigger actions.
00:05:00.760 At the time, I struggled to find resources on the subject. Most information I came across was in other programming languages like Java, and I couldn’t find much regarding Ruby. So, I began my exploration by trying to connect to the Roomba. After reviewing the documentation, I discovered that the Roomba has a seven-pin serial port located beneath the handle. I had to find a compatible cable to connect with the Roomba.
00:06:12.780 I ended up acquiring an eight-pin serial cable from a Mac printer as a replacement for the seven-pin cable. After spending hours in Akihabara, a section of Tokyo known for its electronic shops, I managed to find a suitable cable amidst the piles of used electronics. Just when I was getting into hacking the Roomba, I encountered a major life event—my firstborn child came into the world! Suddenly, all the time I had envisioned for hacking was gone.
00:07:01.990 However, about a month or two later, I found my Arduino and decided it was time to get back to my Roomba project. I began to examine the Arduino layout, looking for how to connect it to the Roomba. There are two pins on the Arduino for receive and transmit, and several power connectors for a 9-volt power supply. To make the connection, users must familiarize themselves with the Roomba open interface (ROI) and the iRobot Roomba Serial Command Interface (SCI) specification.
00:09:02.820 From the documentation, I managed to wire up the Roomba and Arduino correctly. Upon connecting an Arduino or any external device to the Roomba's serial port, the Roomba recognizes the connection and lights up. I initially aimed to use Ruby to send commands to the Arduino, which would relay them to the Roomba, but I quickly realized that passing commands from Ruby directly to the Roomba using the Arduino was far from straightforward.
00:11:00.680 In reality, you end up writing what are referred to as Arduino sketches, which are essentially C code with two main functions: setup and loop. The setup function configures the pins and prepares the Arduino for operation, while the loop function contains the code that controls the device. I wasn't thrilled about having to deal with C code since my intention was to use Ruby.
00:12:50.150 I started searching for alternatives and discovered a project called 'rad,' which enables robotic development in Ruby. I was excited until I noticed that development had stalled. Despite this, I attempted to write C code for the Arduino, defining the setup method to interact with the Roomba via a specified baud rate and sending commands as per the Roomba API documentation. However, I found debugging quite challenging, as the Roomba draws power from the Arduino, and tracking issues while it was connected was cumbersome.
00:14:21.640 An additional challenge arose when I realized the documentation was outdated, causing confusion with certain libraries. Ultimately, I managed to turn on the Roomba, but I needed to figure out how to pass commands effectively.
00:15:18.410 I discovered that connecting an Arduino with a Wi-Fi adapter solves some of my challenges. This setup allows for wireless control of the Roomba while also resolving issues related to running cables. I also considered alternatives such as Bluetooth and direct USB-to-serial connections for flexibility in communication with the Roomba.
00:16:36.180 Once I opted to use the Wi-Fi adapter, I started coding in Ruby, creating an initializer for the Roomba class, allowing me to control it via commands. The commands I used to operate the Roomba were straightforward: each one consisted of simple opcodes that communicated specific instructions to the device.
00:17:57.000 For example, the start command was sent as an opcode, directing the Roomba to begin a cleaning session, while drive commands specified velocity and directions. Each command equated to a particular action, allowing for varied control features.
00:19:29.620 Ultimately, I set up my development environment to allow interaction between Ruby and the Roomba. During a live demo, I conducted a 'Hello, Roomba' test using the Rails console, where I successfully established a connection with my Roomba and initiated movement commands.
00:20:59.680 Nonetheless, encounters with issues like latency necessitated consistent communication with the Roomba to ensure it stopped moving upon detecting obstacles. I also faced debugging challenges due to the asynchronous nature of sensor data and the potential for missing critical information during rapid movements.
00:23:54.110 As I progressed, I integrated my work into a Rails application, where requests would be sent to control the Roomba through a series of socket commands, maintaining a connection to allow for real-time updates. The most significant hurdle arose from the stateless nature of web requests, compelling me ultimately to create a way to maintain persistent communication with the Roomba throughout operations.
00:25:41.540 In addition to this persistent state issue, concurrency presented further complications since the Roomba could only serve one request at a time. To address this, I devised a strategy to implement a socket server that would manage connections efficiently without running into busy device errors.
00:27:32.560 After ensuring everything was running smoothly, I ran a full demo utilizing the Rails app to control the Roomba, showcasing various control features and updates based on sensor data in real-time. The culmination of all these endeavors was my presentation, where I demonstrated how the Roomba could be controlled wirelessly with situational awareness provided by the sensor feedback.
00:29:57.140 Reflecting on my journey, I also contemplated testing methodologies for physical computing devices. It would be beneficial to simulate Roomba behavior to test coding against various conditions and see real-time performance. The aim would be to compare simulated outcomes with actual behavior, allowing adjustments and improvements before hardware execution.
00:31:51.490 In conclusion, individuals should be aware of the impending proliferation of connected devices in our daily lives and how crucial it will be to learn to interface and manage these technologies. This presentation showcases just the tip of the iceberg in understanding how coding can impact the world of robotics, with practical applications that will become increasingly accessible in the landscape of future technology.
00:34:34.440 Ultimately, I hope this presentation inspires you to not only understand how to hack a Roomba, but to also dive into the world of physical computing and embrace the philosophy of exploration and hands-on learning. Thank you for your time, and I'm excited to see what projects you all come up with.
Explore all talks recorded at RailsConf 2012
+65