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

◆ BaudRate

Enumerator
Baud57600 
Baud115200 

◆ Mode

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::~Create ( )

Member Function Documentation

◆ advanceButton()

AbstractButton* Create::advanceButton ( ) const

◆ angle()

Sensor<int>* Create::angle ( ) const

◆ angularVelocity()

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

◆ batteryCapacity()

Sensor<unsigned short>* Create::batteryCapacity ( ) const

◆ batteryCharge()

Sensor<unsigned short>* Create::batteryCharge ( ) const

◆ batteryTemperature()

Sensor<char>* Create::batteryTemperature ( ) const

◆ beginAtomicOperation()

void Create::beginAtomicOperation ( )
inline

◆ blockingRead() [1/2]

template<typename T >
bool Create::blockingRead ( T &  data,
unsigned  timeout = 0 
)
inline

◆ blockingRead() [2/2]

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.

◆ bumpLeft()

Sensor<bool>* Create::bumpLeft ( ) const

◆ bumpRight()

Sensor<bool>* Create::bumpRight ( ) const

◆ cargoBayAnalogSignal()

Sensor<unsigned short>* Create::cargoBayAnalogSignal ( ) const

◆ cargoBayDigitalInputs()

Sensor<unsigned char>* Create::cargoBayDigitalInputs ( ) const

◆ chargingState()

Sensor<unsigned char>* Create::chargingState ( ) const

◆ cliffFrontLeft()

Sensor<bool>* Create::cliffFrontLeft ( ) const

◆ cliffFrontLeftSignal()

Sensor<unsigned short>* Create::cliffFrontLeftSignal ( ) const

◆ cliffFrontRight()

Sensor<bool>* Create::cliffFrontRight ( ) const

◆ cliffFrontRightSignal()

Sensor<unsigned short>* Create::cliffFrontRightSignal ( ) const

◆ cliffLeft()

Sensor<bool>* Create::cliffLeft ( ) const

◆ cliffLeftSignal()

Sensor<unsigned short>* Create::cliffLeftSignal ( ) const

◆ cliffRight()

Sensor<bool>* Create::cliffRight ( ) const

◆ cliffRightSignal()

Sensor<unsigned short>* Create::cliffRightSignal ( ) const

◆ connect() [1/2]

bool Create::connect ( )

Attempts to establish a connection to the create

Returns
true if connection succeeded, false if connection failed
See also
disconnect
isConnected

◆ connect() [2/2]

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

◆ defaultBaudRate()

BaudRate Create::defaultBaudRate ( ) const
inline

◆ disconnect()

bool Create::disconnect ( )

Cleans up connection to the create

Returns
true if disconnected, false otherwise
See also
connect
isConnected

◆ distance()

Sensor<int>* Create::distance ( ) const

◆ drive()

void Create::drive ( const short &  velocity,
const short &  radius 
)

◆ driveDirect()

void Create::driveDirect ( const short &  left,
const short &  right 
)

◆ driveStraight()

void Create::driveStraight ( const short &  speed)

◆ endAtomicOperation()

void Create::endAtomicOperation ( )
inline

◆ flush()

void Create::flush ( )

◆ instance()

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

◆ ir()

Sensor<unsigned char>* Create::ir ( ) const

◆ isConnected()

bool Create::isConnected ( ) const
Returns
true if connected, false if not connected
See also
connect
disconnect

◆ lightBumpCenterLeft()

Sensor<bool>* Create::lightBumpCenterLeft ( ) const

◆ lightBumpCenterLeftSignal()

Sensor<unsigned short>* Create::lightBumpCenterLeftSignal ( ) const

◆ lightBumpCenterRight()

Sensor<bool>* Create::lightBumpCenterRight ( ) const

◆ lightBumpCenterRightSignal()

Sensor<unsigned short>* Create::lightBumpCenterRightSignal ( ) const

◆ lightBumpFrontLeft()

Sensor<bool>* Create::lightBumpFrontLeft ( ) const

◆ lightBumpFrontLeftSignal()

Sensor<unsigned short>* Create::lightBumpFrontLeftSignal ( ) const

◆ lightBumpFrontRight()

Sensor<bool>* Create::lightBumpFrontRight ( ) const

◆ lightBumpFrontRightSignal()

Sensor<unsigned short>* Create::lightBumpFrontRightSignal ( ) const

◆ lightBumpLeft()

Sensor<bool>* Create::lightBumpLeft ( ) const

◆ lightBumpLeftSignal()

Sensor<unsigned short>* Create::lightBumpLeftSignal ( ) const

◆ lightBumpRight()

Sensor<bool>* Create::lightBumpRight ( ) const

◆ lightBumpRightSignal()

Sensor<unsigned short>* Create::lightBumpRightSignal ( ) const

◆ mode()

Create::Mode Create::mode ( )

◆ move()

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.

◆ playButton()

AbstractButton* Create::playButton ( ) const

◆ read() [1/2]

short Create::read ( )

Reads one byte.

Returns
The read byte, or less than zero on error.

◆ read() [2/2]

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.

◆ refreshRate()

const unsigned short& Create::refreshRate ( ) const

◆ send()

void Create::send ( const CreateScript script)

◆ sensorPacket1()

const CreatePackets::_1* Create::sensorPacket1 ( )

◆ sensorPacket101()

const CreatePackets::_101* Create::sensorPacket101 ( )

◆ sensorPacket2()

const CreatePackets::_2* Create::sensorPacket2 ( )

◆ sensorPacket3()

const CreatePackets::_3* Create::sensorPacket3 ( )

◆ sensorPacket4()

const CreatePackets::_4* Create::sensorPacket4 ( )

◆ sensorPacket5()

const CreatePackets::_5* Create::sensorPacket5 ( )

◆ setAngle()

void Create::setAngle ( const int  angle)

◆ setBaudRate()

bool Create::setBaudRate ( const unsigned char &  baudCode)

◆ setDefaultBaudRate()

void Create::setDefaultBaudRate ( const BaudRate  defaultBaudRate)
inline

◆ setDistance()

void Create::setDistance ( const int  distance)

◆ setFullMode()

void Create::setFullMode ( )

◆ setLeds()

void Create::setLeds ( const bool &  advance,
const bool &  play,
const unsigned char &  color,
const unsigned char &  brightness 
)

◆ setMode()

void Create::setMode ( const Create::Mode mode)

◆ setOffMode()

void Create::setOffMode ( )

◆ setPassiveMode()

void Create::setPassiveMode ( )

◆ setRefreshRate()

void Create::setRefreshRate ( const unsigned short &  refreshRate)

◆ setSafeMode()

void Create::setSafeMode ( )

◆ spin()

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.

◆ spinClockwise()

void Create::spinClockwise ( const short &  speed)

◆ spinCounterClockwise()

void Create::spinCounterClockwise ( const short &  speed)

◆ state()

const CreateState* Create::state ( )

◆ stop()

void Create::stop ( )

◆ turn()

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.

◆ virtualWall()

Sensor<bool>* Create::virtualWall ( ) const

◆ wall()

Sensor<bool>* Create::wall ( ) const

◆ wallSignal()

Sensor<unsigned short>* Create::wallSignal ( ) const

◆ wheelDropCaster()

Sensor<bool>* Create::wheelDropCaster ( ) const

◆ wheelDropLeft()

Sensor<bool>* Create::wheelDropLeft ( ) const

◆ wheelDropRight()

Sensor<bool>* Create::wheelDropRight ( ) const

◆ write() [1/2]

bool Create::write ( const unsigned char &  c)

◆ write() [2/2]

bool Create::write ( const unsigned char *  data,
const size_t &  len 
)

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