Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Driving Straight (http://www.chiefdelphi.com/forums/showthread.php?t=152963)

YairZiv 04-01-2017 15:21

Driving Straight
 
Hey, so as we get close to the season, there's one thing we wanna understand how to do. We wanna understand how to drive straight using autonomous period. Using a PIDController for distance will not work since the two sides of the chassis may drive in a different speed. Using a PIDController for speed might work a little better though it will be hard to land in the distance we tried to go to. So how do we go into doing something like that?

Good luck in the season everybody!

Poseidon5817 04-01-2017 15:28

Re: Driving Straight
 
Quote:

Originally Posted by YairZiv (Post 1625061)
Hey, so as we get close to the season, there's one thing we wanna understand how to do. We wanna understand how to drive straight using autonomous period. Using a PIDController for distance will not work since the two sides of the chassis may drive in a different speed. Using a PIDController for speed might work a little better though it will be hard to land in the distance we tried to go to. So how do we go into doing something like that?

Good luck in the season everybody!

If you have a gyro, you can run a PID on the angle so that if it turns one way or the other, it will increase/decrease the outputs on the sides to help it turn back.

AustinShalit 04-01-2017 15:28

Re: Driving Straight
 
When WPILib 2017 is released, take a look at the gyro example. It is a sample program to demonstrate how to use a gyro sensor to make a robot drive straight. The program uses a joystick to drive forwards and backwards while the gyro is used for direction keeping. You can replace the joystick in the example with the output from a PIDController to drive straight for a certain distance.

You can get to the Gyro example by:
File -> New -> Other -> WPILib Robot Java Development -> Example Robot Java Project -> Gyro

BenBernard 04-01-2017 19:08

Re: Driving Straight
 
If you simply can't wait that long, feel free to look at our AutoDrive command, which locks onto the current heading (yaw) from our navX when it starts and uses PID to maintain that heading as it drives. The same approach could be used for any gyro.

mikets 04-01-2017 20:48

Re: Driving Straight
 
Quote:

Originally Posted by YairZiv (Post 1625061)
Hey, so as we get close to the season, there's one thing we wanna understand how to do. We wanna understand how to drive straight using autonomous period. Using a PIDController for distance will not work since the two sides of the chassis may drive in a different speed. Using a PIDController for speed might work a little better though it will be hard to land in the distance we tried to go to. So how do we go into doing something like that?

Good luck in the season everybody!

You can also look at our library in which you will find a PidDrive class that provides a method named "setTarget". It allows you to set the target distances in X or the Y direction. It also let you specified the "heading" you want to maintain relative to current heading. Don't worry about it being a FTC project. Our library is shared between FTC and FRC, so the TrcLib portion of the library is platform independent. So it would be identical code between FTC and FRC.
https://github.com/trc492/FtcSamples...cPidDrive.java


All times are GMT -5. The time now is 15:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi