View Single Post
  #3   Spotlight this post!  
Unread 01-03-2015, 21:26
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,609
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: JAVA code to drive straight using H-drive

The usual way to ensure you're driving straight is to put encoders on your wheel gearboxes, and get both sides going at the same speed. As long as the wheels don't slip, you can make this work by creating a PID on each axle based on speed, and set the target speed from your joysticks rather than the voltage. If you have time to do this, this is the better solution.

However, you probably don't have time, and you already have a gyroscope. During teleop, you're probably better off letting the driver compensate, unless you really do have a "directly forward" control (which means, among other things, not arcade or tank controls). If you do have a "directly forward", do the same as for autonomous below.

Autonomous: First, calibrate the gyroscope to determine the value received when the robot is not rotating. Then, as you're driving forward (or reverse), periodically check the rotation rate. If you are rotating to the left, decrease the right voltage a bit (or increase the left). Likewise, if you are rotating right, decrease the left voltage speed a bit. As you drive, continue the decrease/increase until the rotation rate is the desired value of zero.

As noted above, a gyroscope won't pinpoint you in an exact spot, but it may get you close enough so that you can use other sensors (rangefinders, touch sensors, etc) to get exactly where you want to be.

BTW, we've lost three analog KoP gyroscopes in the past year, two during this year's build season. If you can't get things working with the gyroscope, try checking it with a voltmeter or reading the values from it directly to verify that the hardware is still working.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 01-03-2015 at 21:29.
Reply With Quote