Package ftclib.motor
Class FtcServo
java.lang.Object
trclib.motor.TrcServo
ftclib.motor.FtcServo
- All Implemented Interfaces:
TrcExclusiveSubsystem
This class implements a platform dependent servo extending TrcServo. It provides implementation of the abstract
methods in TrcServo.
-
Nested Class Summary
Nested classes/interfaces inherited from class trclib.motor.TrcServo
TrcServo.Params
Nested classes/interfaces inherited from interface trclib.robotcore.TrcExclusiveSubsystem
TrcExclusiveSubsystem.OwnershipParams
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.qualcomm.robotcore.hardware.ServoController
private final com.qualcomm.robotcore.hardware.Servo
private final TrcTimer
Fields inherited from class trclib.motor.TrcServo
servoSetPosElapsedTimer, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFtcServo
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, TrcServo.Params params) Constructor: Creates an instance of the object.Constructor: Creates an instance of the object.FtcServo
(String instanceName, TrcServo.Params params) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
This method cancels the holdTimer and stops the state machine if it is running.com.qualcomm.robotcore.hardware.ServoController
This method returns the servo controller object that this servo is plugged into.double
This method returns the logical position of the servo.boolean
This method checks if the servo direction is inverted.private void
onTimeExpired
(Object context) This method is called when the onTime has expired.void
setControllerOn
(boolean on) The method enables/disables the servo controller.void
setInverted
(boolean inverted) This method inverts the servo direction.void
setLogicalPosition
(double position) This method sets the logical position of the servo.void
setPositionWithOnTime
(double pos, double onTime) This method sets the servo position but will cut power to the servo when done.Methods inherited from class trclib.motor.TrcServo
cancel, follow, getPosition, getPower, presetPositionDown, presetPositionUp, printElapsedTime, setElapsedTimerEnabled, setLogicalPosRange, setMaxStepRate, setPhysicalPosRange, setPosition, setPosition, setPosition, setPosition, setPosition, setPosition, setPosition, setPosition, setPosPresets, setPower, setPower, setPower, setPower, setPower, setPower, setPresetPosition, toLogicalPosition, toPhysicalPosition, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface trclib.robotcore.TrcExclusiveSubsystem
acquireExclusiveAccess, acquireOwnership, cancelExclusiveAccess, getCurrentOwner, hasOwnership, releaseExclusiveAccess, releaseOwnership, validateOwnership
-
Field Details
-
servo
private final com.qualcomm.robotcore.hardware.Servo servo -
controller
private final com.qualcomm.robotcore.hardware.ServoController controller -
timer
-
-
Constructor Details
-
FtcServo
public FtcServo(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, TrcServo.Params params) Constructor: Creates an instance of the object.- Parameters:
hardwareMap
- specifies the global hardware map.instanceName
- specifies the instance name.params
- specifies the parameters of the servo.
-
FtcServo
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.params
- specifies the parameters of the servo.
-
FtcServo
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
getController
public com.qualcomm.robotcore.hardware.ServoController getController()This method returns the servo controller object that this servo is plugged into.- Returns:
- servo controller object.
-
cancel
public void cancel()This method cancels the holdTimer and stops the state machine if it is running. -
setPositionWithOnTime
public void setPositionWithOnTime(double pos, double onTime) This method sets the servo position but will cut power to the servo when done. Since servo motors can't really take a lot of loads, it would stress out and may burn out the servo if it is held against a heavy load for extended period of time. This method allows us to set the position and only hold it long enough for it to reach target position and then we will cut the servo controller power off. Note that by doing so, all servos on the same controller will go limp.- Parameters:
pos
- specifies the target position.onTime
- specifies the time in seconds to wait before disabling servo controller.
-
onTimeExpired
This method is called when the onTime has expired. It disables the servo controller.- Parameters:
context
- specifies callback context (not used).
-
setControllerOn
public void setControllerOn(boolean on) The method enables/disables the servo controller. If the servo controller is disabled, all servos on the controller will go limp. This is useful for preventing the servos from burning up if it is held against a heavy load.- Parameters:
on
- specifies true to enable the servo controller, false otherwise.
-
setInverted
public void setInverted(boolean inverted) This method inverts the servo direction.- Specified by:
setInverted
in classTrcServo
- Parameters:
inverted
- specifies true to invert the servo direction, false otherwise.
-
isInverted
public boolean isInverted()This method checks if the servo direction is inverted.- Specified by:
isInverted
in classTrcServo
- Returns:
- true if the servo direction is inverted, false otherwise.
-
setLogicalPosition
public void setLogicalPosition(double position) This method sets the logical position of the servo.- Specified by:
setLogicalPosition
in classTrcServo
- Parameters:
position
- specifies the logical position of the servo in the range of [0.0, 1.0].
-
getLogicalPosition
public double getLogicalPosition()This method returns the logical position of the servo. In general, servo do not provide real time position feedback. Therefore, it will return the position set by the last setLogicalPosition call.- Specified by:
getLogicalPosition
in classTrcServo
- Returns:
- logical position of the servo in the range of [0.0, 1.0].
-