This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
e6f3122
commit bc328e3
Showing
8 changed files
with
91 additions
and
30 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/java/edu/bearbots/BearLib/drivebase/Drivebase.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,60 @@ | ||
package edu.bearbots.BearLib.drivebase; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.REVLibError; | ||
import com.revrobotics.CANSparkMax.IdleMode; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Abstract class to handle common drivebase motor controller functions. | ||
*/ | ||
public abstract class Drivebase { | ||
// for all drive bases? don't implement motors | ||
// odometry | ||
// driving | ||
// move to | ||
|
||
/** | ||
* Sets the current limit for Spark Max motor controllers, given a free limit | ||
* and a stall limit (in amps) as well as any number of Spark Maxes. | ||
* | ||
* @param freeLimit The free limit (in amps) | ||
* @param stallLimit The stall limit (in amps) | ||
* @param motor The Spark Maxes | ||
* @return An array of errors, if any | ||
*/ | ||
public REVLibError[] setCurrentLimit(int freeLimit, int stallLimit, CANSparkMax... motor) { | ||
REVLibError[] errors = new REVLibError[motor.length]; | ||
int i = 0; | ||
|
||
for (CANSparkMax m : motor) { | ||
errors[i] = m.setSmartCurrentLimit(freeLimit, stallLimit); | ||
i++; | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
|
||
/** | ||
* Sets the idle mode for Spark Max motor controllers, given an idle mode and | ||
* any number of Spark Maxes. | ||
* | ||
* @param mode The idle mode | ||
* @param motor The Spark Maxes | ||
* @return An array of errors, if any | ||
*/ | ||
public REVLibError[] setIdleMode(IdleMode mode, CANSparkMax... motor) { | ||
REVLibError[] errors = new REVLibError[motor.length]; | ||
int i = 0; | ||
|
||
for (CANSparkMax m : motor) { | ||
errors[i] = m.setIdleMode(mode); | ||
i++; | ||
} | ||
|
||
return errors; | ||
} | ||
} | ||
// inclue |
4 changes: 4 additions & 0 deletions
4
src/main/java/edu/bearbots/BearLib/drivebase/MecanumDrivebase.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,4 @@ | ||
package edu.bearbots.BearLib.drivebase; | ||
|
||
public abstract class MecanumDrivebase extends Drivebase { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/edu/bearbots/BearLib/drivebase/SwerveDrivebase.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,4 @@ | ||
package edu.bearbots.BearLib.drivebase; | ||
|
||
public abstract class SwerveDrivebase extends Drivebase { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/edu/bearbots/BearLib/drivebase/TankDrivebase.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,4 @@ | ||
package edu.bearbots.BearLib.drivebase; | ||
|
||
public abstract class TankDrivebase extends Drivebase { | ||
} |
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
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
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
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