-
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.
Festive Potatoes and I got the Octoquad working (#72)
* OctoQuad based odo. Wholly untested. * Added the ability to flip between OctoQuad and Encoder ports * Refactored into an IEncoder interface. Nothing is tested on hardware. * Cleaned up the 20403 drivebase a little * Adjusted the 4 test paths to see if the odo & drivebase are working * Final minor tidying * Tested on the Bot
- Loading branch information
Showing
11 changed files
with
134 additions
and
100 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
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
8 changes: 8 additions & 0 deletions
8
Twenty403/src/main/java/org/firstinspires/ftc/twenty403/helpers/IEncoder.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,8 @@ | ||
package org.firstinspires.ftc.twenty403.helpers; | ||
|
||
// A simple interface to wrap up an Encoder interface | ||
public interface IEncoder { | ||
void setDirection(boolean reversed); | ||
int getPosition(); | ||
double getVelocity(); | ||
} |
28 changes: 28 additions & 0 deletions
28
Twenty403/src/main/java/org/firstinspires/ftc/twenty403/helpers/MotorEncoderPort.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,28 @@ | ||
package org.firstinspires.ftc.twenty403.helpers; | ||
|
||
import com.technototes.library.hardware.sensor.encoder.MotorEncoder; | ||
import com.technototes.library.hardware.sensor.encoder.MotorEncoder.Direction; | ||
|
||
public class MotorEncoderPort implements IEncoder { | ||
|
||
protected MotorEncoder motorPort; | ||
|
||
public MotorEncoderPort(MotorEncoder motor) { | ||
motorPort = motor; | ||
} | ||
|
||
@Override | ||
public void setDirection(boolean reversed) { | ||
motorPort.setDirection(reversed ? Direction.REVERSE : Direction.FORWARD); | ||
} | ||
|
||
@Override | ||
public int getPosition() { | ||
return motorPort.getCurrentPosition(); | ||
} | ||
|
||
@Override | ||
public double getVelocity() { | ||
return motorPort.getCorrectedVelocity(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Twenty403/src/main/java/org/firstinspires/ftc/twenty403/helpers/OctoquadEncoder.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,33 @@ | ||
package org.firstinspires.ftc.twenty403.helpers; | ||
|
||
import com.qualcomm.hardware.digitalchickenlabs.OctoQuad; | ||
import com.qualcomm.hardware.digitalchickenlabs.OctoQuadBase.EncoderDirection; | ||
|
||
public class OctoquadEncoder implements IEncoder { | ||
|
||
protected OctoQuad octoQuad; | ||
protected int portNumber; | ||
|
||
public OctoquadEncoder(OctoQuad o, int port) { | ||
octoQuad = o; | ||
portNumber = port; | ||
} | ||
|
||
@Override | ||
public void setDirection(boolean reversed) { | ||
octoQuad.setSingleEncoderDirection( | ||
portNumber, | ||
reversed ? EncoderDirection.REVERSE : EncoderDirection.FORWARD | ||
); | ||
} | ||
|
||
@Override | ||
public int getPosition() { | ||
return octoQuad.readSinglePosition(portNumber); | ||
} | ||
|
||
@Override | ||
public double getVelocity() { | ||
return octoQuad.readSingleVelocity(portNumber); | ||
} | ||
} |
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
Oops, something went wrong.