Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Adding rev ctre functions (#140)
Browse files Browse the repository at this point in the history
* Renaming files

* Adding some tests

* Fixing more issues
  • Loading branch information
pjreiniger authored Jan 12, 2020
1 parent 77c70ac commit 12ef0d4
Show file tree
Hide file tree
Showing 25 changed files with 952 additions and 431 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ if(hasProperty('maven_repo'))
throw new GradleException("This isn't supported anymore")
}

ext.maven_version = "2020-0.0.0"
ext.maven_version = "2020-0.0.1"
if(hasProperty('maven_version'))
{
ext.maven_version = maven_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -31,7 +33,7 @@ public void reset()

private CtreTalonSrxSpeedControllerSim getMotorControllerWrapper(int aCanPort)
{
return (CtreTalonSrxSpeedControllerSim) SensorActuatorRegistry.get().getSpeedControllers().get(aCanPort + 100);
return (CtreTalonSrxSpeedControllerSim) SensorActuatorRegistry.get().getSpeedControllers().get(aCanPort + CtreTalonSrxSpeedControllerSim.sCAN_SC_OFFSET);
}

private CtrePigeonImuSim getPigeonWrapper(int aCanPort)
Expand All @@ -45,6 +47,9 @@ public void handleMotorControllerMessage(String aCallback, int aCanPort, ByteBuf

sLOGGER.log(Level.TRACE, "Handling motor controller message " + aCallback + ", " + aCanPort);


Set<String> unsupportedFunctions = new HashSet<>();

if ("Create".equals(aCallback))
{
if (!DataAccessorFactory.getInstance().getSpeedControllerAccessor().getPortList()
Expand Down Expand Up @@ -136,6 +141,10 @@ else if ("Set_4".equals(aCallback))
break;
}
}
else if ("GetBaseID".equals(aCallback))
{
aData.putInt(aCanPort);
}
else if ("ConfigSelectedFeedbackSensor".equals(aCallback))
{
CtreTalonSrxSpeedControllerSim wrapper = getMotorControllerWrapper(aCanPort);
Expand Down Expand Up @@ -320,17 +329,9 @@ else if ("SetInverted_2".equals(aCallback))
///////////////////////////////////
// Unsupported, but not important
///////////////////////////////////
else if ("SetStatusFramePeriod".equals(aCallback))
{
sLOGGER.log(Level.DEBUG, "SetStatusFramePeriod not supported");
}
else if ("ConfigVelocityMeasurementPeriod".equals(aCallback))
{
sLOGGER.log(Level.DEBUG, "ConfigVelocityMeasurementPeriod not supported");
}
else if ("ConfigVelocityMeasurementWindow".equals(aCallback))
else if (unsupportedFunctions.contains(aCallback))
{
sLOGGER.log(Level.DEBUG, "ConfigVelocityMeasurementWindow not supported");
sLOGGER.log(Level.DEBUG, aCallback + " not supported");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ public void setCurrentProfile(byte aProfileSelect)
mCurrentPidProfile = aProfileSelect;
}


@Override
protected void registerFeedbackSensor()
{
Expand Down Expand Up @@ -228,4 +227,28 @@ public int getBinnedVelocity()
{
return (int) (getVelocity() * this.getVelocityUnitConversion());
}

public void setCanFeedbackDevice(byte aFeedbackDevice)
{
FeedbackDevice newDevice = null;
switch (aFeedbackDevice)
{
// Default feedback sensor, handle with care
case 0:
newDevice = FeedbackDevice.Encoder;
break;
case 2:
newDevice = FeedbackDevice.Analog;
break;
// The Absolute and Relative encoders behave the same
case 8:
newDevice = FeedbackDevice.Encoder;
break;
default:
sLOGGER.log(Level.WARN, "Unsupported feedback device " + aFeedbackDevice);
break;
}

setCanFeedbackDevice(newDevice);
}
}
Loading

0 comments on commit 12ef0d4

Please sign in to comment.