Robot API Robot Control Apps
Robot API
The Robot API allows Robot Controller Apps to be run from ANY coding environment that supports a third-party web call (http). Programming an App using Java, Javascript, Python, C++, and more are all possible. However, the simplest way to get started is to use Code.org to develop your Robot Controller App using the Code.org App Lab (Which uses Javascript and also offers a block programming environment.)
A Sample App can be imported into a free Code.org account to quickly get started.
Code.org and the Sample App
If you are using the Code.org and the Sample App, then a Robot Command (described below) means calling the built-in function defined in the App as runRobotCommand which will send the Robot Instructions defined in the variable robotCommand to the Robots.
For example, the following line in the Code.org Sample App will cause the robot to move forward full speed for 3 seconds:
robotCommand = "FWD-255-3000"
runRobotCommand()
Robot Instructions
The following table outlines the available Robot Instructions to be used to control the robot's motion.
Note that XXX below refers to SPEED and must be between 0 (stopped) and 255 (full speed). YYY is the time for the motor to be on (in milliseconds, so 1000 is 1 seconds)
Motor Command | Description |
---|---|
FWD-XXX-YYY | Go Foward |
BACK-XXX-YYY | Go Back |
TURNL-XXX-YYY | Turn Left |
TURNR-XXX-YYY | Turn Right |
TURNFWDL-XXX-YYY | Turn Left (While Moving Forward) |
TURNFWDR-XXX-YYY | Turn Right (While Moving Forward) |
Robot Commands
Participants are able to send one or more Robot Instructions with each Robot Command.
Depending on the Challenge Mode and Win Condition for a given challenge, it can be very advantageous to send multiple instructions in one command. For example, some challenges may be run where the winning team is the team that completes the challenge in the least number of commands (as opposed to the first who completes the challenge).
To send multiple Robot Instructions in one Robot Command, separate each instruction with a comma.
For example, the following Robot Command tells the Robot to perform a 'U-turn' by sending multiple instructions (5 in this case).
FWD-255-1000,TURNR-150-4000,FWD-255-1000,TURNR-150-4000,FWD-255-1000
Robot Instruction Calibration
Example | How far robot moves |
---|---|
FWD-255-1000 | 17 cm forward |
BACK-255-1000 | 17 cm backward |
TURNL-150-4000 | Turns in place about 90 degrees |
TURNR-150-4000 | Turns in place about 90 degrees |
TURNFWDL-200-500 | |
TURNFWDR-200-500 |