![]() |
Drive train PID control
Hello, my team this is looking at solutions for driving more accurately in autonomous. At this moment we are using this to drive a certain distance in autonomous.
Code:
if (encoderDistanceReading >= distance) {Our team is currently using the iterative robot template. The drive train is a four motored tank drive with 8 inch pneumatic tires. I have one encoder setup on the left small output shaft. We have a second encoder coming soon. |
Re: Drive train PID control
The easiest way I can think to do this, is to initialize the motors separately without using the robotDrive class, as from the documentation, I can't find a way to integrate it with PID.
What kind of encoder are you using? continuous analog or digital quadrature? |
Re: Drive train PID control
Quote:
|
Re: Drive train PID control
Be very careful with those encoders. My team has never successfully used these encoders in competition without hilariously disastrous consequences. Make sure you thoroughly test these in the shop and do plenty of research on how to mount them.
now, as to how to implement it. I did a little more research and found that you can infact use the robot drive class. Code:
Encoder leftEncoder = new Encoder(1,2);Code:
leftEncoder.setPIDSourceType(kDisplacement); |
Re: Drive train PID control
Quote:
|
Re: Drive train PID control
It depends on what you're trying to keep track of in auto. If you're concerned only with distance, then one would work, but you would have to make sure all motors follow it. If you're using PWM, my team found it easiest to just splice the PWM cable into 2 end points so it can connect 2 Jags to 1 PWM output. This saves from having to set up sync/follower sets in code. ((obviously you would still need at least 2 PWM, one for each side))
if you're concerned about turning, (like when going over rough terrain) you may wish to use a gyro as well, as encoders will only track wheel spin, and not robot distance |
Re: Drive train PID control
Quote:
Just starting adding some of the code but I am having difficulty with the leftControl. The error I am getting is: "The field RobotDrive.m_frontLeftMotor is not visible" Code:
RobotDrive tankDrive = new RobotDrive(0, 1);RobotDrive(int leftMotorChannel, int rightMotorChannel) Constructor for RobotDrive with 2 motors specified with channel numbers. RobotDrive(int frontLeftMotor, int rearLeftMotor, int frontRightMotor, int rearRightMotor) Constructor for RobotDrive with 4 motors specified with channel numbers. RobotDrive(SpeedController leftMotor, SpeedController rightMotor) Constructor for RobotDrive with 2 motors specified as SpeedController objects. RobotDrive(SpeedController frontLeftMotor, SpeedController rearLeftMotor, SpeedController frontRightMotor, SpeedController rearRightMotor) http://first.wpi.edu/FRC/roborio/rel...obotDrive.html |
Re: Drive train PID control
That is a possibility, which you can fairly easily use if you split the PWM signal cable to both left drive jags. That way, you have one PWM signal, (one jag from the program's point of view) controlled by one PID/encoder.
Now, the gyro will help in keeping straight, but it will not help in going a set distance. for that, you would use an ultra sonic, (or similar range finder) my team is trying to use vision to determine distance, but there is a myrid of other ways to do this. If your plan may involve drive slippage, PID distance control wont much help. now, you might be able to combine that with an accelerometer, and a gyro to use PID after you get across the obstacle. That is, what for the accelerometer to say you are relatively level, use the gyro to straighten out, then use encoders to go forward a distance. IDK how well this will work in conjunction, since there is a lot of variability depending on your drive system. |
Re: Drive train PID control
Sorry, after thought, it may be easier to just use basic the Jaguar class if you continue having issues with robotDrive. You'll have to set up your tank drive yourself, but it is as easy as linking a joystick to the jag's set function.
|
Re: Drive train PID control
Quote:
Code:
RobotDrive tankDrive = new RobotDrive(SpeedController leftMotor, SpeedController rightMotor) |
Re: Drive train PID control
1 Attachment(s)
Quote:
Our pid loop took a lot of time to tune, and we used mecanum drive, so please be aware of that. Hope this helps |
Re: Drive train PID control
More or less yes. So you're using talons. PWM I assume? if so, the following code should be enough to set up your drive.
using only basic classes: Code:
Talon leftDrive=new Talon(1); |
Re: Drive train PID control
Quote:
This is what I thought of doing to have it work for arcade drive I have the PID setup stuff added on I just took it out for this. Code:
public class Robot extends IterativeRobot { |
Re: Drive train PID control
yes, just switch out the teleop init and periodic with the following.
Code:
RobotDrive drive; |
Re: Drive train PID control
Quote:
Code:
public class Robot extends IterativeRobot { |
| All times are GMT -5. The time now is 12:55. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi