-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bc6f91
commit 5d67c86
Showing
6 changed files
with
313 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/org/hyperonline/hyperlib/driving/CartesianDriveParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.hyperonline.hyperlib.driving; | ||
|
||
import edu.wpi.first.wpilibj.drive.DifferentialDrive; | ||
import edu.wpi.first.wpilibj.drive.MecanumDrive; | ||
|
||
/** | ||
* | ||
* @author Chris McGroarty | ||
* | ||
*/ | ||
public class CartesianDriveParams implements DriveParameters { | ||
|
||
private double m_ySpeed, m_xSpeed, m_zRotate, m_gyroAngle; | ||
|
||
/** | ||
* get the speed on the y-axis | ||
* | ||
* @return the y-axis speed | ||
*/ | ||
public double ySpeed() { | ||
return m_ySpeed; | ||
} | ||
|
||
/** | ||
* get the speed on the x-axis | ||
* | ||
* @return the x-axis speed | ||
*/ | ||
public double xSpeed() { | ||
return m_xSpeed; | ||
} | ||
|
||
/** | ||
* get the rotation from the z-axis | ||
* | ||
* @return the z-axis rotation | ||
*/ | ||
public double zRotate() { | ||
return m_zRotate; | ||
} | ||
|
||
/** | ||
* get the gyro angle | ||
* | ||
* @return the gyro angle | ||
*/ | ||
public double gyroAngle() { | ||
return m_gyroAngle; | ||
} | ||
|
||
/** | ||
* Construct a new {@link CartesianDriveParams}. | ||
* | ||
* @param ySpeed the speed to move in the y-axis | ||
* @param xSpeed the speed to move in the x-axis | ||
* @param zRotate the rotation to apply in the z-axis | ||
* @param gyroAngle the gyroAngle to use | ||
*/ | ||
public CartesianDriveParams(double ySpeed, double xSpeed, double zRotate, double gyroAngle) { | ||
m_ySpeed = ySpeed; | ||
m_xSpeed = xSpeed; | ||
m_zRotate = zRotate; | ||
m_gyroAngle = gyroAngle; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void drive(DifferentialDrive driveTrain, double currentGyro) throws WrongDriveTypeException { | ||
throw new WrongDriveTypeException("using Cartesian with DifferentialDrive"); | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void drive(MecanumDrive driveTrain, double currentGyro) { | ||
driveTrain.driveCartesian(m_ySpeed, m_xSpeed, m_zRotate, m_gyroAngle); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/org/hyperonline/hyperlib/driving/PolarDriveParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.hyperonline.hyperlib.driving; | ||
|
||
import edu.wpi.first.wpilibj.drive.DifferentialDrive; | ||
import edu.wpi.first.wpilibj.drive.MecanumDrive; | ||
|
||
/** | ||
* | ||
* @author Chris McGroarty | ||
* | ||
*/ | ||
public class PolarDriveParams implements DriveParameters { | ||
|
||
private double m_magnitude, m_angle, m_zRotation; | ||
|
||
/** | ||
* get the magnitude | ||
* | ||
* @return the magnitude | ||
*/ | ||
public double magnitude() { | ||
return m_magnitude; | ||
} | ||
|
||
/** | ||
* get the angle | ||
* | ||
* @return the angle | ||
*/ | ||
public double angle() { | ||
return m_angle; | ||
} | ||
|
||
/** | ||
* get the rotation | ||
* | ||
* @return the z-axis rotation | ||
*/ | ||
public double rotate() { | ||
return m_zRotation; | ||
} | ||
|
||
/** | ||
* Construct a new {@link PolarDriveParams}. | ||
* | ||
* @param magnitude the amount to move | ||
* @param angle the angle to move at | ||
* @param rotate the rotation to apply | ||
*/ | ||
public PolarDriveParams(double magnitude, double angle, double rotate) { | ||
m_magnitude = magnitude; | ||
m_angle = angle; | ||
m_zRotation = rotate; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void drive(DifferentialDrive driveTrain, double currentGyro) throws WrongDriveTypeException { | ||
throw new WrongDriveTypeException("using Polar with DifferentialDrive"); | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void drive(MecanumDrive driveTrain, double currentGyro) { | ||
driveTrain.drivePolar(m_magnitude, m_angle, m_zRotation); | ||
} | ||
|
||
} |
Oops, something went wrong.