Log in

View Full Version : Gyros in place of potentiometers?/Gyro intergration with jaguars


wolfspell12
23-01-2014, 21:13
We are looking for a sensor to measure the angle of our boom on the robot suitable for PID control. The boom was not designed for potentiometers, so we were wondering if gyros are a suitable replacement?

Secondly we are using CAN jaguars and PID controls for the first time this year. We wanted to make sure that there was no potential conflict between a drive gyro, and a CAN Jaguar system with encoders. The two won't send conflicting signals to the Cartesian mecanum drive method in Java, will they?

Alan Anderson
24-01-2014, 00:09
What most people call a Gyro in the context of FRC robots is actually a yaw rate sensor. It measures how quickly it is rotating. It is not really suitable for measuring an absolute angle on a moving robot part. Depending on how precise you need to do the measurement, you might be able to use a two-axis accelerometer to compute the direction of gravity relative to the boom, though that will have dynamic errors whenever the robot itself is accelerating.

You don't need to mount a potentiometer (or other absolute angle sensor) directly to the rotating component. You can use a linkage from the component to a "follower" arm to copy the rotation of the boom to a piece that is designed for a pot.

gpetilli
24-01-2014, 13:10
Regarding the Jaguars -
Assuming that you intend to do PID wheel speed control inside the Jaguar (which is a fine distributed processing architecture), the Jaguar must be connected to the cRIO via CAN (not PWM) and the encoder is connected directly to the Jaguar.

I strongly recommend doing a CD search for old threads on PID and Jaguar for more info. Velocity loops are tuned differently than position loops in that the loop must integrate the encoder error to get the control velocity. The recommend method of tuning is to start with P=0, I=small, D=0 and increase I until just before speed is unstable. Then increase P to further improve stability.

As mentioned in post 2, the gyro outputs angular velocity and I don't believe it will interface directly with the Jaguar. The standard WPI mecanum code I believe does handle the gyro for you on the cRIO, but I have never used that code. The WPI code may also assume that the encoders are hooked to the cRIO and not the Jaguars - you will need to verify that first.

wolfspell12
25-01-2014, 16:28
Regarding the Jaguars -
Assuming that you intend to do PID wheel speed control inside the Jaguar (which is a fine distributed processing architecture), the Jaguar must be connected to the cRIO via CAN (not PWM) and the encoder is connected directly to the Jaguar.

I strongly recommend doing a CD search for old threads on PID and Jaguar for more info. Velocity loops are tuned differently than position loops in that the loop must integrate the encoder error to get the control velocity. The recommend method of tuning is to start with P=0, I=small, D=0 and increase I until just before speed is unstable. Then increase P to further improve stability.

As mentioned in post 2, the gyro outputs angular velocity and I don't believe it will interface directly with the Jaguar. The standard WPI mecanum code I believe does handle the gyro for you on the cRIO, but I have never used that code. The WPI code may also assume that the encoders are hooked to the cRIO and not the Jaguars - you will need to verify that first.

While this is becoming more of a programming question, I am a little concerned about the last thing you said. I did a little searching, but it wasn't much help. At least that verified that you could connect to the jaguars or the cRIO. I looked at the java docs, and some of the constructors use a DigitalSource object. I dont know if this object is an input on the cRIO or the jaguar. If its on the jaguar its no problem, if its on the cRIO then i need to know how to tell the robot that these are connected to the jaguars. Does someone know for certain if a digital source connects to the cRIO or jaguar? If it connects to the cRIO how do i tell the robot that it needs data from the jaguars?

gpetilli
25-01-2014, 18:57
While this is becoming more of a programming question, I am a little concerned about the last thing you said. I did a little searching, but it wasn't much help. At least that verified that you could connect to the jaguars or the cRIO. I looked at the java docs, and some of the constructors use a DigitalSource object. I dont know if this object is an input on the cRIO or the jaguar. If its on the jaguar its no problem, if its on the cRIO then i need to know how to tell the robot that these are connected to the jaguars. Does someone know for certain if a digital source connects to the cRIO or jaguar? If it connects to the cRIO how do i tell the robot that it needs data from the jaguars?

Im sorry, but you are at the edge of my knowledge. I think you need to create encoder and gyro objects and pass them to the mecanum drive code. You really need someone who has done this to direct you better.

DonRotolo
25-01-2014, 20:14
If you are comfortable with potentiometers:

Mount a pot to the arm, somewhere. Attach a weighted arm to the shaft, maybe 2-3 oz.. The arm will always point down (due to gravity) and send a voltage to indicate arm angle.

Easy-peasy.

wolfspell12
29-01-2014, 18:49
We decided forego the potentiometer and PID control for the boom. The Jag question may require a programming topic in the Java section, so I think we will go there next.