//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Program: ROOMBA_TEMPLATE // Description: - This a template for any Roomba program. In order to use this, simple place code in the 'while' loop in place of "// ((>>>>]]}- PLACE CODE HERE -{[[<<<<))" // - As a Disclaimer, this loops much more complicated than it is... // // Drexelized By: Peter Thai - [pwt23@drexel.edu] //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This imports the libraries necessary for communicating with Roomba (namely RoomabComm) import roombacomm.*; import roombacomm.net.*; //This stops Roomba and disconnects it from your computer. String roombacommPort = "[DELETE THIS AND ENTER YOUR ROOMBA PORT]"; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::::::::::::: ENTER YOUR ROOMBA PORT ::::::::::::: //String roombacommPort = "/dev/cu.RooTooth-COM0-1"; boolean hwhandshake = false; RoombaCommSerial roombacomm = new RoombaCommSerial(); roombacomm.waitForDSR = hwhandshake; // If Roomba fails to connect, it will print out an error and terminate the program if ( ! roombacomm.connect(roombacommPort) ) { println("Couldn't connect to "+roombacommPort); System.exit(1); } // Once Roomba is connected, it will perform the following actions to indicate it has connected println("Roomba startup on port"+roombacommPort); // Prints out the Port on which Roomba is connected roombacomm.startup(); roombacomm.control(); // Puts Roomba in "Safe Mode" roombacomm.playNote(72,50); // Plays a note roombacomm.pause(100); // Pauses Roomba while note is being played roombacomm.updateSensors(); // Updates the state of all sensors // This is the main loop. It is executed continuously until the variable 'done' is set to true boolean done = false; // This instantiates the variable 'done' and sets it to false while (!done) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ::::::::::::: START CODE (Code goes between this thing and.... *look down*) ::::::::::::: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //[DELETE THIS LINE AND ENTER YOUR OWN CODE!] //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ::::::::::::: END CODE (Code goes between this thing and... *look up*) ::::::::::::: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //This stops Roomba and disconnects it from your computer. roombacomm.stop(); roombacomm.disconnect();