-
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.
Added (NYI) CRServo and MotorAsServo hardware devices
- Loading branch information
Showing
3 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
RobotLibrary/src/main/java/com/technototes/library/hardware/motor/CRServo.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,36 @@ | ||
package com.technototes.library.hardware.motor; | ||
|
||
import com.technototes.library.hardware.HardwareDevice; | ||
import java.io.InvalidClassException; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* This is for "continuous rotation" servos. They work, unfortunately, like motors | ||
* without encoders: You can set a power (from 0 to 1, typically, with .5 as "stop") and the | ||
* servo will spin in the direct, at the provided speed... | ||
* | ||
* Not Yet Implemented! | ||
* TODO: Implement this | ||
*/ | ||
public class CRServo extends HardwareDevice<com.qualcomm.robotcore.hardware.CRServo> implements Supplier<Double> { | ||
|
||
public CRServo(com.qualcomm.robotcore.hardware.CRServo device, String deviceName) throws InvalidClassException { | ||
super(device, deviceName); | ||
throw new InvalidClassException("com.technototes.library.hardware.motor.CRServo", "Not Yet Implemented"); | ||
} | ||
|
||
protected CRServo(String deviceName) throws InvalidClassException { | ||
super(deviceName); | ||
throw new InvalidClassException("com.technototes.library.hardware.motor.CRServo", "Not Yet Implemented"); | ||
} | ||
|
||
@Override | ||
public String LogLine() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Double get() { | ||
return null; | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
RobotLibrary/src/main/java/com/technototes/library/hardware/servo/MotorAsServo.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,56 @@ | ||
package com.technototes.library.hardware.servo; | ||
|
||
import com.qualcomm.robotcore.hardware.DcMotor; | ||
import com.qualcomm.robotcore.hardware.DcMotorEx; | ||
import com.technototes.library.hardware.HardwareDevice; | ||
import com.technototes.library.hardware.Sensored; | ||
import java.io.InvalidClassException; | ||
|
||
/** | ||
* This is to use a motor as a servo using the built-in capabilities (instead of doing it manually) | ||
* | ||
* One rather important feature would be to hand control back & forth between a normal encoded | ||
* motor. The alternative would be to extend EncodedMotor to just "do" this stuff automatically. | ||
* Honestly, that probably makes more sense, but requires some thought about state transitions. | ||
* | ||
* @param <T> | ||
* Not Yet Implemented! | ||
* TODO: Implement this | ||
* | ||
*/ | ||
public class MotorAsServo<T extends DcMotor> extends HardwareDevice<T> implements Sensored { | ||
|
||
public MotorAsServo(T device, String deviceName) throws InvalidClassException { | ||
super(device, deviceName); | ||
throw new InvalidClassException("com.technototes.library.hardware.servo.MotorAsServo", "Not Yet Implemented"); | ||
} | ||
|
||
protected MotorAsServo(String deviceName) throws InvalidClassException { | ||
super(deviceName); | ||
throw new InvalidClassException("com.technototes.library.hardware.servo.MotorAsServo", "Not Yet Implemented"); | ||
} | ||
|
||
/** | ||
* @return | ||
*/ | ||
@Override | ||
public String LogLine() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @return | ||
*/ | ||
@Override | ||
public double getSensorValue() { | ||
return 0; | ||
} | ||
|
||
/** | ||
* @return | ||
*/ | ||
@Override | ||
public double getAsDouble() { | ||
return getSensorValue(); | ||
} | ||
} |