Robot Commands

codorobo module contain methods to control the robot and get data from the robot.

Sample usage:

>>> import coderobo
>>> coderobo.moveForward()
coderobo.closeClaw()

Close the claw to grab the object in front of the claw.

Note: The robot will grab a object within 0.25 m in front of the claw.

coderobo.display()

Display text or number by the robot.

coderobo.getDistanceToCollision(dir)

Get distance to collisionin the requested directions.

Parameters

dir (string) – direction. Options: ‘FRONT’, ‘BACK’, ‘LEFT’, ‘RIGHT’

coderobo.isAtGoal()

Detect if the robot has reached it’s goal.

Returns

True if the robot is at the goal.

Return type

bool

coderobo.isObjectPresent()

Detect if an object in present under the robot.

Note: This is a simplified API only for the ‘Introduction to Programming’ course.

Returns

True if the object is present .

Return type

bool

coderobo.liftArm()

Lift the arm to raise the object in the claw.

coderobo.lowerArm()

Lower the arm to lower the object in the claw.

coderobo.moveBackward()

Move the robot backward by one step.

coderobo.moveBackwardByX(distance)

Move the robot backward by X distance.

Parameters

distance (float) – Distance to travese

coderobo.moveForward()

Move the robot forward by one step.

coderobo.moveForwardByX(distance)

Move the robot forward by X distance.

Parameters

distance (float) – Distance to travese

coderobo.openClaw()

Open the claw to release the object held by the claw.

coderobo.pickUpObject()

Pick up the object under the robot.

Note: This is a simplified API only for the ‘Introduction to Programming’ course.

coderobo.pickUpPen()

Pick up pen from the robot. After this API is called, the robot stop drawing as it moves on the canvas.

coderobo.placePen()

Place pen on the robot. After this API is called, the robot starts drawing as it moves on the canvas.

coderobo.setPenColor(color)

Set color of the pen.

Parameters

color (string) – Color of the pen (for example: ‘#FF0000’)

coderobo.turnLeft()

Turn the robot to the left by 90 degrees.

coderobo.turnLeftByX(degree)

Turn to the left by X degrees.

Parameters

degree (float) – angle in degrees.

coderobo.turnRight()

Turn the robot to the right by 90 degrees.

coderobo.turnRightByX(degree)

Turn to the right by X degrees.

Parameters

degree (float) – angle in degrees.