Documentation / v1.0 / Core / COIL

From emss Framework - iRobot Create C++ Framework

Jump to: navigation, search

You are here: Documentation / v1.0 / Core / COIL


[edit] COIL

Files:

COIL/COIL.h Licensed under GPLv3
COIL/COIL.cpp Licensed under GPLv3

The Create Open Interface Library22, or COIL, was originally implemented by Jesse DeGuire and Nathan Sprague as a POSIX compliant C wrapper for the iRobot Open Interface. Together with Stefan Sander, Michal Policht, and Brandon Fosdickā€™s QextSerialPort23 we created a C++ version of COIL which compiles on Windows, Linux, and OS X. COIL opens a serial port and directly communicates with the iRobot Open Interface. All the functions of the interface have been ported in our version, with some additional useful functions.

  // Allocate and start COIL
  coil = new COIL("COM4");
  coil->startOI();
  coil->enterFullMode();
  // Drive forward one meter, checking for collision at intervals
  coil->wheelDrive(100,100); // 100 mm/s
  coil->waitTime(10000); // 10 seconds
  for(int i = 0; i < 10; i++) {
        if(coil->getBumpsAndWheelDrops() != 0) break;
        coil->wheelDrive(100, 100); // 100 mm/s
        coil->waitTime(100); // 0.1 seconds
  }
  coil->wheelDrive(0,0); // stop moving
  // Turn around
  coil->turn(180);
  // Shutdown and cleanup
  coil->stopOI();
  delete COIL;