libwallaby  v24
The wallaby standard library
Create Class Reference

Facilitates communication with the iRobot (R) Create (TM) More...

#include <create.hpp>

Public Types

enum  Mode { OffMode, PassiveMode, SafeMode, FullMode }
 
enum  BaudRate { Baud57600 = 0, Baud115200 = 1 }
 

Public Member Functions

 ~Create ()
 
bool connect ()
 
bool connect (const BaudRate baudRate)
 
bool disconnect ()
 
bool isConnected () const
 
void setOffMode ()
 
void setPassiveMode ()
 
void setSafeMode ()
 
void setFullMode ()
 
void setMode (const Create::Mode &mode)
 
Create::Mode mode ()
 
void send (const CreateScript &script)
 
bool write (const unsigned char &c)
 
bool write (const unsigned char *data, const size_t &len)
 
void flush ()
 
short read ()
 
int read (unsigned char *data, const size_t &len)
 
bool blockingRead (unsigned char *data, const size_t &size, unsigned timeout=25)
 
template<typename T >
bool blockingRead (T &data, unsigned timeout=0)
 
void setLeds (const bool &advance, const bool &play, const unsigned char &color, const unsigned char &brightness)
 
void drive (const short &velocity, const short &radius)
 
void driveDirect (const short &left, const short &right)
 
void driveStraight (const short &speed)
 
void stop ()
 
void turn (const short &angle, const unsigned short &speed)
 
void move (const short &millimeters, const unsigned short &speed)
 
void spin (const short &speed)
 
short angularVelocity () const
 
void spinClockwise (const short &speed)
 
void spinCounterClockwise (const short &speed)
 
bool setBaudRate (const unsigned char &baudCode)
 
void setDistance (const int distance)
 
void setAngle (const int angle)
 
AbstractButtonplayButton () const
 
AbstractButtonadvanceButton () const
 
Sensor< bool > * wall () const
 
Sensor< bool > * cliffLeft () const
 
Sensor< bool > * cliffFrontLeft () const
 
Sensor< bool > * cliffFrontRight () const
 
Sensor< bool > * cliffRight () const
 
Sensor< bool > * virtualWall () const
 
Sensor< unsigned short > * wallSignal () const
 
Sensor< unsigned short > * cliffLeftSignal () const
 
Sensor< unsigned short > * cliffFrontLeftSignal () const
 
Sensor< unsigned short > * cliffFrontRightSignal () const
 
Sensor< unsigned short > * cliffRightSignal () const
 
Sensor< unsigned short > * cargoBayAnalogSignal () const
 
Sensor< unsigned char > * cargoBayDigitalInputs () const
 
Sensor< unsigned char > * ir () const
 
Sensor< unsigned char > * chargingState () const
 
Sensor< char > * batteryTemperature () const
 
Sensor< unsigned short > * batteryCharge () const
 
Sensor< unsigned short > * batteryCapacity () const
 
Sensor< int > * angle () const
 
Sensor< int > * distance () const
 
Sensor< bool > * bumpLeft () const
 
Sensor< bool > * bumpRight () const
 
Sensor< bool > * wheelDropLeft () const
 
Sensor< bool > * wheelDropRight () const
 
Sensor< bool > * wheelDropCaster () const
 
Sensor< bool > * lightBumpLeft () const
 
Sensor< bool > * lightBumpFrontLeft () const
 
Sensor< bool > * lightBumpCenterLeft () const
 
Sensor< bool > * lightBumpCenterRight () const
 
Sensor< bool > * lightBumpFrontRight () const
 
Sensor< bool > * lightBumpRight () const
 
Sensor< unsigned short > * lightBumpLeftSignal () const
 
Sensor< unsigned short > * lightBumpFrontLeftSignal () const
 
Sensor< unsigned short > * lightBumpCenterLeftSignal () const
 
Sensor< unsigned short > * lightBumpCenterRightSignal () const
 
Sensor< unsigned short > * lightBumpFrontRightSignal () const
 
Sensor< unsigned short > * lightBumpRightSignal () const
 
void setRefreshRate (const unsigned short &refreshRate)
 
const unsigned short & refreshRate () const
 
const CreateStatestate ()
 
const CreatePackets::_1sensorPacket1 ()
 
const CreatePackets::_2sensorPacket2 ()
 
const CreatePackets::_3sensorPacket3 ()
 
const CreatePackets::_4sensorPacket4 ()
 
const CreatePackets::_5sensorPacket5 ()
 
const CreatePackets::_101sensorPacket101 ()
 
void beginAtomicOperation ()
 
void endAtomicOperation ()
 
void setDefaultBaudRate (const BaudRate defaultBaudRate)
 
BaudRate defaultBaudRate () const
 

Static Public Member Functions

static Createinstance ()
 

Detailed Description

Facilitates communication with the iRobot (R) Create (TM)

Provides high level bindings for a significant majority of the iRobot Open Interface specification.

Author
Braden McDorman

Member Enumeration Documentation

Enumerator
Baud57600 
Baud115200 

The "Mode" of the create.

  • PassiveMode: No movement allowed.
  • SafeMode: Movement is allowed, but the Create will stop if it's safety sensors are activated.
  • FullMode: All movement is allowed, even if it is considered dangerous. This mode is recommended for Botball.
Enumerator
OffMode 
PassiveMode 
SafeMode 
FullMode 

Constructor & Destructor Documentation

Create::~Create ( )

Member Function Documentation

AbstractButton* Create::advanceButton ( ) const
Sensor<int>* Create::angle ( ) const
short Create::angularVelocity ( ) const

Returns the current angular velocity of the create. This value is positive for counter-clockwise velocity and negative for clockwise velocity.

Returns
angular velocity of the create, between 0 and 1000 mm/s
Sensor<unsigned short>* Create::batteryCapacity ( ) const
Sensor<unsigned short>* Create::batteryCharge ( ) const
Sensor<char>* Create::batteryTemperature ( ) const
void Create::beginAtomicOperation ( )
inline
bool Create::blockingRead ( unsigned char *  data,
const size_t &  size,
unsigned  timeout = 25 
)

Reads until the specified number of bytes have been read.

Parameters
dataPointer to the buffer to read into
sizeNumber of bytes to be read
Returns
true if reading succeeded, false if there was an error
This function is blocking.
template<typename T >
bool Create::blockingRead ( T &  data,
unsigned  timeout = 0 
)
inline
Sensor<bool>* Create::bumpLeft ( ) const
Sensor<bool>* Create::bumpRight ( ) const
Sensor<unsigned short>* Create::cargoBayAnalogSignal ( ) const
Sensor<unsigned char>* Create::cargoBayDigitalInputs ( ) const
Sensor<unsigned char>* Create::chargingState ( ) const
Sensor<bool>* Create::cliffFrontLeft ( ) const
Sensor<unsigned short>* Create::cliffFrontLeftSignal ( ) const
Sensor<bool>* Create::cliffFrontRight ( ) const
Sensor<unsigned short>* Create::cliffFrontRightSignal ( ) const
Sensor<bool>* Create::cliffLeft ( ) const
Sensor<unsigned short>* Create::cliffLeftSignal ( ) const
Sensor<bool>* Create::cliffRight ( ) const
Sensor<unsigned short>* Create::cliffRightSignal ( ) const
bool Create::connect ( )

Attempts to establish a connection to the create

Returns
true if connection succeeded, false if connection failed
See also
disconnect
isConnected
bool Create::connect ( const BaudRate  baudRate)

Attempts to establish a connection to the create

Parameters
baudRateThe desired communication speed with the Create 1 or 2
Returns
true if connection succeeded, false if connection failed
See also
disconnect
isConnected
BaudRate Create::defaultBaudRate ( ) const
inline

References PI.

bool Create::disconnect ( )

Cleans up connection to the create

Returns
true if disconnected, false otherwise
See also
connect
isConnected
Sensor<int>* Create::distance ( ) const
void Create::drive ( const short &  velocity,
const short &  radius 
)
void Create::driveDirect ( const short &  left,
const short &  right 
)
void Create::driveStraight ( const short &  speed)
void Create::endAtomicOperation ( )
inline
void Create::flush ( )
static Create* Create::instance ( )
static

The Create class is a singleton, which means that you cannot instantiate it directly. To get an instance of the create, you must use this method.

Returns
The global instance of the Create class
Sensor<unsigned char>* Create::ir ( ) const
bool Create::isConnected ( ) const
Returns
true if connected, false if not connected
See also
connect
disconnect
Sensor<bool>* Create::lightBumpCenterLeft ( ) const
Sensor<unsigned short>* Create::lightBumpCenterLeftSignal ( ) const
Sensor<bool>* Create::lightBumpCenterRight ( ) const
Sensor<unsigned short>* Create::lightBumpCenterRightSignal ( ) const
Sensor<bool>* Create::lightBumpFrontLeft ( ) const
Sensor<unsigned short>* Create::lightBumpFrontLeftSignal ( ) const
Sensor<bool>* Create::lightBumpFrontRight ( ) const
Sensor<unsigned short>* Create::lightBumpFrontRightSignal ( ) const
Sensor<bool>* Create::lightBumpLeft ( ) const
Sensor<unsigned short>* Create::lightBumpLeftSignal ( ) const
Sensor<bool>* Create::lightBumpRight ( ) const
Sensor<unsigned short>* Create::lightBumpRightSignal ( ) const
Create::Mode Create::mode ( )
void Create::move ( const short &  millimeters,
const unsigned short &  speed 
)

A very accurate move method based on time rather than the create's own readings, which are often less than accurate.

Parameters
millimetersThe amount to move, in millimeters.
speedThe speed each wheel should move at, in mm/s.
This function is blocking.
AbstractButton* Create::playButton ( ) const
short Create::read ( )

Reads one byte.

Returns
The read byte, or less than zero on error.
int Create::read ( unsigned char *  data,
const size_t &  len 
)

Reads a maximum of len bytes.

Parameters
dataPointer to the buffer to read into.
lenMaxiumum number of bytes to read. Should be less than or equal to the size of data.
Returns
The number of bytes actually read, or less than zero on error.
const unsigned short& Create::refreshRate ( ) const
void Create::send ( const CreateScript script)
const CreatePackets::_1* Create::sensorPacket1 ( )
const CreatePackets::_101* Create::sensorPacket101 ( )
const CreatePackets::_2* Create::sensorPacket2 ( )
const CreatePackets::_3* Create::sensorPacket3 ( )
const CreatePackets::_4* Create::sensorPacket4 ( )
const CreatePackets::_5* Create::sensorPacket5 ( )
void Create::setAngle ( const int  angle)
bool Create::setBaudRate ( const unsigned char &  baudCode)
void Create::setDefaultBaudRate ( const BaudRate  defaultBaudRate)
inline
void Create::setDistance ( const int  distance)
void Create::setFullMode ( )
void Create::setLeds ( const bool &  advance,
const bool &  play,
const unsigned char &  color,
const unsigned char &  brightness 
)
void Create::setMode ( const Create::Mode mode)
void Create::setOffMode ( )
void Create::setPassiveMode ( )
void Create::setRefreshRate ( const unsigned short &  refreshRate)
void Create::setSafeMode ( )
void Create::spin ( const short &  speed)

Spin the create at a constant velocity.

Parameters
speedThe speed each motor should move at. Positive is counter-clockwise.
void Create::spinClockwise ( const short &  speed)
void Create::spinCounterClockwise ( const short &  speed)
const CreateState* Create::state ( )
void Create::stop ( )
void Create::turn ( const short &  angle,
const unsigned short &  speed 
)

A very accurate turn method based on time rather than the create's own readings, which are often less than accurate.

Parameters
angleThe angle to turn, in degrees. Positive is counter-clockwise.
speedThe speed each wheel should move at, in mm/s. The angular velocity will be double this value.
This function is blocking.
Sensor<bool>* Create::virtualWall ( ) const
Sensor<bool>* Create::wall ( ) const
Sensor<unsigned short>* Create::wallSignal ( ) const
Sensor<bool>* Create::wheelDropCaster ( ) const
Sensor<bool>* Create::wheelDropLeft ( ) const
Sensor<bool>* Create::wheelDropRight ( ) const
bool Create::write ( const unsigned char &  c)
bool Create::write ( const unsigned char *  data,
const size_t &  len 
)

The documentation for this class was generated from the following file: