Follow-the steps below to get a sample Robot Controller App in your code.org account.
Go to code.org and click on 'Sign In' (top right). Then, choose Continue with Google and use your school account to login.
Once you are signed in to code.org, click here for the Sample Robot Controller App. You will then click on View Code (NOT 'Make my Own').
Click on the Remix button to copy the sample app into your own account. (When you have done this - the name of the app will be Remix: Robot Controller V3. Feel free to rename it if you wish. This is now your own copy of the app to use and modify.)
You now need to change the username and usercode to the values Mr. Hogg has given you. (Make sure to keep the double quotes around these values when you change them!) You now have a robot controller app in your code.org account. You can use the Test Robot screen for basic testing. You will then need to create your own controller screen on the controlrobot screen.
Once you have completed the above steps, you SHOULD be able to control the robot during mission challenges! NOW you can modify the app to better control the app and give you greater control.
Using the Sample Robot App you will need to create a good robot controller. You can modify the screen with id controlrobot to create your controller.
Note that the runRobotCommand runs the instruction(s) you set in the variable robotCommand. The next section below describes all the possible instructions. Note that you can provide multiple instructions at once by separating the instructions with commas.
Example
robotCommand = "FWD-255-1000,TURNR-150-2000";
runRobotCommand();
|
This example is calling the runRobotCommand with two instructions. The first instruction FWD-255-1000 says to go forward at full speed (255) for 1 seconds (1000 ms). The second instruction (separated by comma) TURNR-150-2000 says to turn right at medium speed (150) for 2 seconds (2000 ms). |
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) |
Note that ZZZ below is a time (in ms)
Light Command | Description |
---|---|
LEDON | Lights ON |
LEDONL | Left Light ON |
LEDONR | Right Light ON |
LEDOFF | Lights OFF |
LEDOFFL | Left Light OFF |
LEDOFFR | Right Light OFF |
LEDBLINK-ZZZ | Light Blink |
LEDBLINKL-ZZZ | Left Light Blink |
LEDBLINKR-ZZZ | Right Light Blink |
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 |
To be succesful at a mission, you want to move your robot as quickly as possible. However, more commands more quickly means you are 'driving blind' and may end up causing your robot to get stuck or fall off a 'cliff'. To make things worse, you may find your robot a bit unreliable. A given command may not result in the robot moving exactly the same each time. This problem is called repeatability and reliability.
The following table summarizes some of the reasons why your robot may not respond as expected. Can you think of more? Can you think of ways of changing how you control your robot so it completes a mission efficiently, but not fail due to these issues?
Problem Uneven surface | Description The uneven surface may cause a given command to not behave completely as expected. This is particularly a problem with the sharp turn commands (TURNL, TURNR) as they are more sensitive to the amount of friction on the rover wheels. |
Problem Robot Hardware | Description Your job on these missions is to develop software (app) and use that software to control your robot. Of course, a robot includes BOTH hardware and software. If you are driving the robot from home, you have no way to fix hardware issues or even the design of the robot and you must rely on the engineers whose job was robot design (or in this case - on Mr. Hogg). Note that this is exactly what happens for space missions where often an error in design or manufacturing must be cleverly handled (not fixed) through software |
Problem Network Issues | Description Just like NASA Engineers driving real robots on Mars, you may encounter issues with network connectivity. You are ACTUALLY driving robots over the internet, so its possible a command may get lost or your network may go down. Note that while this is possible - it is definitely NOT the most likely reason for issues. Network issues happen, but generally networks are fairly reliable. Note that the various networks used to control your robot include your own internet (if working from home), the code.org servers, the robot controller server, the school network, and then bluetooth connections to the individual robots. Lots of tech means lots of ways for problems to show up! |
Useful Links