View unanswered posts | View active topics It is currently Wed Nov 13, 2019 11:25 pm






Reply to topic  [ 2 posts ] 
FTC Gyro help 
Author Message
Rookie

Joined: Sun Nov 09, 2014 4:17 pm
Posts: 1
Post 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
Profile
Rookie
User avatar

Joined: Wed Jan 09, 2013 11:48 pm
Posts: 46
Location: Saint Paul, MN
Post 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:
<Life>
   Fun
</Life>


Thu Nov 13, 2014 1:49 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.