libkipr  1.0.0
iRobot (R) Create (TM)

Classes

class  kipr::create::CreateScript
 
class  kipr::create::Create
 Facilitates communication with the iRobot (R) Create (TM) More...
 

Functions

EXPORT_SYM int create_connect ()
 
EXPORT_SYM int create_connect_once ()
 
EXPORT_SYM void create_disconnect ()
 
EXPORT_SYM void create_passive ()
 
EXPORT_SYM void create_safe ()
 
EXPORT_SYM void create_full ()
 
EXPORT_SYM int get_create_mode ()
 
EXPORT_SYM int get_create_lbump ()
 
EXPORT_SYM int get_create_rbump ()
 
EXPORT_SYM int get_create_lwdrop ()
 
EXPORT_SYM int get_create_cwdrop ()
 
EXPORT_SYM int get_create_rwdrop ()
 
EXPORT_SYM int get_create_wall ()
 
EXPORT_SYM int get_create_lcliff ()
 
EXPORT_SYM int get_create_lfcliff ()
 
EXPORT_SYM int get_create_rfcliff ()
 
EXPORT_SYM int get_create_rcliff ()
 
EXPORT_SYM int get_create_llightbump ()
 
EXPORT_SYM int get_create_lflightbump ()
 
EXPORT_SYM int get_create_lclightbump ()
 
EXPORT_SYM int get_create_rclightbump ()
 
EXPORT_SYM int get_create_rflightbump ()
 
EXPORT_SYM int get_create_rlightbump ()
 
EXPORT_SYM int get_create_llightbump_amt ()
 
EXPORT_SYM int get_create_rlightbump_amt ()
 
EXPORT_SYM int get_create_lflightbump_amt ()
 
EXPORT_SYM int get_create_lclightbump_amt ()
 
EXPORT_SYM int get_create_rclightbump_amt ()
 
EXPORT_SYM int get_create_rflightbump_amt ()
 
EXPORT_SYM int get_create_vwall ()
 
EXPORT_SYM int get_create_infrared ()
 
EXPORT_SYM int get_create_advance_button ()
 
EXPORT_SYM int get_create_play_button ()
 
EXPORT_SYM int get_create_normalized_angle ()
 
EXPORT_SYM void set_create_normalized_angle (int angle)
 
EXPORT_SYM int get_create_total_angle ()
 
EXPORT_SYM void set_create_total_angle (int angle)
 
EXPORT_SYM int get_create_distance ()
 
EXPORT_SYM void set_create_distance (int dist)
 
EXPORT_SYM int get_create_battery_charging_state ()
 
EXPORT_SYM int get_create_battery_temp ()
 
EXPORT_SYM int get_create_battery_charge ()
 
EXPORT_SYM int get_create_battery_capacity ()
 
EXPORT_SYM int get_create_wall_amt ()
 
EXPORT_SYM int get_create_lcliff_amt ()
 
EXPORT_SYM int get_create_lfcliff_amt ()
 
EXPORT_SYM int get_create_rfcliff_amt ()
 
EXPORT_SYM int get_create_rcliff_amt ()
 
EXPORT_SYM int get_create_song_number ()
 
EXPORT_SYM int get_create_song_playing ()
 
EXPORT_SYM void create_stop ()
 
EXPORT_SYM void create_drive (int speed, int radius)
 
EXPORT_SYM void create_drive_straight (int speed)
 
EXPORT_SYM void create_spin_CW (int speed)
 
EXPORT_SYM void create_spin_CCW (int speed)
 
EXPORT_SYM void create_drive_direct (int l_speed, int r_speed)
 
EXPORT_SYM void create_spin_block (int speed, int angle)
 
EXPORT_SYM int _create_get_raw_encoders (long *lenc, long *renc)
 
EXPORT_SYM int create_load_song (const unsigned char *song, const unsigned char length, const unsigned char num)
 
EXPORT_SYM int create_play_song (const unsigned char num)
 
EXPORT_SYM int create_read_block (char *data, int count)
 
EXPORT_SYM void create_write_byte (char byte)
 
EXPORT_SYM void create_clear_serial_buffer ()
 
EXPORT_SYM enum BaudRate get_create_baud_rate ()
 
EXPORT_SYM void set_create_baud_rate (const enum BaudRate baudRate)
 
bool kipr::create::Create::loadSong (const unsigned char *song, const unsigned char length, const unsigned char songNum)
 
bool kipr::create::Create::playSong (const unsigned char songNum)
 

Detailed Description

The functions here allow for communication with the Create (roomba). They only work when there is a Create cable plugged into the wombat and into the Create.

Setup

Make sure to plug the usb side of the Create cable into the wombat and the other side into the Create.

Movement Example

Once you've done that, you can now use the roomba. The following example moves the roomba forward, swerves left, swerves right, and finally drives backwards.

#include <kipr/wombat.h>
#include <stdio.h>
int main(){
// connect to the create in order to control it
// move forward for 1 second
msleep(1000);
// swerve left
msleep(300);
// swerve right
msleep(300);
// go backwards for 1 second
create_drive_direct(-100, -100);
msleep(1000);
// stop moving
// disconnect before ending the program
return 0;
}
EXPORT_SYM int create_connect_once()
EXPORT_SYM void create_disconnect()
EXPORT_SYM void create_drive_direct(int l_speed, int r_speed)
void msleep(long msecs)

Function Documentation

◆ _create_get_raw_encoders()

EXPORT_SYM int _create_get_raw_encoders ( long *  lenc,
long *  renc 
)

Gets the displacement of the left wheel and right wheel and puts that data into the longs provided

Parameters
[out]lenc- where the left wheel's displacement is stored
[out]renc- where the right wheel's displacement is stored
Note
Not yet implemented

◆ create_clear_serial_buffer()

EXPORT_SYM void create_clear_serial_buffer ( )

Flushes commands to the create.

Note
This library already automatically flushes commands to the create

◆ create_connect()

EXPORT_SYM int create_connect ( )

Waits to establish a connection to the create.

This function blocks until A connection to a create is established
Returns
0 on success
See also
create_disconnect

◆ create_connect_once()

EXPORT_SYM int create_connect_once ( )

Attempts to establish a connection to the create.

Returns
1 if connection succeeded, 0 if connection failed
See also
create_disconnect

◆ create_disconnect()

EXPORT_SYM void create_disconnect ( )

Disconnects the controller from the iRobot Create.

ALWAYS disconnect from the iRobot Create before ending your program.

See also
create_connect

◆ create_drive()

EXPORT_SYM void create_drive ( int  speed,
int  radius 
)

Drive at the requested speed in an arc with the provided radius.

Parameters
speedThe speed (in mm/s) to drive at. Range is -500 to 500.
radiusThe radius (in mm) of the arc to drive through. Range is -2000 to 2000.

◆ create_drive_direct()

EXPORT_SYM void create_drive_direct ( int  l_speed,
int  r_speed 
)

Drive the create at the provided left wheel speed and right wheel speed.

Parameters
l_speedThe speed (in mm/s) to drive the left wheel at. Range is -500 to 500
r_speedThe speed (in mm/s) to drive the right wheel at. Range is -500 to 500

◆ create_drive_straight()

EXPORT_SYM void create_drive_straight ( int  speed)

Drive straight at the requested speed.

Parameters
speedThe speed (in mm/s) to drive at. Range is -500 to 500.

◆ create_full()

EXPORT_SYM void create_full ( )
See also
create_safe
create_passive
get_create_mode

Puts the iRobot Create in "Full Mode"

"Full Mode" allows the programmer to completely control all functions of the Create (disables safety blocks).

With this mode enabled, the Create will not prevent use of motors in situations where it detects an edge/cliff/etc.

Use this if you are having issues with the Create not moving after lifting it, falling, etc.

◆ create_load_song()

EXPORT_SYM int create_load_song ( const unsigned char *  song,
const unsigned char  length,
const unsigned char  num 
)

Loads a song for playing on the create

Parameters
songIt should be an array of unsigned chars (positive integers 0-255) The first value in a pair will be the midi value of the note the second value in the pair will be the duration (in 64ths of a second) for example, a song {88, 20, 91, 32, 70, 15} will play midi value 88 for 20/64ths of a second, midi value 91 for 32/64ths of a second, and midi value 70 for 15/64ths of a second. A full list of notes playable on the create is found at https://cdn-shop.adafruit.com/datasheets/create_2_Open_Interface_Spec.pdf on page 34
lengthThe length of the song. It is how many notes are in the song, not how many items are in your song array.
numThe song slot to load the song into; valid values are 0, 1, 2, and 3
Returns
1 on success, 0 on failure
Note
Example use: unsigned char example_song[] = {88, 20, 91, 32, 70, 15}; create_load_song(example_song, 3, 0);

◆ create_passive()

EXPORT_SYM void create_passive ( )
See also
create_safe
create_full
get_create_mode

When the Create is in Passive mode, you can request and receive sensor data using any of the sensor commands,

but you cannot change the current command parameters for the actuators (motors, speaker, lights, low side drivers, digital outputs) to something else.

To change how one of the actuators operates, you must switch from Passive mode to Full mode or Safe mode.

While in Passive mode, you can read Roomba’s sensors, watch Roomba perform a cleaning cycle, and charge the battery.

In Passive mode, Roomba will go into power saving mode to conserve battery power after five minutes of inactivity

Note
Appears to crash controller, do not use or use serial communication.

◆ create_play_song()

EXPORT_SYM int create_play_song ( const unsigned char  num)

Plays a song that has been loaded. Use create_load_song first.

Parameters
numThe song slot to play from; valid values are 0, 1, 2, and 3
Returns
1 on success, 0 on failure
See also
create_load_song

◆ create_read_block()

EXPORT_SYM int create_read_block ( char *  data,
int  count 
)

Reads sensor data from the create.

Parameters
data- This is where the read sensor data is stored
count- How many bytes to read from the create.
Returns
1 on success, 0 on failure.

◆ create_safe()

EXPORT_SYM void create_safe ( )
See also
create_full
create_passive
get_create_mode

Puts the iRobot Create in "Safe Mode"

Safe mode gives you full control of Roomba, with the exception of the following safety-related conditions.

safety-related conditions include: Cliff detection, wheel drop, and charging.

If your Create is refusing to move, try setting it to full mode.

◆ create_spin_block()

EXPORT_SYM void create_spin_block ( int  speed,
int  angle 
)

Turns the create the requested number of degrees at the requested speed.

Parameters
speedThe speed (in mm/s) to turn at. Range is -500 to 500
angleThe angle (in degrees) to turn.
Note
This is a blocking function, so you DO NOT need an msleep after it. It already sleeps for the time that it needs to execute the turn and doesn't need extra msleeps.

◆ create_spin_CCW()

EXPORT_SYM void create_spin_CCW ( int  speed)

Spin counter-clockwise at the requested speed. Spins in place.

Parameters
speedThe speed (in mm/s) to drive at. Range is -500 to 500.
Note
negative speeds will result in spinning clockwise

◆ create_spin_CW()

EXPORT_SYM void create_spin_CW ( int  speed)

Spin clockwise at the requested speed. Spins in place.

Parameters
speedThe speed (in mm/s) to drive at. Range is -500 to 500.
Note
negative speeds will result in spinning counter-clockwise

◆ create_stop()

EXPORT_SYM void create_stop ( )

Sets the create connection mode to off. No sensor data will be available, and the create will not respond to movement commands.

◆ create_write_byte()

EXPORT_SYM void create_write_byte ( char  byte)

Write a byte to the create. This is used to send commands directly to the create without using the functions provided in this library.

Note
If you want to directly send bytes to the create, consider checking out the actual create oi specifications: https://cdn-shop.adafruit.com/datasheets/create_2_Open_Interface_Spec.pdf

◆ get_create_advance_button()

EXPORT_SYM int get_create_advance_button ( )

Returns if the "advance" button is pressed.

Note
"Advance" is not a button on the newer Creates.

◆ get_create_battery_capacity()

EXPORT_SYM int get_create_battery_capacity ( )

Returns the capacity of the battery in milliAmp-Hours (mAH)

◆ get_create_battery_charge()

EXPORT_SYM int get_create_battery_charge ( )

returns the current charge on the battery in milliAmp-Hours (mAH)

◆ get_create_battery_charging_state()

EXPORT_SYM int get_create_battery_charging_state ( )
See also
get_create_battery_voltage
get_create_battery_current

returns the current charging state of the battery.

Not Charging: 0, Reconditioning Charging: 1, Full Charging: 2, Trickle Charging: 3, Waiting: 4, Charging Connection Fault: 5

◆ get_create_battery_temp()

EXPORT_SYM int get_create_battery_temp ( )

returns the temperature of the battery in degrees Celcius

◆ get_create_baud_rate()

EXPORT_SYM enum BaudRate get_create_baud_rate ( )

Returns the baud rate of the create.

Note
The baud rate is how many times a second the create updates its sensors and receives commands.

◆ get_create_cwdrop()

EXPORT_SYM int get_create_cwdrop ( )
See also
get_create_rwdrop
get_create_lwdrop
Note
Not Implemented

◆ get_create_distance()

EXPORT_SYM int get_create_distance ( )
See also
set_create_distance

Gets the distance traveled based on encoder values in the wheels.

Units should be in millimeters (mm)

◆ get_create_infrared()

EXPORT_SYM int get_create_infrared ( )

The Docks, Virutal Walls, etc. send out infrared signals that the Create can pick up.

For example, Right of dock ("Green Buoy"): 164, Left of Dock ("Red Buoy"): 168, "Force Field": 161

You can also potentially control the Create with IR signals for forward, backward, etc.

See iRobot Create Manual for more information ("Characters sent by iRobot devices")

◆ get_create_lbump()

EXPORT_SYM int get_create_lbump ( )
See also
get_create_rbump

Returns the status of the left bumper as a digital value (0 or 1).

◆ get_create_lcliff()

EXPORT_SYM int get_create_lcliff ( )
See also
get_create_lfcliff
get_create_rfcliff
get_create_rcliff

reports if the left cliff/edge sensor is tripped.

◆ get_create_lcliff_amt()

EXPORT_SYM int get_create_lcliff_amt ( )

Returns the value measured by the left-most cliff sensor.

Note
For line following purposes, this can be treated like a tophat sensor value. Lower values often indicate black, higher values often indicate white.
See also
get_create_lcliff

◆ get_create_lclightbump()

EXPORT_SYM int get_create_lclightbump ( )
See also
get_create_lflightbump
get_create_llightbump
get_create_rclightbump
get_create_rflightbump
get_create_rlightbump

returns the left-center light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_lclightbump_amt()

EXPORT_SYM int get_create_lclightbump_amt ( )
See also
get_create_lflightbump_amt
get_create_llightbump_amt
get_create_rclightbump_amt
get_create_rflightbump_amt
get_create_rlightbump_amt

returns the left-center light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_lfcliff()

EXPORT_SYM int get_create_lfcliff ( )
See also
get_create_lcliff
get_create_rfcliff
get_create_rcliff

reports if the front-left cliff/edge sensor is tripped.

◆ get_create_lfcliff_amt()

EXPORT_SYM int get_create_lfcliff_amt ( )

Returns the value measured by the left-front cliff sensor.

Note
For line following purposes, this can be treated like a tophat sensor value. Lower values often indicate black, higher values often indicate white.
See also
get_create_lfcliff

◆ get_create_lflightbump()

EXPORT_SYM int get_create_lflightbump ( )
See also
get_create_llightbump
get_create_lclightbump
get_create_rclightbump
get_create_rflightbump
get_create_rlightbump

returns the left-front light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_lflightbump_amt()

EXPORT_SYM int get_create_lflightbump_amt ( )
See also
get_create_llightbump_amt
get_create_lclightbump_amt
get_create_rclightbump_amt
get_create_rflightbump_amt
get_create_rlightbump_amt

returns the left-front light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_llightbump()

EXPORT_SYM int get_create_llightbump ( )
See also
get_create_lflightbump
get_create_lclightbump
get_create_rclightbump
get_create_rflightbump
get_create_rlightbump

returns the left light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_llightbump_amt()

EXPORT_SYM int get_create_llightbump_amt ( )
See also
get_create_lflightbump_amt
get_create_lclightbump_amt
get_create_rclightbump_amt
get_create_rflightbump_amt
get_create_rlightbump_amt

returns the left light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_lwdrop()

EXPORT_SYM int get_create_lwdrop ( )
See also
get_create_rwdrop

Detects if the left wheel is dropped/lowered (the create is lifted)

◆ get_create_mode()

EXPORT_SYM int get_create_mode ( )
See also
create_safe
create_passive
create_full

Gets the current mode of the Create OI

Off: 0, Passive: 1, Safe: 2, Full: 3

◆ get_create_normalized_angle()

EXPORT_SYM int get_create_normalized_angle ( )
See also
set_create_normalized_angle

returns the normalized angle that the create is at in degrees (angle mod 360).

"Normalized" means that the angle is converted to be between 0 and 360 degrees first.

◆ get_create_play_button()

EXPORT_SYM int get_create_play_button ( )

Returns if the "play" button is pressed.

Note
"Play" is not a button on the newer Creates.

◆ get_create_rbump()

EXPORT_SYM int get_create_rbump ( )
See also
get_create_lbump

Returns the status of the right bumper as a digital value (0 or 1).

◆ get_create_rcliff()

EXPORT_SYM int get_create_rcliff ( )
See also
get_create_lcliff
get_create_lfcliff
get_create_rfcliff

reports if the right cliff/edge sensor is tripped.

◆ get_create_rcliff_amt()

EXPORT_SYM int get_create_rcliff_amt ( )

Returns the value measured by the right-most cliff sensor.

Note
For line following purposes, this can be treated like a tophat sensor value. Lower values often indicate black, higher values often indicate white.

◆ get_create_rclightbump()

EXPORT_SYM int get_create_rclightbump ( )
See also
get_create_lflightbump
get_create_lclightbump
get_create_llightbump
get_create_rflightbump
get_create_rlightbump

returns the right-center light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_rclightbump_amt()

EXPORT_SYM int get_create_rclightbump_amt ( )
See also
get_create_lflightbump_amt
get_create_lclightbump_amt
get_create_llightbump_amt
get_create_rflightbump_amt
get_create_rlightbump_amt

returns the right-center light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_rfcliff()

EXPORT_SYM int get_create_rfcliff ( )
See also
get_create_lcliff
get_create_rcliff
get_create_lfcliff

reports if the front-right cliff/edge sensor is tripped.

◆ get_create_rfcliff_amt()

EXPORT_SYM int get_create_rfcliff_amt ( )

Returns the value measured by the right-front cliff sensor.

Note
For line following purposes, this can be treated like a tophat sensor value. Lower values often indicate black, higher values often indicate white.
See also
get_create_rfcliff

◆ get_create_rflightbump()

EXPORT_SYM int get_create_rflightbump ( )
See also
get_create_lflightbump
get_create_lclightbump
get_create_rclightbump
get_create_llightbump
get_create_rlightbump

returns the right-front light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_rflightbump_amt()

EXPORT_SYM int get_create_rflightbump_amt ( )
See also
get_create_lflightbump_amt
get_create_lclightbump_amt
get_create_rclightbump_amt
get_create_llightbump_amt
get_create_rlightbump_amt

returns the right-front light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_rlightbump()

EXPORT_SYM int get_create_rlightbump ( )
See also
get_create_lflightbump
get_create_lclightbump
get_create_rclightbump
get_create_rflightbump
get_create_llightbump

returns the right light bumper sensor as described in the iRobot Create manual.

returns a binary/digital value rather than the raw sensor data (on or off/1 or 0).

◆ get_create_rlightbump_amt()

EXPORT_SYM int get_create_rlightbump_amt ( )
See also
get_create_lflightbump_amt
get_create_lclightbump_amt
get_create_rclightbump_amt
get_create_rflightbump_amt
get_create_llightbump_amt

returns the right light bumper sensor as described in the iRobot Create manual.

returns the amount the sensor is pressed, rather than a binary value.

◆ get_create_rwdrop()

EXPORT_SYM int get_create_rwdrop ( )
See also
get_create_lwdrop

Detects if the right wheel is dropped/lowered (the create is lifted)

◆ get_create_song_number()

EXPORT_SYM int get_create_song_number ( )
Returns
The song slot of the current song

◆ get_create_song_playing()

EXPORT_SYM int get_create_song_playing ( )
Returns
1 if it the create is playing a song, 0 if the create isn't playing a song

◆ get_create_total_angle()

EXPORT_SYM int get_create_total_angle ( )
See also
set_create_total_angle

returns the angle the Create is currently turned to (does not "normalize").

This value is any value as it is not normalized to a range of [0,360)

◆ get_create_vwall()

EXPORT_SYM int get_create_vwall ( )
See also
get_create_wall

Reports if there is a virutal wall.

Note
The botball kit does not contain a "virtual wall" unit as of Fall 2019.

◆ get_create_wall()

EXPORT_SYM int get_create_wall ( )
See also
get_create_vwall

Reports if the Create sees a physical wall.

Note
The Create only detects walls on the right because Roombas only need it on the right side.

◆ get_create_wall_amt()

EXPORT_SYM int get_create_wall_amt ( )

Returns the wall signal sensed by the create.

See also
get_create_wall

◆ loadSong()

bool kipr::create::Create::loadSong ( const unsigned char *  song,
const unsigned char  length,
const unsigned char  songNum 
)

Loads a song for playing on the create

Parameters
songIt should be an array of unsigned chars (positive integers 0-255) The first value in a pair will be the midi value of the note the second value in the pair will be the duration (in 64ths of a second) for example, a song {88, 20, 91, 32, 70, 15} will play midi value 88 for 20/64ths of a second, midi value 91 for 32/64ths of a second, and midi value 70 for 15/64ths of a second. A full list of notes playable on the create is found at https://cdn-shop.adafruit.com/datasheets/create_2_Open_Interface_Spec.pdf on page 34
lengthThe length of the song. It is how many notes are in the song, not how many items are in your song array.
numThe song slot to load the song into; valid values are 0, 1, 2, and 3
Returns
1 on success, 0 on failure
Note
Example use: unsigned char example_song[] = {88, 20, 91, 32, 70, 15}; create_load_song(example_song, 3, 0);

◆ playSong()

bool kipr::create::Create::playSong ( const unsigned char  songNum)

Plays a song that has been loaded. Use create_load_song first.

Parameters
numThe song slot to play from; valid values are 0, 1, 2, and 3
Returns
1 on success, 0 on failure
See also
create_load_song

◆ set_create_baud_rate()

EXPORT_SYM void set_create_baud_rate ( const enum BaudRate  baudRate)

Sets the create's baud rate to the provided baud rate.

◆ set_create_distance()

EXPORT_SYM void set_create_distance ( int  dist)

Sets the current distance the create thinks it has traveled.

Use this to set it's reference for where it is.

◆ set_create_normalized_angle()

EXPORT_SYM void set_create_normalized_angle ( int  angle)
See also
get_create_normalized_angle

Set the current angle that the create is at.

Sets what the create should use as a reference for its angle

◆ set_create_total_angle()

EXPORT_SYM void set_create_total_angle ( int  angle)
See also
get_create_total_angle

Set the current angle that the create is at for the total angle functions.

Sets what the create should use as a reference for its angle