In the previous entry, I shared some of the features of the VEX IQ robots. Also discussed were some ideas on how to get a classroom organized. Now that we have those things established, we can move on to a discussion of how to begin programming the VEX IQ robots.
ROBOTC for VEX IQ has Natural Language commands that will help beginning programmers of the VEX IQ by supplying a set of commands that use “natural” words. For example, the “forward” command will make your robot move forwards for a specified amount of time or distance. The robot will come to a stop after the movement. Here are some examples of the command:
Move the robot forward for 2.5 rotations:
Move the robot forward to 180 degrees:
• forward(180, degrees);
Move the robot forward for 1.5 rotations at 30% speed:
• forward(1.5, rotations, 30);
Move the robot forward for 10 seconds:
• forward(10, seconds);
• forward(10000, milliseconds);
Natural Language also contains other helpful commands; such as, “backward”, “turnLeft”, “turnRight”, and “repeat”. Below is an example of a Natural Language sample program that is located within the Natural Language sample program folder in ROBOTC:
VEX IQ Natural Language – Port Names and Numbers
leftMotor – Port #1
rightMotor – Port #6
armMotor – Port #10
clawMotor – Port #11
touchLEDSensor – Port #3
gyroSensor – Port #4
distanceSensor – Port #7
bumperSensor – Port #8
colorSensor – Port #9
//Configure the Natural Language to use the VEX IQ Clawbot
//Move the robot forward for 1.5 rotations (rotations are the default unit) at 50% speed (default speed)
//Turn the robot right for 1.25 rotations at 50% speed (default speed)
//Move the robot backwards for 720 degrees at 25% speed.
backward(720, degrees, 25);
//Turn the robot left for 2.5 rotations at 50% speed (default speed)
As you can see, there are a couple things that we have to do in order to use the Natural Language functionality. To enable Natural Language, go to “Robot Menu -> Platform Type -> Natural Language”.
The easiest way to get started programming is to open a sample program or to use a template. To open a sample program in ROBOTC, go to File Menu -> Open Sample Program.
To use a Natural Language template in ROBOTC, go to File Menu -> New… -> Natural Language Template.
To make programming easier, Natural Language makes assumptions about the type of robot you are using. To configure your Natural Language program to use our VEX IQ Clawbot, use the following line of code:
More robot models will be supported in future releases.
Finally, you will notice in the sample program that port names and numbers are given specific names and ports. Make sure that your VEX IQ Clawbot’s motors and sensors are configured this way in order to work with the Natural Language commands.
Ok. We are ready to go with programming! What should we do? My suggestion would be to start with the Labyrinth Challenge.
The Labyrinth challenge gives the students an opportunity to engage with the VEX IQ robots and ROBOTC. The students are immediately engaged because they can see and test their robot’s movement as it makes its way through the course. Since this may be the first program that some students write, there are a couple of things worth remembering. First, makes sure the students create a flowchart before they begin programming. For more information on flowcharts, you can look here: VEX Teacher – Engineering.
Second, it is important that the students describe what is going on in their programs with comments. For more information on how to utilize comments, please see here: http://www.robotc.net/vex_full/reference/hp_comment.pdf
Now you are ready to go! Good luck and have fun! Remember, if you have any questions as you are working, please visit the ROBOTC forums.
– Jason McKenna