ROBOTC.net Blog  

ROBOTC News

Archive for October, 2011

Programming the VEX Gyro in ROBOTC

with one comment

The new VEX Yaw Rate Gyro is one of the more sophisticated sensors in the VEX Robotics System – but it’s also one of the most useful and powerful. Among other things, the Gyro allows your robot to make very precise, consistent turns.

Other sensors, like the Shaft Encoders, allow you to control your robot’s turns… but indirectly. The Shaft Encoders can measure the rotation of the axles (or shafts) of your robot’s drive train. By monitoring how much the axles spin, you can also monitor and control how much your robot moves forward or turns. (As a side note, some great tutorials on using the Shaft Encoders to do just that can be found in the Movement section of the VEX Cortex Video Trainer.)

The Gyro, on the other hand, actually measures the rotation of your robot. Factors such as wheel slippage and varying surface friction that cause inconsistencies with Shaft Encoder-based turns are far less problematic with the Gyro; your robot will turn until it reaches the target you set – no matter how much the wheels slip or how long it takes!

There are a number of different ways that electronic Gyros work. The VEX Gyro includes a sensing element kept in continuous oscillation which reacts when angular rate is applied, based on the “Coriolis effect”. The Coriolis effect is a deflection of moving objects when they are viewed in a rotating reference frame. In a reference frame with clockwise rotation, the deflection is to the left of the motion of the object; in one with counter-clockwise rotation, the deflection is to the right. This effect is caused by the rotation of the Earth and the inertia of the mass experiencing the effect.

Thus, the Gyro is able to detect whether the robot is turning clockwise or counter-clockwise and provide different sensor values based on how much it’s been rotated. For a more thorough explanation of the Coriolis effect, visit this Wikipedia article. For more technical information on the on the internals of the VEX Gyro, you can check out its datasheet.For this tutorial, we mounted the VEX Gyro on our Swervebot robot model and connected it to Analog port 8 on the Cortex.

ROBOTC includes a number of sample programs for the Gyro. You can open the sample program below by going to File > Open Sample Program > Gyroscope > “Gyro Based Turns – Basic.c”.

A few additional notes about the Gyro and the program:
  • Typically all sensors are configured in ROBOTC using the Motors and Sensors Setup window. This can still be done with the Gyro, but lines 23-28 do so manually. The Gyro is an extremely sensitive sensor – it’s readings are affected by heat, fluctuations in voltage, and how long the sensor has been in use. These factors cause the sensor to accumulate an error, or drift, over time. By setting Analog Port 8 to “sensorNone” on line 24, all of the drift is wiped out from previous runs. The sensor is then reconfigured as a “sensorGyro” on line 27.
  • After the Gyro is configured on line 27, it’s very important that your robot is kept completely still for at least 1.1 seconds. During this time, ROBOTC and the Gyro perform a calibration process. The 2-second wait on line 28 is more than enough time for this process to occur.
  • There is a small amount of variance between each Gyro. ROBOTC has default values used for scaling the readings from the VEX Gyro into useful SensorValues, but you may need to make a slight adjustment for your sensor. The “SensorScale[]” command (commented out on line 31) allows you to do just that. If you find that your robot is turning too far or too little, un-comment line 31 and adjust the “260″ value as needed.
  • As the Gyro is turned, the values it returns are in tenths of degrees, positive and negative. Thus, a SensorValue of 3600 equals 360 degrees, or one full rotation. When the sensor is mounted horizontally, counter-clockwise movements will return values from 0 to -3600; clockwise movements will return values from 0 to 3600. Once the gyro completes one full revolution, the sensor value will “roll-over” to 0 by default (for example: …3597, 3598, 3599, 3600, 0, 1, 2, 3,…). To change the “roll-over” point, un-comment line 33 and change the value of “SensorFullCount” from 3600 to the desired value (7200, 18000, ect)
  • For a much more thorough explanation of the program, check out the tutorial video we produced, here.
#pragma config(Motor, port2, rightMotor, tmotorNormal, openLoop)
 #pragma config(Motor, port3, leftMotor, tmotorNormal, openLoop, reversed)
 //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++
 Gyro Based Turns - Basic
 -This program instructs your robot to turn for the specified number of degrees in "degrees10".
 -For best sensor results, clear out the gyro and manually configure it at the begging of the code.
 -The Gyro is configured by default to provide values from 0 to -3600 for clockwise rotation,
 and 0 to 3600 for counter-clockwise rotation

Robot Model(s): Swervebot

[I/O Port] [Name] [Type] [Description]
 Motor Port 2 rightMotor VEX Motor Right side motor
 Motor Port 3 leftMotor VEX Motor Left side motor
 Analog Port 8 in8 VEX Gyro Top-center mounted,
 away from the Cortex
 --------------------------------------------------------------------------------------------------*/

task main()
 {
 //Completely clear out any previous sensor readings by setting the port to "sensorNone"
 SensorType[in8] = sensorNone;
 wait1Msec(1000);
 //Reconfigure Analog Port 8 as a Gyro sensor and allow time for ROBOTC to calibrate it
 SensorType[in8] = sensorGyro;
 wait1Msec(2000);

//Adjust SensorScale to correct the scaling for your gyro
 //SensorScale[in8] = 260;
 //Adjust SensorFullCount to set the "rollover" point. 3600 sets the rollover point to +/-3600
 //SensorFullCount[in8] = 3600;

//Specify the number of degrees for the robot to turn (1 degree = 10, or 900 = 90 degrees)
 int degrees10 = 900;

//While the absolute value of the gyro is less than the desired rotation...
 while(abs(SensorValue[in8]) < degrees10)
 {
 //...continue turning
 motor[rightMotor] = 25;
 motor[leftMotor] = -25;
 }

//Brief brake to stop some drift
 motor[rightMotor] = -5;
 motor[leftMotor] = 5;
 wait1Msec(250);
 }

Here’s a video of the robot moving, based on the code:

And again, just in case you missed it, a more detailed explanation of the program can be found in this tutorial video:

The VEX Gyro can be purchased from the RoboMatter store.

Written by Jesse Flot

October 13th, 2011 at 5:08 pm

Posted in Cortex,General News,VEX

Tagged with , , ,

Great tutorial on setting up ROBOTC for ’11-’12 FTC season

with 5 comments

Pattonville High School’s Green Army Robotics team has put together a really nice tutorial on how to set up ROBOTC for the 2011-2012 FTC season.

Click here to go to their tutorial:

Setting up ROBOTC for the 2011-2012 FTC Season

Big Thanks to Green Army Robotics for putting so much effort in helping the community!

Written by Vu Nguyen

October 13th, 2011 at 12:55 pm

Posted in FTC,NXT

New Materials added to the VEX Cortex Video Trainer!

with one comment

Exciting news! We’ve updated the VEX Cortex Video Trainer with two new sections.

First, we’ve added a section for ROBOTC’s new Natural Language Library. You’ll find tons of print materials, ranging from guides describing each Natural Language command available for the VEX PIC and Cortex to dedicated helper guides for each of the VEX Sensors. You can find the new page in the VEX Cortex Video Trainer by going to the Fundamentals section and choosing Natural Language.

Second, there are 4 new tutorial videos that show how to use the Ultrasonic Rangefinder, complete with helper guides and programming challenges. You can find them by going to Sensing and choosing Forward until Near.

The VEX Cortex Video Trainer is available for free, online. To purchase a copy that you can install on each computer in your classroom, visit the RoboMatter store.

Written by Jesse Flot

October 12th, 2011 at 2:59 pm

ROBOTC 3.04 is now available!

without comments

Hi all,

We’ve just released ROBOTC 3.04. Head on over to the download pages to download the latest version!

Change log:

  1. Fixed silent updater bug
  2. Modified sensor scale and full count settings for gyros for VEX PIC.
  3. Eliminated deprecated warning for “#pragma platform”. Remove warning on “#pragma competition”
  4. dited BuiltInVariables.txt to include Battery & Power Control category, including 3 new entries for VEX battery level.
  5. Added intrinsic to ROBOTCIntrinsics to return BackupBatterLevel value.
  6. Corrected BuiltInVariables.txt to prevent displayLCDPos from appearing in “Undefined Entries”
  7. Updated BuiltInVariables.txt to reflect additions to VEX Display commands
  8. Modified RobotCIntrinsics.c setLCDPos command to “setLCDPosition”
  9. Merge fixes from 32Bit branch for >160 subroutines.
  10. Rebuild VEX firmware files because they were out of date.
  11. Change text for button on VEX remote screen from “Enter” to “Center”.
  12. Support on Prolific cables for workaround to protocol errors for IFI defined special Cortex messages. Previously was only implemented on integrated USB-to-Serial.
  13. Correct incorrect code generation for a parameter “call by reference” variable which is itself a “call by reference” variable.
  14. Add new intrinsics for VEX LCD to specify line and char position of the “Put”. Add alias “setLCDPos” for “displayLCDPos”
  15. Bump version to 9.04 / 3.04. Rebuild firmware.
  16. Eliminate NXT EXE encrypted file headers. It causes a bug with >160 subroutines on NXT. Need to rebuild NXT firmware to support this change.
  17. When return statement from a “non void” function is unreachable because function contains an infinite loop compiler used to generate an error message that “No return statement from non-void function”. Now it generates a warning that an infinite loop prevents return.
  18. Timer values on VEX (and NXT) were incorrectly truncated to 16-bits instead of preserving the 32-bit value.
  19. Incorrect code generation for assignments when the expression is a compound expression and it uses an intrinsic function that refers to the ‘l-value” of the assignment.
  20. Fixed Licensing System but when deactivating any product but ROBOTC for Mindstorms and it was the only product in the list.
  21. Hid two options in the “NXT Brick” menu to prevent crashing when in RVW mode
  22. Fixed an issue where the “Toggle Comment” button may crash ROBOTC when used near the beginning and end of a file.
  23. Fixed an issue where the “View” menu on the NXT was displaying incorrect data with the NXT Encoders.
  24. You can now drag/drop files to the ROBOTC application and also associate .c and .h files with ROBOTC.

Written by Vu Nguyen

October 10th, 2011 at 4:05 pm

Robot Virtual World Discount Code (expires 10/31/11)

without comments

You can get $30 off Robot Virtual World Single User licenses if you use the following Discount Code during checkout:

Discount Code:

RVWFALL11

Use the following links to add the desired ROBOTC version to your cart:

Annual Single User License for Robot Virtual Worlds – Mindstorms – $19 (was $49)

Annual Single User License for Robot Virtual Worlds – Cortex – $19 (was $49)


Annual Single User License for ROBOTC for Mindstorms and Robot Virtual Worlds – Mindstorms
– $59 (was $89)

Annual Single User License for ROBOTC for Cortex/PIC and Robot Virtual Worlds – Cortex – $59 (was $89)

Where do I type in the Discount Code?

When you click on any of the links above, you will be taken to  your Cart. Type in RVWFALL11 as shown below:

If you click Update, you will see the discount applied to your cart.

Written by Vu Nguyen

October 7th, 2011 at 11:35 am

Posted in General News,NXT,VEX

Lego George the Giant Robot

with 3 comments

[Thank you burf2000 from our forums for contributing this project!]

LEGO George the Giant Robot

LEGO George the Giant Robot

I present to you…

LEGO George the Giant Robot!

He moves, he dances, he can grab things… What CAN’T HE DO!?

This latest creation from burf2000 stands 5’7″ tall, and is a fully functional 5 foot 7″ robot.

He is controlled via a PlayStation 2 controller, he can move about, rotate his upper body, move his arms / shoulders and grab on to items. His head also rotates, moves up and down and if you get too close, his eyes will rotate.

Video of LEGO George:

I asked burf2000 some questions about his robot:

What inspired you to build this robot?

“I have always loved robotics and so Lego for me was a medium to build it in, I built another large robot last year but was not so successful. That one was based off T1 from Terminator 3. I wanted to keep things simple on this one due to size. It weights around 20KG. I also loved the Short-circuit films (johnny 5).”

How long did it take to make?

“This one took around 3 months of the odd evenings and days, We just had a baby (my wife) so getting time has been quite hard. However my wife is very supportive and knew I needed to build this for a show. (http://www.greatwesternlegoshow.com/).”

What are your future plans with the robot?

“Glad you asked this, currently I am improving certain parts of this which I am not happy with like shoulder joints, main bearing and turning. Once they are done, I am going to build a second robot to keep him company. Its going to be another large one, using more NXT’s and hopefully will go round on his own. My aim is to get a whole display of large robots moving around and interacting with each other.”

I thank you, burf2000, for submitting LEGO George. We can’t wait to see his successor!

More Photos

LEGO George's neckClose up

The whole photo set can be found on burf2000′s Flickr page

Written by Vu Nguyen

October 6th, 2011 at 1:04 pm

Posted in Cool projects,NXT

How to set up ROBOTC to use Third Party Sensors

without comments

We found a great video that a user made on Youtube (username: JosGJosG) that talks about Third Party Sensors.

JosGJosG takes you through starting up ROBOTC and going through the Preference settings in order to enable the ability to use Third Party sensors.

Description of the video (from youtube):

When ROBOTC is downloaded, it is initially set up to recognise only LEGO sensors. A set-up change has to be made to allow ROBOTC to recognise third party sensors, (HiTechnic, MindSensors, Firgelli, etc.). This video shows how to make that change, and also briefly mentions the difference in set-up between the full ROBOTC, and the simplified Natural Language ROBOTC. This video is one of a series of free video tutorials that introduce students to LEGO MindStorms NXT-G and to the use of Third Party Sensors; you can see them at www.DrGraeme.net.
Enjoy!

The Video:

Written by Vu Nguyen

October 6th, 2011 at 11:18 am

Posted in NXT