Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Perfect driving using encoders? (http://www.chiefdelphi.com/forums/showthread.php?t=93748)

siggy2xc 18-03-2011 21:40

Perfect driving using encoders?
 
What would be the best way to make your robot drive perfectly straight using encoders while still being able to drive it with a joystick?

Jimmy the Kidd 18-03-2011 22:17

Re: Perfect driving using encoders?
 
By encoders, are you referring to encoders on, say, Supershifters? You could set a gain running on the encoder voltage, use the joystick value, and somehow compare the two, possibly using a coerce, to keep it within a certain range.

biojae 19-03-2011 01:13

Re: Perfect driving using encoders?
 
You could interpret the joystick as a velocity command (rate).

If you are using one joystick (arcade) your code could look something like this:
(Sorry, I don't have labview on my computer)
Code:

double driveCmd = Joystick1.getY(); // Convert the Y axis value into a velocity relative to the robot's maximum speed
double turnCmd  = Joystick1.getX() * MaxTurnRate; //Convert the X axis value into a turning velocity relative to the robot's maximum rotation speed

double turnRate = (leftEncoder.getRate() - rightEncoder.getRate()) / robotWidth; // Based on Kinematics of a differential (tank) driven vehicle
double turn = P * (turnCmd - turnRate); //Proportional control; Expand to PID if needed

RobotDrive.arcadeDrive(driveCmd, turn);

The only change needed for driving it with 2 joysticks (tank drive) is:
Code:

double driveCmd = (Joystick1.getY() + Joystick2.getY()) / 2.0; // Average the 2 sticks to get an overall Speed for the robot to drive 
double turnCmd  = ((Joystick1.getY() - Joystick2.getY()) / 2.0) * MaxTurnRate; // Convert the difference of the 2 sticks to get a turn velocity command



All times are GMT -5. The time now is 09:26.

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