edu.nau.cs.scu
Class Servo
java.lang.Object
edu.nau.cs.scu.Servo
public class Servo
- extends java.lang.Object
This class represents a single axis of rotation for the gimbal. It contains all the
position information and analysis necessary for the servo, along with information about
soft and hard stops, the enabled/disabled status of the servo, and methods for inducing
motion.
- Author:
- Bernard Jzexoia Avery
Constructor Summary |
Servo()
This default constructor will load in default starting values for the servo. |
Servo(double posHardStop,
double negHardStop)
This constructor will initialize the servo with starting positions for positive and
negative hard stops. |
Method Summary |
void |
disable()
Disable the servo. |
void |
enable()
Enable the servo. |
boolean |
enabledStatus()
This method will return the current enabled/disabled status of the servo. |
double |
getNegativeSoftStop()
This method returns the negative soft stop of the servo. |
double |
getPosition()
Return the current angle of the servo, based on a calculation based on the rate of
motion, the position at the last move command, and the desired "goalAngle" if in
position mode. |
double |
getPositiveSoftStop()
This method returns the positive soft stop of the servo. |
double |
lowerBound()
This method will return the limit of motion in the negative direction currently
imposed on this servo. |
void |
setNegativeSoftStop(double s)
Set the value of the negative soft stop, measured in radians. |
void |
setPosition(double a)
This method will act as the "Position Mode" command would. |
void |
setPositiveSoftStop(double s)
Set the value of the positive soft stop, measured in radians |
void |
setRate(double a)
This command will simulate "Rate Mode" for one axis of rotation. |
void |
stop()
This method will stop the servo in its tracks. |
double |
upperBound()
This method will return the limit of motion in the positive direction currently
imposed on this servo. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Servo
public Servo()
- This default constructor will load in default starting values for the servo. It is
not recommended to use this constructor, it is recommended to use
Servo(double posSoftStop, double negSoftStop) instead.
Servo
public Servo(double posHardStop,
double negHardStop)
- This constructor will initialize the servo with starting positions for positive and
negative hard stops. The positive and negative soft stops will be set equal to the
hard stops when the servo is initialized.
- Parameters:
posHardStop
- The desired positive hard stop for this axisnegHardStop
-
getPositiveSoftStop
public double getPositiveSoftStop()
- This method returns the positive soft stop of the servo. this is distinct from
getUpperBound in that getUpperBound will return either a hard stop OR a soft stop,
depending on which one imposes the stricter limitation on movement.
- Returns:
- the positive soft stop for this axis of rotation.
getNegativeSoftStop
public double getNegativeSoftStop()
- This method returns the negative soft stop of the servo. this is distinct from
getLowerBound in that getLowerBound will return either a hard stop OR a soft stop,
depending on which one imposes the stricter limitation on movement.
- Returns:
- the negative soft stop for this axis of rotation.
stop
public void stop()
- This method will stop the servo in its tracks. This is called when the servo hits a
stop or is disabled.
upperBound
public double upperBound()
- This method will return the limit of motion in the positive direction currently
imposed on this servo. This may be a hard or a soft stop depending on whether the
positive soft stop has been set within the physical range of motion or outside of
that range.
- Returns:
- The largest positive angle the servo can move to.
lowerBound
public double lowerBound()
- This method will return the limit of motion in the negative direction currently
imposed on this servo. This may be a hard or a soft stop depending on whether the
positive soft stop has been set within the physical range of motion or outside of
that range.
- Returns:
- The largest negative angle the servo can move to.
setPosition
public void setPosition(double a)
- This method will act as the "Position Mode" command would. It will cause the servo
to move at its default rate from its current angle to a desired new angle, then
stop. If setPosition is issued with an angle greater than the current upperBound()
or lower than the current lowerBound(), the servo will move to its closest bound
instead.
- Parameters:
a
- The angle which the servo is being ordered to move to.
setRate
public void setRate(double a)
- This command will simulate "Rate Mode" for one axis of rotation. When this method is
called, the servo will begin moving at the specified rate.
- Parameters:
a
- The signed rate you wish the servo to move at.
getPosition
public double getPosition()
- Return the current angle of the servo, based on a calculation based on the rate of
motion, the position at the last move command, and the desired "goalAngle" if in
position mode. This method will also account for hard and soft stops. This method
will update the position before returning it, and so should be called by the program
at least 50 times per second for accurate results. This method is called by
getStatus() in PMCentralInterface so there is no need to individually call both
methods.
- Returns:
- The current angle of the servo in radians.
setPositiveSoftStop
public void setPositiveSoftStop(double s)
- Set the value of the positive soft stop, measured in radians
- Parameters:
s
- The new value for the positive soft stop, in radians.
setNegativeSoftStop
public void setNegativeSoftStop(double s)
- Set the value of the negative soft stop, measured in radians.
- Parameters:
s
- The new value for the negative soft stop, in radians.
enable
public void enable()
- Enable the servo. If the servo is disabled, no motion will be possible.
Calling this method will allow future motion to take place as usual. Note that
it will NOT restore any motion that was previously canceled by disable().
disable
public void disable()
- Disable the servo. If the servo is disabled, no motion will be possible.
Calling this method will stop the servo in its tracks at its current exact position.
Once this method has been called, no further motion will be possible until enable()
is called to cancel out this effect.
enabledStatus
public boolean enabledStatus()
- This method will return the current enabled/disabled status of the servo.
- Returns:
- True if the servo is enabled, false if it is disabled.