Page 380 - Hacking Roomba
P. 380

Chapter 15 — RoombaCam: Adding Eyes to Roomba                     361



                             The result is something like in Figure 15-20. However, there is a small change to the control
                             panel. A new button called Snapshot has been added. As you drive around exploring the world
                             from the robot’s perspective, it would be nice to be able to save the current image. It would also
                             be useful to save the Roomba sensor state at that point.


































                             FIGURE 15-20: The finished command center


                             The snapshot command copies the current live webcam image to an archive location (the flash
                             drive). It also dumps the current sensor state of Roomba to a text file. With both a webcam
                             image and sensor telemetry data, you can reconstruct what Roomba was doing and remember
                             your adventures. Listing 15-7 shows the changes needed to be made to roombapanel.cgi.


                               Listing 15-7: Changes to roombapanel.cgi to Add Snapshot Capability

                               if [ “$cmd” ] ; then
                                   echo “cmd: $cmd”
                                   if [ “$cmd” = “snapshot” ] ; then
                                        echo “saving image and sensors to $SNAPPATH!”
                                        cp $PICPATH “$SNAPPATH.tif”
                                        $ROOMBACMD -p $PORT -- sensors-raw > \
                                            “$SNAPPATH-sensors.txt”
                                                                                              Continued
   375   376   377   378   379   380   381   382   383   384   385