libkipr  1.0.0
kipr::create::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)
 
button::AbstractButtonplayButton () const
 
button::AbstractButtonadvanceButton () const
 
sensor::Sensor< bool > * wall () const
 
sensor::Sensor< bool > * cliffLeft () const
 
sensor::Sensor< bool > * cliffFrontLeft () const
 
sensor::Sensor< bool > * cliffFrontRight () const
 
sensor::Sensor< bool > * cliffRight () const
 
sensor::Sensor< bool > * virtualWall () const
 
sensor::Sensor< unsigned short > * wallSignal () const
 
sensor::Sensor< unsigned short > * cliffLeftSignal () const
 
sensor::Sensor< unsigned short > * cliffFrontLeftSignal () const
 
sensor::Sensor< unsigned short > * cliffFrontRightSignal () const
 
sensor::Sensor< unsigned short > * cliffRightSignal () const
 
sensor::Sensor< unsigned short > * cargoBayAnalogSignal () const
 
sensor::Sensor< unsigned char > * cargoBayDigitalInputs () const
 
sensor::Sensor< unsigned char > * ir () const
 
sensor::Sensor< unsigned char > * chargingState () const
 
sensor::Sensor< char > * batteryTemperature () const
 
sensor::Sensor< unsigned short > * batteryCharge () const
 
sensor::Sensor< unsigned short > * batteryCapacity () const
 
sensor::Sensor< int > * angle () const
 
sensor::Sensor< int > * distance () const
 
sensor::Sensor< bool > * bumpLeft () const
 
sensor::Sensor< bool > * bumpRight () const
 
sensor::Sensor< bool > * wheelDropLeft () const
 
sensor::Sensor< bool > * wheelDropRight () const
 
sensor::Sensor< bool > * wheelDropCaster () const
 
sensor::Sensor< bool > * lightBumpLeft () const
 
sensor::Sensor< bool > * lightBumpFrontLeft () const
 
sensor::Sensor< bool > * lightBumpCenterLeft () const
 
sensor::Sensor< bool > * lightBumpCenterRight () const
 
sensor::Sensor< bool > * lightBumpFrontRight () const
 
sensor::Sensor< bool > * lightBumpRight () const
 
sensor::Sensor< unsigned short > * lightBumpLeftSignal () const
 
sensor::Sensor< unsigned short > * lightBumpFrontLeftSignal () const
 
sensor::Sensor< unsigned short > * lightBumpCenterLeftSignal () const
 
sensor::Sensor< unsigned short > * lightBumpCenterRightSignal () const
 
sensor::Sensor< unsigned short > * lightBumpFrontRightSignal () const
 
sensor::Sensor< unsigned short > * lightBumpRightSignal () const
 
sensor::Sensor< unsigned char > * songPlaying () const
 
sensor::Sensor< unsigned char > * songNumber () const
 
void setRefreshRate (const unsigned short &refreshRate)
 
const unsigned short & refreshRate () const
 
bool loadSong (const unsigned char *song, const unsigned char length, const unsigned char songNum)
 
bool playSong (const unsigned char songNum)
 
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()

kipr::create::Create::~Create ( )

Member Function Documentation

◆ advanceButton()

button::AbstractButton* kipr::create::Create::advanceButton ( ) const

◆ angle()

sensor::Sensor<int>* kipr::create::Create::angle ( ) const

◆ angularVelocity()

short kipr::create::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::Sensor<unsigned short>* kipr::create::Create::batteryCapacity ( ) const

◆ batteryCharge()

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

◆ batteryTemperature()

sensor::Sensor<char>* kipr::create::Create::batteryTemperature ( ) const

◆ beginAtomicOperation()

void kipr::create::Create::beginAtomicOperation ( )
inline

◆ blockingRead() [1/2]

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

◆ blockingRead() [2/2]

bool kipr::create::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::Sensor<bool>* kipr::create::Create::bumpLeft ( ) const

◆ bumpRight()

sensor::Sensor<bool>* kipr::create::Create::bumpRight ( ) const

◆ cargoBayAnalogSignal()

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

◆ cargoBayDigitalInputs()

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

◆ chargingState()

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

◆ cliffFrontLeft()

sensor::Sensor<bool>* kipr::create::Create::cliffFrontLeft ( ) const

◆ cliffFrontLeftSignal()

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

◆ cliffFrontRight()

sensor::Sensor<bool>* kipr::create::Create::cliffFrontRight ( ) const

◆ cliffFrontRightSignal()

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

◆ cliffLeft()

sensor::Sensor<bool>* kipr::create::Create::cliffLeft ( ) const

◆ cliffLeftSignal()

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

◆ cliffRight()

sensor::Sensor<bool>* kipr::create::Create::cliffRight ( ) const

◆ cliffRightSignal()

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

◆ connect() [1/2]

bool kipr::create::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 kipr::create::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 kipr::create::Create::defaultBaudRate ( ) const
inline

◆ disconnect()

bool kipr::create::Create::disconnect ( )

Cleans up connection to the create

Returns
true if disconnected, false otherwise
See also
connect
isConnected

◆ distance()

sensor::Sensor<int>* kipr::create::Create::distance ( ) const

◆ drive()

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

◆ driveDirect()

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

◆ driveStraight()

void kipr::create::Create::driveStraight ( const short &  speed)

◆ endAtomicOperation()

void kipr::create::Create::endAtomicOperation ( )
inline

◆ flush()

void kipr::create::Create::flush ( )

◆ instance()

static Create* kipr::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::Sensor<unsigned char>* kipr::create::Create::ir ( ) const

◆ isConnected()

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

◆ lightBumpCenterLeft()

sensor::Sensor<bool>* kipr::create::Create::lightBumpCenterLeft ( ) const

◆ lightBumpCenterLeftSignal()

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

◆ lightBumpCenterRight()

sensor::Sensor<bool>* kipr::create::Create::lightBumpCenterRight ( ) const

◆ lightBumpCenterRightSignal()

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

◆ lightBumpFrontLeft()

sensor::Sensor<bool>* kipr::create::Create::lightBumpFrontLeft ( ) const

◆ lightBumpFrontLeftSignal()

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

◆ lightBumpFrontRight()

sensor::Sensor<bool>* kipr::create::Create::lightBumpFrontRight ( ) const

◆ lightBumpFrontRightSignal()

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

◆ lightBumpLeft()

sensor::Sensor<bool>* kipr::create::Create::lightBumpLeft ( ) const

◆ lightBumpLeftSignal()

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

◆ lightBumpRight()

sensor::Sensor<bool>* kipr::create::Create::lightBumpRight ( ) const

◆ lightBumpRightSignal()

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

◆ mode()

Create::Mode kipr::create::Create::mode ( )

◆ move()

void kipr::create::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()

button::AbstractButton* kipr::create::Create::playButton ( ) const

◆ read() [1/2]

short kipr::create::Create::read ( )

Reads one byte.

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

◆ read() [2/2]

int kipr::create::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& kipr::create::Create::refreshRate ( ) const

◆ send()

void kipr::create::Create::send ( const CreateScript script)

◆ sensorPacket1()

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

◆ sensorPacket101()

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

◆ sensorPacket2()

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

◆ sensorPacket3()

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

◆ sensorPacket4()

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

◆ sensorPacket5()

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

◆ setAngle()

void kipr::create::Create::setAngle ( const int  angle)

◆ setBaudRate()

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

◆ setDefaultBaudRate()

void kipr::create::Create::setDefaultBaudRate ( const BaudRate  defaultBaudRate)
inline

◆ setDistance()

void kipr::create::Create::setDistance ( const int  distance)

◆ setFullMode()

void kipr::create::Create::setFullMode ( )

◆ setLeds()

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

◆ setMode()

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

◆ setOffMode()

void kipr::create::Create::setOffMode ( )

◆ setPassiveMode()

void kipr::create::Create::setPassiveMode ( )

◆ setRefreshRate()

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

◆ setSafeMode()

void kipr::create::Create::setSafeMode ( )

◆ songNumber()

sensor::Sensor<unsigned char>* kipr::create::Create::songNumber ( ) const

◆ songPlaying()

sensor::Sensor<unsigned char>* kipr::create::Create::songPlaying ( ) const

◆ spin()

void kipr::create::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 kipr::create::Create::spinClockwise ( const short &  speed)

◆ spinCounterClockwise()

void kipr::create::Create::spinCounterClockwise ( const short &  speed)

◆ state()

const CreateState* kipr::create::Create::state ( )

◆ stop()

void kipr::create::Create::stop ( )

◆ turn()

void kipr::create::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::Sensor<bool>* kipr::create::Create::virtualWall ( ) const

◆ wall()

sensor::Sensor<bool>* kipr::create::Create::wall ( ) const

◆ wallSignal()

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

◆ wheelDropCaster()

sensor::Sensor<bool>* kipr::create::Create::wheelDropCaster ( ) const

◆ wheelDropLeft()

sensor::Sensor<bool>* kipr::create::Create::wheelDropLeft ( ) const

◆ wheelDropRight()

sensor::Sensor<bool>* kipr::create::Create::wheelDropRight ( ) const

◆ write() [1/2]

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

◆ write() [2/2]

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

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