View unanswered posts | View active topics It is currently Fri May 29, 2020 1:50 pm

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
FTC Gyro help
Author Message
Rookie

Joined: Sun Nov 09, 2014 4:17 pm
Posts: 1
FTC Gyro help
Our team wants to use a gyro for precision on turns. I somewhat understand the functionality of this sensor, and I found sample code that proved useful on NXT motors, due to the nSyncedMotors=synchBC;

I know that that is specific to NXT, but is there a replacement of sorts for tetrix motors? Are there any other ways to program gyros? Thanks!

Sun Nov 09, 2014 4:24 pm
Rookie

Joined: Wed Jan 09, 2013 11:48 pm
Posts: 46
Location: Saint Paul, MN
Re: FTC Gyro help
The gyro returns a velocity of degrees per second. My program gets four readings a second, and add .25*speed to a variable storing the total degrees turned. Then just have your motors run until that variable is equal to or greater than the angle you want. It was very accurate for me. Here's my code that I've used:

 Code:void trackTurning(int angle, int distance){   bool turning = true;   float totalAngle = 0;   ClearTimer(T2);   while(turning){      if(time1(T2) >= 250){         totalAngle += HTGYROreadRot(Gyro) * .250;         ClearTimer(T2);      }      if(totalAngle >= angle && abs(nMotorEncoder(Right1)) > distance && abs(nMotorEncoder(Left1)) > distance) break;   }}

Keep in mind that you should still use SensorValue normally, I'm connected to a SMUX. So track turning will break when the encoders are at the right position and the angle is correct

_________________
Head Programmer FTC Team 6699, Tempest

 Code:   Fun

Thu Nov 13, 2014 1:49 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning