![]() |
Gyro not sending values?
Hello =) This is our first year using C++ and the WPI Library as opposed to LabView, and it's been a bit rough getting on our feet. Our current issue is that of the gyro. Modelling off of the example code included, as well as just reading the documentation, you can see what I tried. It seems as if it should work, but it hasn't. In order to test if I am even getting values I created an autonomous that should run the intake motor according to the values the gyro gives. The wiring is correct (to the extent of my knowledge) with the PWM plugged into the "gyro" plug on the gyro (not temp), with the signal cable facing outwards (I've flipped it both ways to see if it makes a difference; it hasn't), and plugged into the 2nd slot of the analog breakout (which is in module 1 of the cRIO).
In short, the gyro just doesn't seem to be working, and during the autonomous I created to test it, nothing happens. The wiring seems to be correct, and I was wondering if it could be code? [code below] Code:
#include "WPILib.h" |
Re: Gyro not sending values?
One thing you might try is to put the robot in Test mode from the DriverStation and verify that you are getting expected values for the gyro. It should show you the headings it is returning as you grab the robot and rotate it. Verify that the gyro sensitivity parameter is correct - if you look at the Gyro.h header file there is a parameter for this. The default is kDefaultVoltsPerDegreePerSecond = 0.007. Make sure that this matches the gyro that you are using.
Unrelated to the gyro problem, to make the driving easier, you might consider using the RobotDrive object instead of having separate speed controllers. The RobotDrive object in WPILib takes 2 or 4 drive speed controllers and supplies a number of methods to operate on them. It was designed to do exactly what you want to do. While the code shown below is completely untested and it's possible that some of the parameters are not quite right, you can look at the samples and get the idea from this. So you can replace this code: Code:
Jaguar frontRight; // robot drive systemCode:
RobotDrive drive;Code:
frontRight(1), // these must be initialized in the same orderCode:
drive(1, 2, 3, 4),Code:
void motorDrive(float speed)//Positive is forward; Negative is backwardsCode:
void motorDrive(float speed) {Code:
drive.Arcade(driveStick); // it automatically does the arcade driving stuffCode:
void gyroDrive(float speed, float time) {If you look here: http://wpilib.screenstepslive.com/s/...-robot-project it shows some of these concepts. Hope this helps. Brad |
Re: Gyro not sending values?
Thank you for the reply! I've found the problem, and it seemed that the gyro wasn't grounded well enough -_- And in regards to RobotDrive, it was what we first attempted. Our front motors are reversed in the front, so it was giving us some trouble at first before we tried inversing, and even after we inversed their values (SetInvertedMotor) we were having odd control issues. I figured it'd be more handy and easy in the end to declare them separately =)
If its alright to ask another question, I've been using a Logitech Dual Action joystick, and for the life of me I can't figure out how to get values to be modified by the 2nd (right) stick. I thought maybe defining it in the constructor as 0, 1, or 2 would work, but it hasn't :/ Thanks again! Jacque |
Re: Gyro not sending values?
Quote:
|
Re: Gyro not sending values?
This seems like a common enough question that there is this new page in the documentation for you...
http://wpilib.screenstepslive.com/s/...botdrive-class Brad |
Re: Gyro not sending values?
Sorry to derail, but I had a question about the Gyro GetAngle function.
We want to incorporate the gyro that comes attached with the ADXL345 accelerometer in a Complementary filter which kinda looks like Code:
angle = 0.98(angle + GyroAngularRateOfChange * dt) + 0.02(asin(Acceleration)) |
Re: Gyro not sending values?
Quote:
|
| All times are GMT -5. The time now is 18:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi