FIRST Robotics Simulator

Linear OpMode

runOpMode()
Description
You can put any blocks inside the runOpMode block. Every blocks inside will get executed sequentially to control the robot behaviour
Parameters
Simulator – the name of the project
Return
No return value

opModeIsActive()
Description
Check whether the robot is active
Parameters
Simulator - the name of the project
Return
Boolean
True if robot is active.
False is robot is inactive.

Sleep()
Description
sleep() causes the calling thread to sleep either until the number of real-time milliseconds specified in seconds have elapsed
Parameters
Math number - the time that you want to wait (in milliseconds)
Return
No return value

Actuators

setPower()
Description
Set power to the motor. This only works in the default mode RUN_USING_ENCODER
Parameters
Motor - the motor to set power to.
Math Number - the power value.
Return
No return value

setDirection()
Description
Sets the direction of the motor.
Parameters
Motor - the motor to set direction for.
Direction - The direction of the motor, FORWARD or REVERSE.
Return
No return value

setTargetPosition()
Description
Set the target number of 'ticks' for the motor. This only works in RUN_TO_POSITION mode
Parameters
Motor - the motor to set target position for.
Math number - Set the number of ticks, 1 revolution is equal to 1440 ticks.
Return
No return value

setMode()
Description
Set the motor to a specific mode.
Parameters
Motor - the motor to set mode on.
RunMode the mode to set the motor to.
RUN_USING_ENCODER - Default mode. Use this to set the power to a motor.
RUN_TO_POSITION - Use this to set the target position for a motor.
STOP_AND_RESET_ENCODER - This resets the number of ticks the motor has turned to 0.
Return
No return value

isBusy()
Description
Checks if the motor is running.
Parameters
Motor - The motor that is checked
Return
Boolean
True if the motor is running
False if the motor is not running.

Sensors

getColorRed()
Description
Gets the Red RGB value from the color sensor. In this case, color1 is the color sensor.
Parameters
Color Sensor
Property of the color sensor
Return
Returns the Red RGB value from the color sensor, a value between 0 to 1
returns 0 when the sensor detects no Red returns 1 when the sensor detects 100% Red

getColorGreen()
Description
Gets the Green RGB value from the color sensor. In this case, color1 is the color sensor.
Parameters
Color Sensor
Property of the color sensor
Return
Returns the Green RGB value from the color sensor, a value between 0 to 1
returns 0 when the sensor detects no Green returns 1 when the sensor detects 100% Green

getColorBlue()
Description
Gets the Blue RGB value from the color sensor. In this case, color1 is the color sensor.
Parameters
Color Sensor
Property of the color sensor
Return
Returns the Blue RGB value from the color sensor, a value between 0 to 1
returns 0 when the sensor detects no Blue returns 1 when the sensor detects 100% Blue

getDistance()
Description
Uses an infrared sensor to detect the distance between any object and the sensor.
Parameters
Sensor - The distance sensor to get the data from. In example picture above, this is labelled as 'distance'.
Property - The function to call on the distance sensor. In this case we're calling getDistance.
Distance Unit - Set the unit measurement of the value returned.
Return
Number - The distance between the sensor and the first object it reaches. Unit is dependent on parameters provided.

Utilities

RGBToColor()
Description
The rgbToColor method is a method within the class 'Color', and is called to convert the the RGB vlaues provided by the sensors to HSV values.
Parameters
Red - The Red RGB value of the color sensor.
Green - The Green RGB value of the color sensor.
Blue - The Blue RGB value of the color sensor.
Return
Returns an object that holds the HSV values.

getPropertyNumber()
Description
calls the getHue, getSaturation, and getValue methods from the class Color. Requires a 'HSV Object' as an input parameter
Parameters
HSV Object that has HSV values stored.
Return
Returns the hue, saturation or value of HSV object.