public class Arm
extends edu.wpi.first.wpilibj.command.Subsystem
Initial class creation, motor and sensors with ability to set states
, version 2: 2/2/2016 -- Derek WitcpalekAdded methods to check whether the states have been reached and to stop the motors Also added documentation
, version 3: 2/9/2016 -- Derek WitcpalekAdded documentation and classes to return angles based on sensor input
, version 4: 2/10/2016 -- Derek WitcpalekAdded adjustments for the bend in the arms
, version 5: 2/13/2016 -- Derek WitcpalekTested arm code: the arm was reaching setpoints, but there were issues with it reaching outside of the frame perimeter, and with the angles read by the potentiometer changing from test to test. The issue with the potentiometers still requires more testing, and the frame perimeter issue also needs a solution. I see two options: coordinating the outputs between the two joints or adding more setpoints that are essentially "transition" setpoints that the arm would move to between target positions.
, version 6: 2/14/2016 -- Derek WitcpalekAdded in coordination of control between the two joints of the arm so that the arm will be less likely to reach outside of the frame. Additionally, there is now the option to control the arm either manually or with setpoints. When controlling the arm manually, there is now code to make sure that it doesn't go outside of the extension limit. These new things still need to be tested.
, version 7: 2/16/2016 -- Derek WitcpalekRemoved deprecated methods
, version 8: 2/17/2016 -- Derek WitcpalekRenamed things better -- motor names are now shoulder and elbow motor and the PID controllers also follow this naming model
Modifier and Type | Class and Description |
---|---|
static class |
Arm.ControlStyle
These are the types of control for the arm.
|
Modifier and Type | Field and Description |
---|---|
private Arm.ControlStyle |
m_ControlStyle |
private ArmSetpoints.ArmState |
m_currentState |
private PIDController |
m_ElbowController |
private edu.wpi.first.wpilibj.CANTalon |
m_ElbowJoint |
(package private) edu.wpi.first.wpilibj.AnalogPotentiometer |
m_ElbowSensor |
private double |
m_lowerArmZeroAngle |
private double |
m_MaxManualExtension |
private PIDController |
m_ShoulderController |
private edu.wpi.first.wpilibj.CANTalon |
m_ShoulderJoint |
(package private) edu.wpi.first.wpilibj.AnalogPotentiometer |
m_ShoulderSensor |
private double |
m_upperArmZeroAngle |
Constructor and Description |
---|
Arm(Arm.ControlStyle style)
Creator
|
Arm(Arm.ControlStyle style,
double[] pidConstant)
Creator
|
Arm(Arm.ControlStyle style,
double p,
double i,
double d)
Creator
|
Modifier and Type | Method and Description |
---|---|
ArmSetpoints.ArmState |
getArmStateTarget()
Use this to tell where the arm is trying to get to
|
double |
getFirstJointPosition()
Get the average of the two first joint sensors
|
double |
getSecondJointPosition()
Get the average of the two second joint sensors
|
protected void |
initDefaultCommand() |
boolean |
isAtTargetState(double tolerance)
This will tell you if the arm is within a specific tolerance of its target.
|
void |
set(double lowerJoint,
double upperJoint)
Sets the motors to a specific output when you are using manual control.
|
void |
setControlStyle(Arm.ControlStyle style)
Changes the arm's control style to the input style.
|
void |
setPIDConstants(double p,
double i,
double d)
This can be used when testing to change the pid constants
|
void |
setState(ArmSetpoints.ArmState Target)
Set the target state for the arm
|
void |
stopArm()
Sends an output of zero to all of the arm motors
|
private final double m_lowerArmZeroAngle
private final double m_upperArmZeroAngle
private final double m_MaxManualExtension
private Arm.ControlStyle m_ControlStyle
private edu.wpi.first.wpilibj.CANTalon m_ShoulderJoint
private edu.wpi.first.wpilibj.CANTalon m_ElbowJoint
private PIDController m_ShoulderController
private PIDController m_ElbowController
edu.wpi.first.wpilibj.AnalogPotentiometer m_ShoulderSensor
edu.wpi.first.wpilibj.AnalogPotentiometer m_ElbowSensor
private ArmSetpoints.ArmState m_currentState
public Arm(Arm.ControlStyle style, double[] pidConstant)
style
- this is a control style: manual or setpoint-controlledpidConstant
- this is an array of the pid constants for the arm controllers.
It is in the form: {p-constant, i-constant, d-constant}public Arm(Arm.ControlStyle style)
style
- this is a control style: manual or setpoint-controlledpublic Arm(Arm.ControlStyle style, double p, double i, double d)
style
- this is a control style: manual or setpoint-controlledp
- proportional constanti
- integral constantd
- derivative constantpublic void setControlStyle(Arm.ControlStyle style)
style
- This is the method you want to use to control the armpublic void setPIDConstants(double p, double i, double d)
p
- proportionali
- integrald
- derivativepublic ArmSetpoints.ArmState getArmStateTarget()
public void setState(ArmSetpoints.ArmState Target)
Target
- this is the state that you want the arm to go toprotected void initDefaultCommand()
initDefaultCommand
in class edu.wpi.first.wpilibj.command.Subsystem
public void stopArm()
public boolean isAtTargetState(double tolerance)
tolerance
- ???public double getFirstJointPosition()
public double getSecondJointPosition()
public void set(double lowerJoint, double upperJoint)
lowerJoint
- ??upperJoint
- ??