-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from DeepBlueRobotics/fix-to-work-with-complia…
…nt-can-sims Fix to work with spec compliant CAN sims.
- Loading branch information
Showing
7 changed files
with
121 additions
and
49 deletions.
There are no files selected for viewing
Submodule WPIWebSockets
updated
7 files
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
29 changes: 29 additions & 0 deletions
29
...ontroller/src/main/java/org/team199/deepbluesim/mediators/AnalogInputEncoderMediator.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,29 @@ | ||
package org.team199.deepbluesim.mediators; | ||
|
||
import org.team199.wpiws.devices.AnalogInputSim; | ||
|
||
import com.cyberbotics.webots.controller.PositionSensor; | ||
|
||
public class AnalogInputEncoderMediator extends EncoderMediatorBase { | ||
|
||
public final AnalogInputSim device; | ||
|
||
public AnalogInputEncoderMediator(PositionSensor encoder, AnalogInputSim device, boolean isOnMotorShaft, boolean isAbsolute, double absoluteOffsetDeg, boolean isInverted, int countsPerRevolution, double gearing) { | ||
super(encoder, isOnMotorShaft, isAbsolute, absoluteOffsetDeg, isInverted, countsPerRevolution, gearing); | ||
this.device = device; | ||
} | ||
|
||
@Override | ||
public void setPosition(int positionCounts) { | ||
// 1 Volt = 1 Rotation. The robot code can use | ||
// SparkAnalogSensor.setPositionConversionFactor() to change what | ||
// SparkAnalogSensor.getPosition() returns. | ||
device.setVoltage(1.0 * positionCounts / countsPerRevolution); | ||
} | ||
|
||
@Override | ||
public void setVelocity(int velocityCountsPerSecond) { | ||
// AnalogInput data doesn't include velocity so we do nothing. | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
plugin/controller/src/main/java/org/team199/deepbluesim/mediators/CANEncoderMediator.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,26 @@ | ||
package org.team199.deepbluesim.mediators; | ||
|
||
import org.team199.wpiws.devices.CANEncoderSim; | ||
|
||
import com.cyberbotics.webots.controller.PositionSensor; | ||
|
||
public class CANEncoderMediator extends EncoderMediatorBase { | ||
|
||
public final CANEncoderSim device; | ||
|
||
public CANEncoderMediator(PositionSensor encoder, CANEncoderSim device, boolean isOnMotorShaft, boolean isAbsolute, double absoluteOffsetDeg, boolean isInverted, int countsPerRevolution, double gearing) { | ||
super(encoder, isOnMotorShaft, isAbsolute, absoluteOffsetDeg, isInverted, countsPerRevolution, gearing); | ||
this.device = device; | ||
} | ||
|
||
@Override | ||
public void setPosition(int positionCounts) { | ||
device.setPosition(1.0 * positionCounts / countsPerRevolution); | ||
} | ||
|
||
@Override | ||
public void setVelocity(int velocityCountsPerSecond) { | ||
device.setVelocity(1.0 * velocityCountsPerSecond / countsPerRevolution); | ||
} | ||
|
||
} |
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
27 changes: 27 additions & 0 deletions
27
plugin/controller/src/main/java/org/team199/deepbluesim/mediators/DutyCycleMediator.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,27 @@ | ||
package org.team199.deepbluesim.mediators; | ||
|
||
import org.team199.wpiws.devices.DutyCycleSim; | ||
|
||
import com.cyberbotics.webots.controller.PositionSensor; | ||
|
||
public class DutyCycleMediator extends EncoderMediatorBase { | ||
|
||
public final DutyCycleSim device; | ||
|
||
public DutyCycleMediator(PositionSensor encoder, DutyCycleSim device, boolean isOnMotorShaft, boolean isAbsolute, double absoluteOffsetDeg, boolean isInverted, int countsPerRevolution, double gearing) { | ||
super(encoder, isOnMotorShaft, isAbsolute, absoluteOffsetDeg, isInverted, countsPerRevolution, gearing); | ||
this.device = device; | ||
device.setConnected(true); | ||
} | ||
|
||
@Override | ||
public void setPosition(int positionCounts) { | ||
device.setPosition(1.0 * positionCounts / countsPerRevolution); | ||
} | ||
|
||
@Override | ||
public void setVelocity(int velocityCountsPerSecond) { | ||
// DutyCycle data doesn't include velocity so we do nothing. | ||
} | ||
|
||
} |
26 changes: 0 additions & 26 deletions
26
.../controller/src/main/java/org/team199/deepbluesim/mediators/SimDeviceEncoderMediator.java
This file was deleted.
Oops, something went wrong.