CurrentRobotState class



The CurrentRobotState class provides a small interface that provides access to the robot. Through a reference to this class, you can obtain references to Motor and Sensor objects, and directly set and query components of the gripper arm unit. A set of class fields define contstant legal values for arm and gripper positions.


Class Fields

public static final int ARM_UP
public static final int ARM_DOWN
public static final int GRIP_OPEN
public static final int GRIP_CLOSED

Methods

Motor getMotorState() - returns a reference to the current Motor object. Use this returned reference to set motor speeds, etc.
Sensor[] getSensorValues() - returns a reference to an array of 8 Sensor objects. Each Sensor object in the array refers to 1 of the 8 IR sensors on the robot. The array indexes (0-7) access the sensors starting at the leftmost sensor (i.e. Sensor[0]) as you look at the top of the robot with its front facing up. The rest are indexed going clock-wise around the robot from this perspective.
int getArmState() - returns one of the two arm constants as defined above. Provides information on the gripper arm's current position.
void setArmState(int arm) - accepts one of the two arm constants as defined above. This will move the gripper arm to the specified position.
int getGripperState() - returns one of the two gripper constants as defined above. Provides information on the grippers' current position.
void setGripperState(int grip) - accepts one of the two gripper constants as defined above. This will move the grippers to the specified position. If an object is between the grippers, it will effectively grab the object.
boolean isObjectPresent() - returns true if an object is currently detected by the gripper sensor, false otherwise. The gripper sensor detects anything present between the grippers.

Back Home