Package edu.wpi.first.wpilibj
Class NidecBrushless
- java.lang.Object
-
- edu.wpi.first.wpilibj.SendableBase
-
- edu.wpi.first.wpilibj.NidecBrushless
-
- All Implemented Interfaces:
MotorSafety
,PIDOutput
,Sendable
,SpeedController
,AutoCloseable
public class NidecBrushless extends SendableBase implements SpeedController, MotorSafety, Sendable
Nidec Brushless Motor.
-
-
Field Summary
-
Fields inherited from interface edu.wpi.first.wpilibj.MotorSafety
DEFAULT_SAFETY_EXPIRATION
-
-
Constructor Summary
Constructors Constructor Description NidecBrushless(int pwmChannel, int dioChannel)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
disable()
Disable the motor.void
enable()
Re-enable the motor after disable() has been called.double
get()
Get the recently set value of the PWM.int
getChannel()
Gets the channel number associated with the object.String
getDescription()
double
getExpiration()
Return the safety expiration time.boolean
getInverted()
Common interface for returning if a speed controller is in the inverted state or not.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.boolean
isAlive()
Check if the motor is currently alive or stopped due to a timeout.boolean
isSafetyEnabled()
Check if motor safety is enabled.void
pidWrite(double output)
Write out the PID value as seen in the PIDOutput base object.void
set(double speed)
Set the PWM value.void
setExpiration(double timeout)
Set the safety expiration time.void
setInverted(boolean isInverted)
Common interface for inverting direction of a speed controller.void
setSafetyEnabled(boolean enabled)
void
stopMotor()
Stop the motor.-
Methods inherited from class edu.wpi.first.wpilibj.SendableBase
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.wpilibj.Sendable
getName, getSubsystem, setName, setName, setSubsystem
-
-
-
-
Constructor Detail
-
NidecBrushless
public NidecBrushless(int pwmChannel, int dioChannel)
Constructor.- Parameters:
pwmChannel
- The PWM channel that the Nidec Brushless controller is attached to. 0-9 are on-board, 10-19 are on the MXP portdioChannel
- The DIO channel that the Nidec Brushless controller is attached to. 0-9 are on-board, 10-25 are on the MXP port
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classSendableBase
-
set
public void set(double speed)
Set the PWM value.The PWM value is set using a range of -1.0 to 1.0, appropriately scaling the value for the FPGA.
- Specified by:
set
in interfaceSpeedController
- Parameters:
speed
- The speed value between -1.0 and 1.0 to set.
-
get
public double get()
Get the recently set value of the PWM.- Specified by:
get
in interfaceSpeedController
- Returns:
- The most recently set value for the PWM between -1.0 and 1.0.
-
setInverted
public void setInverted(boolean isInverted)
Description copied from interface:SpeedController
Common interface for inverting direction of a speed controller.- Specified by:
setInverted
in interfaceSpeedController
- Parameters:
isInverted
- The state of inversion true is inverted.
-
getInverted
public boolean getInverted()
Description copied from interface:SpeedController
Common interface for returning if a speed controller is in the inverted state or not.- Specified by:
getInverted
in interfaceSpeedController
- Returns:
- isInverted The state of the inversion true is inverted.
-
pidWrite
public void pidWrite(double output)
Write out the PID value as seen in the PIDOutput base object.
-
setExpiration
public void setExpiration(double timeout)
Set the safety expiration time.- Specified by:
setExpiration
in interfaceMotorSafety
- Parameters:
timeout
- The timeout (in seconds) for this motor object
-
getExpiration
public double getExpiration()
Return the safety expiration time.- Specified by:
getExpiration
in interfaceMotorSafety
- Returns:
- The expiration time value.
-
isAlive
public boolean isAlive()
Check if the motor is currently alive or stopped due to a timeout.- Specified by:
isAlive
in interfaceMotorSafety
- Returns:
- a bool value that is true if the motor has NOT timed out and should still be running.
-
stopMotor
public void stopMotor()
Stop the motor. This is called by the MotorSafetyHelper object when it has a timeout for this PWM and needs to stop it from running. Calling set() will re-enable the motor.- Specified by:
stopMotor
in interfaceMotorSafety
- Specified by:
stopMotor
in interfaceSpeedController
-
isSafetyEnabled
public boolean isSafetyEnabled()
Check if motor safety is enabled.- Specified by:
isSafetyEnabled
in interfaceMotorSafety
- Returns:
- True if motor safety is enforced for this object
-
setSafetyEnabled
public void setSafetyEnabled(boolean enabled)
- Specified by:
setSafetyEnabled
in interfaceMotorSafety
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfaceMotorSafety
-
disable
public void disable()
Disable the motor. The enable() function must be called to re-enable the motor.- Specified by:
disable
in interfaceSpeedController
-
enable
public void enable()
Re-enable the motor after disable() has been called. The set() function must be called to set a new motor speed.
-
getChannel
public int getChannel()
Gets the channel number associated with the object.- Returns:
- The channel number.
-
initSendable
public void initSendable(SendableBuilder builder)
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-
-