Skip to content

Commit

Permalink
getUnwrapped method for everything allowing for cast calls to wrapper…
Browse files Browse the repository at this point in the history
…ed devices when necessary.
  • Loading branch information
Autumn-Ou committed Apr 30, 2023
1 parent 6a50cea commit f28fada
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
sourceCompatibility = '1.11'
targetCompatibility = '1.11'
group 'com.northeasternrobotics.wrappers'
version '0.1.1'
version '0.1.2'

java {
withSourcesJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ public abstract class AbstractSwerveAzmthEncoder {
*/
public abstract double getRawAngle_rad();

/**
* @return The unwrapped encoder object
*/
public abstract Object getUnwrappedEncoder();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public RealCANCoder(int can_id) {
cancoder.configAllSettings(config);
}

@Override
public Object getUnwrappedEncoder() {
return cancoder;
}

@Override
public double getRawAngle_rad() {
supplyVoltage = cancoder.getBusVoltage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public RealSRXEncoder(int port) {
m_dutyCycle = new DutyCycle(m_digitalInput);
}

@Override
public Object getUnwrappedEncoder() {
return m_digitalInput;
}

@Override
public double getRawAngle_rad() {
freq = m_dutyCycle.getFrequency(); //Track this for fault mode detection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public SimSwerveAzmthEncoder(int port) {
SimDeviceBanks.addDIDevice(this, port);
}

@Override
public Object getUnwrappedEncoder() {
return this;
}

/**
* Simulates the encoder updating
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public RealThriftyEncoder(int port) {
m_encoder = new AnalogEncoder(m_input);
}

@Override
public Object getUnwrappedEncoder() {
return m_encoder;
}

@Override
public double getRawAngle_rad() {
measVoltage = m_input.getVoltage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
public class WrapperedSwerveAzimuthEncoder {
AbstractSwerveAzmthEncoder enc;
double curAngleRad;
// TODO: Bring in oxconfig maybe?
double mountingOffset;

/**
Expand Down Expand Up @@ -47,6 +46,13 @@ public WrapperedSwerveAzimuthEncoder(SwerveAzmthEncType type, String prefix, int
this.mountingOffset = dfltMountingOffset_rad;
}

/**
* @return Motor controller object
*/
public Object getUnwrappedEncoder() {
return enc.getUnwrappedEncoder();
}

/**
* Updates the abstracted swerve azimuth encoder values
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public RealADXRS453() {
realGyro.calibrate();
}

@Override
public Object getUnwrappedGyro() {
return realGyro;
}

@Override
public void reset() {
realGyro.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
* Abstract class for a gyro.
*/
public abstract class AbstractGyro {
/**
* @return gyro object
*/
public abstract Object getUnwrappedGyro();
/**
* Resets the gyro to a heading of zero.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public RealNavx() {
this.calibrate();
}

@Override
public Object getUnwrappedGyro() {
return ahrs;
}

@Override
public void reset() {
ahrs.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public SimGyro() {
SimDeviceBanks.addSPIDevice(this, 0); // TODO are we actually on CS 0?
}

@Override
public Object getUnwrappedGyro() {
return this;
}

@Override
public void reset() {
rate = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public WrapperedGyro(GyroType type) {
}
}

/**
* @return gyro object
*/
public Object getUnwrappedGyro() {
return gyro.getUnwrappedGyro();
}

/**
* Updates the abstracted gyro values
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
* Abstract class for a Simulateable Motor Controller.
*/
public abstract class AbstractSimmableMotorController {
/**
* @return the wrapped motor controller object
*/
public abstract Object getUnwrappedMotor();

/**
* @param invert if set to true inverts the motors direction
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public RealTalonFX(int can_id) {
}
}

@Override
public Object getUnwrappedMotor() {
return _talon;
}

@Override
public void setInverted(boolean invert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public RealTalonSRX(int can_id) {
}
}

@Override
public Object getUnwrappedMotor() {
return _talon;
}

@Override
public void setInverted(boolean invert) {
_talon.setInverted(invert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public RealVenom(int can_id) {
_venom = new CANVenom(can_id);
}

@Override
public Object getUnwrappedMotor() {
return _venom;
}

@Override
public void setInverted(boolean invert) {
_venom.setInverted(invert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public RealSparkMax(int can_id) {

}

@Override
public Object getUnwrappedMotor() {
return m_motor;
}

@Override
public void setInverted(boolean invert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public SimSmartMotor(int can_id) {
SimDeviceBanks.addCANDevice(this, can_id);
}

@Override
public Object getUnwrappedMotor() {
return this;
}

@Override
public void setInverted(boolean invert) {
isInverted = invert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public WrapperedCANMotorCtrl(String prefix, int can_id, CANMotorCtrlType type) {

}

/**
* @return Motor controller object
*/
public Object getUnwrappedMotor() {
return ctrl.getUnwrappedMotor();
}

/**
* Updates the abstracted controllers values
*/
Expand Down

0 comments on commit f28fada

Please sign in to comment.