View Single Post
  #11   Spotlight this post!  
Unread 16-02-2014, 19:19
geomapguy's Avatar
geomapguy geomapguy is offline
Centenary '18
AKA: Graham Maxwell
FRC #1818
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Alexandria, LA
Posts: 535
geomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud ofgeomapguy has much to be proud of
Re: Gyro with Labview to drive straight

Quote:
Originally Posted by MrRoboSteve View Post
In our 2012 robot, we used a simple proportional control system to turn the robot on heading. It uses a higher power level to turn close to the desired heading, and then lowers the power to avoid overrunning the desired heading. We also had a tolerance around the desired heading of a couple degrees where we considered the robot to be on heading.

All of the constants here are values you will need to determine experimentally.

Initialize at start of turn:

start_heading = current gyro heading
goal_heading = desired heading (calculated from your desired turn and the start heading)

Each loop:

turn_rate = 0 (this ranges from -1 to 1 and is the desired power to drive train)
current_heading = current gyro heading
angle_difference = current_heading - goal_heading

// angle_difference here might be positive or negative, indicating a turn in either direction

If (abs(angle_difference) > 10) then
turn_rate = .7
// when the angle difference is > 10 degrees, turn at .7 power.
Else if (abs(angle_difference) > 3 and abs(angle_difference) < 10)
turn_rate = .6
// when you are within 10 degrees of desired heading, turn at lower
// power to prevent overrunning the desired heading
Else
// Consider heading within 3 degrees of desired heading to be on heading
turn_rate = 0
End

// Motor inputs

// Depending on your motor configuration and how the gyro is mounted, you may need to reverse the motor controls.

If (angle_difference > 0) then
turn_left(turn_rate)
Else
turn_right(turn rate)
end

Ended up using this method but adapted for LabVIEW....works great.

We did this since we aren't using encoders
__________________
The Cowboys - FIRST Robotics Team #1818 2015-
The Bolton Bear Bots - FIRST Robotics Team #3666 2011-204 (30-26-0)
2014 Oklahoma Regional - 20/62 (6-4-0), 5/62 in OPR
2014 Arkansas Regional - 14/39 (8-7-0, Quarterfinalists with 1706 and 1939), 24/39 in OPR
2013 Lone Star Regional Dean's List Finalist!
2013 Lone Star Regional - 22/57 (6-5-0), 17/57 in OPR
2012 Bayou Regional - 16/49 (6-5-0)
2011 Dallas Regional - 10/52 (4-2-5, #6 Alliance Captain, Quarterfinalists with 2948 and 3350)