Cardboard Robot SDK
 All Classes Namespaces Functions Enumerations Properties Events
Properties | Public Member Functions | Protected Member Functions | Events | List of all members
CBRobot.Robot Class Reference

Detailed Description

The main cardboard robot class.

Most functionality to control the robot can be accessed from here.

Note: You MUST dispose of the robot instance after you are done with it, or the application will never quit. A good place to do this is in the FormClosed event handler of your main form.

Connection / disconnection will be detected automatically, but only at an interval of 5 seconds. To enable faster detection, you must pass in a valid window handle to the constructor, and forward windows messages from your form to the HandleWindowsMessage() function.

Inherits IDisposable.

Properties

bool Connected [get]
 Gets whether or not the robot device is currently connected.
 
ArmPosition CurrentPosition [get, set]
 Gets or sets the current position of the robot's arm.
 
ArmPosition TargetPosition [get, set]
 Gets or sets the target position of the robot's arm.
 
ArmSpeed Speed [get, set]
 Gets or sets the desired speed of the robot's arm.
 
static ArmSpeed DefaultSpeed [get]
 Gets the robot's default speed.
 
bool Paused [get, set]
 Gets or sets whether the robot is currently in a paused state.
 
double ArmLength1 [get, set]
 Gets or sets the length of the first arm segment (from pivot to pivot), measured in centimeters.
 
double ArmLength2 [get, set]
 Gets or sets the length of the second arm segment (from pivot to pivot), measured in centimeters.
 
Path Path [get, set]
 Specifies the path that the robot should execute.
 

Public Member Functions

 Robot (IntPtr windowHandle)
 Creates a new robot instance.
 
void Dispose ()
 Releases all resources used by the robot, and allows the application to quit.
 
void HandleWindowsMessage (ref Message m)
 Call this to process windows messages that affect device status, such as WM_DEVICECHANGE.
 
void UpdateFromDevice ()
 Updates the robot's CurrentPosition property from the device.
 
MotorParameters GetMotorParameters (int motorNumber)
 Returns the parameters for the specified motor (1 through 4)
 
double ConvertStepsToAngle (double steps, int motorNumber)
 Converts a step count into an angle (in radians) for the given motor (1 through 4).
 
double ConvertAngleToSteps (double angle, int motorNumber)
 Converts an angle (in radians) into a step count for the given motor (1 through 4).
 
void SetHomePosition ()
 Sets the current position as the new home position / zero position.
 
bool IsWithinThresholdOfTarget (double steps)
 Returns true if each motor of the robot is within the given number of steps of its target position (not rounded).
 
bool IsMotorWithinThresholdOfTarget (int motor, double steps)
 Returns true if the given motor (1 - 4) is within the given number of steps of the target position (not rounded).
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Events

EventHandler ConnectionStatusChanged
 Fired when the connection status has changed.
 
EventHandler TargetPositionChanged
 Fired when the TargetPosition property changes.
 
EventHandler PausedChanged
 Fired when the Paused property changes.
 
EventHandler SpeedChanged
 Fired when the Speed property changes.
 
EventHandler PathChanged
 Fired when the Path property changes.
 

Property Documentation

double CBRobot.Robot.ArmLength1
getset

Gets or sets the length of the first arm segment (from pivot to pivot), measured in centimeters.

You should generally only need to change this value if you replace the arm segment with a custom-sized one.

double CBRobot.Robot.ArmLength2
getset

Gets or sets the length of the second arm segment (from pivot to pivot), measured in centimeters.

You should generally only need to change this value if you replace the arm segment with a custom-sized one.

bool CBRobot.Robot.Connected
get

Gets whether or not the robot device is currently connected.

Connection to the device is automatic; there's no need to manually connect.

ArmPosition CBRobot.Robot.CurrentPosition
getset

Gets or sets the current position of the robot's arm.

This value is frequently overwritten with data read from the device, and setting it will have no effect. Set TargetPosition and Speed instead to make the robot's arm move. You may also have to call UpdateFromRobot() before reading this property to obtain the latest position from the device.

Path CBRobot.Robot.Path
getset

Specifies the path that the robot should execute.

Note that the target position and speed cannot be updated manually while a path is executing. Set this property to null to have the robot stop executing the current path.

Constructor & Destructor Documentation

CBRobot.Robot.Robot ( IntPtr  windowHandle)
inline

Creates a new robot instance.

Member Function Documentation

double CBRobot.Robot.ConvertAngleToSteps ( double  angle,
int  motorNumber 
)
inline

Converts an angle (in radians) into a step count for the given motor (1 through 4).

Does NOT round the resulting step count to a whole number.

double CBRobot.Robot.ConvertStepsToAngle ( double  steps,
int  motorNumber 
)
inline

Converts a step count into an angle (in radians) for the given motor (1 through 4).

Does NOT round the step count to a whole number.


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