Gyro Programming

FIRST Robotics Programming, WPLIB

Page 1 of 1

0 Replies - 1245 Views - Last Post: 01 December 2009 - 05:51 PM Rate Topic: -----

#1 BettyRebecca  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-December 09

Gyro Programming

Posted 01 December 2009 - 05:51 PM

Hi, how are you?

This is my first time working with a gyro sensor, and I was asked to make the robot go straight and to realign itself with that straight path in case it is set off-course. I will not post the entire code for it is too long and has a lot of things outside of the gyro code, so I will paste only the gyro-related parts.



Gyro*gyro;	 // Setting a variable for the Gyro
MyRobotDrive *myRobot; // Setting myRobot variable as the drive system

gyro = new Gyro (1);   // Assigning the gyro as Analog Port 1
myRobot = new MyRobotDrive (1, 4, 0.5);  //myRobot will use the motors in ports 1 and 4

/****** In Autonomous********/

gyro->Reset();	  // Resetting the gyro
gyro->SetSensitivity(.005)   //Setting its sensitivity in volts per second

float angle = gyro->GetAngle();   //Gyro gets its heading

myRobot-> Drive (-1.0, -angle/30);  //Supposed to go forward and correct itself
Wait (4.0);								   //Do that for 4 seconds
 
myRobot->Drive (0.0, 0.0);		 //Stop
Wait (1.0);


When the code was tested on the Robot, not only did it not go straight, but it made a crazy spin. Later, i changed the
myRobot-> Drive (-1.0, -angle/30);  
part to
  myRobot-> Drive (-1.0, -angle);  
and the robot did go straight, but did not correct itself after its path was changed.

I know for a fact that the drive system itself is working fine and that the gyro is wired correctly. So, programming must be to blame, and I do not have any experience with gyros, so I do not know how to go about programming them.

I am using Wind River Workbench.

Any help would be appreciated! Thank you!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1