mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Last feature addition for CANTalon java/C++ user-facing API.
- CANJaguar also touched up to report it can't do the new control mode (just like with follower). - New third optional param for talon c'tor to speed up enable control frame. - The pulse width routines have been moved to where the script generator puts them. No actual changes there but should help Peter integrate the latest code generator. Last feature additions for TalonSRX HAL for FRC2015-FRC-2016 season. -HAL driver uses control_5 frame if firmware supports it. This allows teams to see/confirm control settings taking effect before enabling the robot. For example selecting the sensor type and going to web-dash to check sensor values now works without having to enable the robot. -Motion profile HAL routines added. Tested on Single-Speed Double reduction (with slave Talon too). -Start moving ctre frame defs into a new common header (better then shoving a bunch of struct defs at top of module). -New child class in CANTalonSRX for buffering motion profile points. Not sure it would be best to leave it as is or make another module. It's trivial now so I thought that was acceptable, (in future it will likely possess compression strategies => no longer trivial). Change-Id: I803680c1a6669ca3f5157d7875942def6f75b540
This commit is contained in:
committed by
Peter Johnson
parent
ec69c6a866
commit
cd5765559a
@@ -6,6 +6,8 @@ import edu.wpi.first.wpilibj.communication.UsageReporting;
|
||||
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_double;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_int;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_uint32_t;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_int32_t;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_CTR_Code;
|
||||
import edu.wpi.first.wpilibj.tables.ITable;
|
||||
import edu.wpi.first.wpilibj.tables.ITableListener;
|
||||
@@ -31,7 +33,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
private final double kMinutesPer100msUnit = 1.0/600.0;
|
||||
|
||||
public enum TalonControlMode implements CANSpeedController.ControlMode {
|
||||
PercentVbus(0), Position(1), Speed(2), Current(3), Voltage(4), Follower(5), Disabled(15);
|
||||
PercentVbus(0), Position(1), Speed(2), Current(3), Voltage(4), Follower(5), MotionProfile(6), Disabled(15);
|
||||
|
||||
public final int value;
|
||||
|
||||
@@ -114,7 +116,173 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Enumerated types for Motion Control Set Values.
|
||||
* When in Motion Profile control mode, these constants are paseed
|
||||
* into set() to manipulate the motion profile executer.
|
||||
* When changing modes, be sure to read the value back using getMotionProfileStatus()
|
||||
* to ensure changes in output take effect before performing buffering actions.
|
||||
* Disable will signal Talon to put motor output into neutral drive.
|
||||
* Talon will stop processing motion profile points. This means the buffer is
|
||||
* effectively disconnected from the executer, allowing the robot to gracefully
|
||||
* clear and push new traj points. isUnderrun will get cleared.
|
||||
* The active trajectory is also cleared.
|
||||
* Enable will signal Talon to pop a trajectory point from it's buffer and process it.
|
||||
* If the active trajectory is empty, Talon will shift in the next point.
|
||||
* If the active traj is empty, and so is the buffer, the motor drive is neutral and
|
||||
* isUnderrun is set. When active traj times out, and buffer has at least one point,
|
||||
* Talon shifts in next one, and isUnderrun is cleared. When active traj times out,
|
||||
* and buffer is empty, Talon keeps processing active traj and sets IsUnderrun.
|
||||
* Hold will signal Talon keep processing the active trajectory indefinitely.
|
||||
* If the active traj is cleared, Talon will neutral motor drive. Otherwise
|
||||
* Talon will keep processing the active traj but it will not shift in
|
||||
* points from the buffer. This means the buffer is effectively disconnected
|
||||
* from the executer, allowing the robot to gracefully clear and push
|
||||
* new traj points.
|
||||
* isUnderrun is set if active traj is empty, otherwise it is cleared.
|
||||
* isLast signal is also cleared.
|
||||
*
|
||||
* Typical workflow:
|
||||
* set(Disable),
|
||||
* Confirm Disable takes effect,
|
||||
* clear buffer and push buffer points,
|
||||
* set(Enable) when enough points have been pushed to ensure no underruns,
|
||||
* wait for MP to finish or decide abort,
|
||||
* If MP finished gracefully set(Hold) to hold position servo and disconnect buffer,
|
||||
* If MP is being aborted set(Disable) to neutral the motor and disconnect buffer,
|
||||
* Confirm mode takes effect,
|
||||
* clear buffer and push buffer points, and rinse-repeat.
|
||||
*/
|
||||
public enum SetValueMotionProfile {
|
||||
Disable(0), Enable(1), Hold(2);
|
||||
public int value;
|
||||
|
||||
public static SetValueMotionProfile valueOf(int value) {
|
||||
for (SetValueMotionProfile mode : values()) {
|
||||
if (mode.value == value) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SetValueMotionProfile(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Motion Profile Trajectory Point
|
||||
* This is simply a data transer object.
|
||||
*/
|
||||
public static class TrajectoryPoint {
|
||||
public double position; //!< The position to servo to.
|
||||
public double velocity; //!< The velocity to feed-forward.
|
||||
/**
|
||||
* Time in milliseconds to process this point.
|
||||
* Value should be between 1ms and 255ms. If value is zero
|
||||
* then Talon will default to 1ms. If value exceeds 255ms API will cap it.
|
||||
*/
|
||||
public int timeDurMs;
|
||||
/**
|
||||
* Which slot to get PIDF gains.
|
||||
* PID is used for position servo.
|
||||
* F is used as the Kv constant for velocity feed-forward.
|
||||
* Typically this is hardcoded to the a particular slot, but you are free
|
||||
* gain schedule if need be.
|
||||
*/
|
||||
public int profileSlotSelect;
|
||||
/**
|
||||
* Set to true to only perform the velocity feed-forward and not perform
|
||||
* position servo. This is useful when learning how the position servo
|
||||
* changes the motor response. The same could be accomplish by clearing the
|
||||
* PID gains, however this is synchronous the streaming, and doesn't require restoing
|
||||
* gains when finished.
|
||||
*
|
||||
* Additionaly setting this basically gives you direct control of the motor output
|
||||
* since motor output = targetVelocity X Kv, where Kv is our Fgain.
|
||||
* This means you can also scheduling straight-throttle curves without relying on
|
||||
* a sensor.
|
||||
*/
|
||||
public boolean velocityOnly;
|
||||
/**
|
||||
* Set to true to signal Talon that this is the final point, so do not
|
||||
* attempt to pop another trajectory point from out of the Talon buffer.
|
||||
* Instead continue processing this way point. Typically the velocity
|
||||
* member variable should be zero so that the motor doesn't spin indefinitely.
|
||||
*/
|
||||
public boolean isLastPoint;
|
||||
/**
|
||||
* Set to true to signal Talon to zero the selected sensor.
|
||||
* When generating MPs, one simple method is to make the first target position zero,
|
||||
* and the final target position the target distance from the current position.
|
||||
* Then when you fire the MP, the current position gets set to zero.
|
||||
* If this is the intent, you can set zeroPos on the first trajectory point.
|
||||
*
|
||||
* Otherwise you can leave this false for all points, and offset the positions
|
||||
* of all trajectory points so they are correct.
|
||||
*/
|
||||
public boolean zeroPos;
|
||||
};
|
||||
/**
|
||||
* Motion Profile Status
|
||||
* This is simply a data transer object.
|
||||
*/
|
||||
public static class MotionProfileStatus {
|
||||
/**
|
||||
* The available empty slots in the trajectory buffer.
|
||||
*
|
||||
* The robot API holds a "top buffer" of trajectory points, so your applicaion
|
||||
* can dump several points at once. The API will then stream them into the Talon's
|
||||
* low-level buffer, allowing the Talon to act on them.
|
||||
*/
|
||||
public int topBufferRem;
|
||||
/**
|
||||
* The number of points in the top trajectory buffer.
|
||||
*/
|
||||
public int topBufferCnt;
|
||||
/**
|
||||
* The number of points in the low level Talon buffer.
|
||||
*/
|
||||
public int btmBufferCnt;
|
||||
/**
|
||||
* Set if isUnderrun ever gets set.
|
||||
* Only is cleared by clearMotionProfileHasUnderrun() to ensure
|
||||
* robot logic can react or instrument it.
|
||||
* @see clearMotionProfileHasUnderrun()
|
||||
*/
|
||||
public boolean hasUnderrun;
|
||||
/**
|
||||
* This is set if Talon needs to shift a point from its buffer into
|
||||
* the active trajectory point however the buffer is empty. This gets cleared
|
||||
* automatically when is resolved.
|
||||
*/
|
||||
public boolean isUnderrun;
|
||||
/**
|
||||
* True if the active trajectory point has not empty, false otherwise.
|
||||
* The members in activePoint are only valid if this signal is set.
|
||||
*/
|
||||
public boolean activePointValid;
|
||||
/**
|
||||
* The number of points in the low level Talon buffer.
|
||||
*/
|
||||
public TrajectoryPoint activePoint = new TrajectoryPoint();
|
||||
/**
|
||||
* The current output mode of the motion profile executer (disabled, enabled, or hold).
|
||||
* When changing the set() value in MP mode, it's important to check this signal to
|
||||
* confirm the change takes effect before interacting with the top buffer.
|
||||
*/
|
||||
public SetValueMotionProfile outputEnable;
|
||||
};
|
||||
/** preallocated for Motion Profile Status fetching. This is more efficient
|
||||
* then creating them on every call. */
|
||||
private long _flagsPtr = CanTalonJNI.new_intp();
|
||||
private long _profileSlotSelectPtr = CanTalonJNI.new_intp();
|
||||
private long _targPosPtr = CanTalonJNI.new_intp();
|
||||
private long _targVelPtr = CanTalonJNI.new_intp();
|
||||
private long _topBufferRemPtr = CanTalonJNI.new_intp();
|
||||
private long _topBufferCntPtr = CanTalonJNI.new_intp();
|
||||
private long _btmBufferCntPtr = CanTalonJNI.new_intp();
|
||||
private long _outputEnablePtr = CanTalonJNI.new_intp();
|
||||
|
||||
private CanTalonSRX m_impl;
|
||||
private TalonControlMode m_controlMode;
|
||||
@@ -148,7 +316,10 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
* for scaling into rotations and RPM.
|
||||
*/
|
||||
FeedbackDevice m_feedbackDevice;
|
||||
|
||||
/**
|
||||
* Constructor for the CANTalon device.
|
||||
* @param deviceNumber The CAN ID of the Talon SRX
|
||||
*/
|
||||
public CANTalon(int deviceNumber) {
|
||||
m_deviceNumber = deviceNumber;
|
||||
m_impl = new CanTalonSRX(deviceNumber);
|
||||
@@ -162,7 +333,12 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
setProfile(m_profile);
|
||||
applyControlMode(TalonControlMode.PercentVbus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the CANTalon device.
|
||||
* @param deviceNumber The CAN ID of the Talon SRX
|
||||
* @param controlPeriodMs The period in ms to send the CAN control frame.
|
||||
* Period is bounded to [1ms,95ms].
|
||||
*/
|
||||
public CANTalon(int deviceNumber, int controlPeriodMs) {
|
||||
m_deviceNumber = deviceNumber;
|
||||
m_impl = new CanTalonSRX(deviceNumber, controlPeriodMs); /*
|
||||
@@ -180,6 +356,29 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
setProfile(m_profile);
|
||||
applyControlMode(TalonControlMode.PercentVbus);
|
||||
}
|
||||
/**
|
||||
* Constructor for the CANTalon device.
|
||||
* @param deviceNumber The CAN ID of the Talon SRX
|
||||
* @param controlPeriodMs The period in ms to send the CAN control frame.
|
||||
* Period is bounded to [1ms,95ms].
|
||||
* @param enablePeriodMs The period in ms to send the enable control frame.
|
||||
* Period is bounded to [1ms,95ms]. This typically is not
|
||||
* required to specify, however this could be used to minimize the
|
||||
* time between robot-enable and talon-motor-drive.
|
||||
*/
|
||||
public CANTalon(int deviceNumber, int controlPeriodMs, int enablePeriodMs) {
|
||||
m_deviceNumber = deviceNumber;
|
||||
m_impl = new CanTalonSRX(deviceNumber, controlPeriodMs, enablePeriodMs);
|
||||
m_safetyHelper = new MotorSafetyHelper(this);
|
||||
m_controlEnabled = true;
|
||||
m_profile = 0;
|
||||
m_setPoint = 0;
|
||||
m_codesPerRev = 0;
|
||||
m_numPotTurns = 0;
|
||||
m_feedbackDevice = FeedbackDevice.QuadEncoder;
|
||||
setProfile(m_profile);
|
||||
applyControlMode(TalonControlMode.PercentVbus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pidWrite(double output) {
|
||||
@@ -253,6 +452,9 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
double milliamperes = (isInverted ? -outputValue : outputValue) * 1000.0; /* mA*/
|
||||
m_impl.SetDemand((int)milliamperes);
|
||||
break;
|
||||
case MotionProfile:
|
||||
m_impl.SetDemand((int) outputValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -582,15 +784,15 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
/**
|
||||
* Set the allowable closed loop error.
|
||||
* @param allowableCloseLoopError allowable closed loop error for selected profile.
|
||||
* mA for Curent closed loop.
|
||||
* Talon Native Units for position and velocity.
|
||||
* mA for Curent closed loop.
|
||||
* Talon Native Units for position and velocity.
|
||||
*/
|
||||
public void setAllowableClosedLoopErr(int allowableCloseLoopError)
|
||||
{
|
||||
if(m_profile == 0){
|
||||
setParameter(CanTalonSRX.param_t.eProfileParamSlot0_AllowableClosedLoopErr, (double)allowableCloseLoopError);
|
||||
setParameter(CanTalonSRX.param_t.eProfileParamSlot0_AllowableClosedLoopErr, (double)allowableCloseLoopError);
|
||||
}else{
|
||||
setParameter(CanTalonSRX.param_t.eProfileParamSlot1_AllowableClosedLoopErr, (double)allowableCloseLoopError);
|
||||
setParameter(CanTalonSRX.param_t.eProfileParamSlot1_AllowableClosedLoopErr, (double)allowableCloseLoopError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,17 +1387,17 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
*/
|
||||
public void configMaxOutputVoltage(double voltage) {
|
||||
/* config peak throttle when in closed-loop mode in the fwd and rev direction. */
|
||||
configPeakOutputVoltage(voltage, -voltage);
|
||||
configPeakOutputVoltage(voltage, -voltage);
|
||||
}
|
||||
|
||||
public void configPeakOutputVoltage(double forwardVoltage,double reverseVoltage) {
|
||||
/* bounds checking */
|
||||
if(forwardVoltage > 12)
|
||||
forwardVoltage = 12;
|
||||
forwardVoltage = 12;
|
||||
else if(forwardVoltage < 0)
|
||||
forwardVoltage = 0;
|
||||
if(reverseVoltage > 0)
|
||||
reverseVoltage = 0;
|
||||
reverseVoltage = 0;
|
||||
else if(reverseVoltage < -12)
|
||||
reverseVoltage = -12;
|
||||
/* config calls */
|
||||
@@ -1205,11 +1407,11 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
public void configNominalOutputVoltage(double forwardVoltage,double reverseVoltage) {
|
||||
/* bounds checking */
|
||||
if(forwardVoltage > 12)
|
||||
forwardVoltage = 12;
|
||||
forwardVoltage = 12;
|
||||
else if(forwardVoltage < 0)
|
||||
forwardVoltage = 0;
|
||||
if(reverseVoltage > 0)
|
||||
reverseVoltage = 0;
|
||||
reverseVoltage = 0;
|
||||
else if(reverseVoltage < -12)
|
||||
reverseVoltage = -12;
|
||||
/* config calls */
|
||||
@@ -1229,14 +1431,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
* be used for testing future features.
|
||||
*/
|
||||
public double getParameter(CanTalonSRX.param_t paramEnum) {
|
||||
/* transmit a request for this param */
|
||||
/* transmit a request for this param */
|
||||
m_impl.RequestParam(paramEnum);
|
||||
/* Briefly wait for new values from the Talon. */
|
||||
Timer.delay(kDelayForSolicitedSignals);
|
||||
/* poll out latest response value */
|
||||
/* poll out latest response value */
|
||||
long pp = CanTalonJNI.new_doublep();
|
||||
SWIGTYPE_p_CTR_Code status = m_impl.GetParamResponse(paramEnum, new SWIGTYPE_p_double(pp, true));
|
||||
/* pass latest value back to caller */
|
||||
/* pass latest value back to caller */
|
||||
return CanTalonJNI.doublep_value(pp);
|
||||
}
|
||||
public void clearStickyFaults() {
|
||||
@@ -1363,183 +1565,312 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont
|
||||
}
|
||||
/**
|
||||
* @return Number of native units per rotation if scaling info is available.
|
||||
* Zero if scaling information is not available.
|
||||
* Zero if scaling information is not available.
|
||||
*/
|
||||
double GetNativeUnitsPerRotationScalar(FeedbackDevice devToLookup)
|
||||
{
|
||||
double retval = 0;
|
||||
boolean scalingAvail = false;
|
||||
switch(devToLookup){
|
||||
case QuadEncoder:
|
||||
{ /* When caller wants to lookup Quadrature, the QEI may be in 1x if the selected feedback is edge counter.
|
||||
* Additionally if the quadrature source is the CTRE Mag encoder, then the CPR is known.
|
||||
* This is nice in that the calling app does not require knowing the CPR at all.
|
||||
* So do both checks here.
|
||||
*/
|
||||
int qeiPulsePerCount = 4; /* default to 4x */
|
||||
switch(m_feedbackDevice){
|
||||
case CtreMagEncoder_Relative:
|
||||
case CtreMagEncoder_Absolute:
|
||||
/* we assume the quadrature signal comes from the MagEnc,
|
||||
of which we know the CPR already */
|
||||
retval = kNativePwdUnitsPerRotation;
|
||||
scalingAvail = true;
|
||||
break;
|
||||
case EncRising: /* Talon's QEI is setup for 1x, so perform 1x math */
|
||||
case EncFalling:
|
||||
qeiPulsePerCount = 1;
|
||||
break;
|
||||
case QuadEncoder: /* Talon's QEI is 4x */
|
||||
default: /* pulse width and everything else, assume its regular quad use. */
|
||||
break;
|
||||
}
|
||||
if(scalingAvail){
|
||||
/* already deduced the scalar above, we're done. */
|
||||
}else{
|
||||
/* we couldn't deduce the scalar just based on the selection */
|
||||
if(0 == m_codesPerRev){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else{
|
||||
/* Talon expects PPR units */
|
||||
retval = 4 * m_codesPerRev;
|
||||
scalingAvail = true;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case EncRising:
|
||||
case EncFalling:
|
||||
if(0 == m_codesPerRev){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else{
|
||||
/* Talon expects PPR units */
|
||||
retval = 1 * m_codesPerRev;
|
||||
scalingAvail = true;
|
||||
}
|
||||
break;
|
||||
case AnalogPot:
|
||||
case AnalogEncoder:
|
||||
if(0 == m_numPotTurns){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else {
|
||||
retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns;
|
||||
scalingAvail = true;
|
||||
}
|
||||
break;
|
||||
case CtreMagEncoder_Relative:
|
||||
case CtreMagEncoder_Absolute:
|
||||
case PulseWidth:
|
||||
retval = kNativePwdUnitsPerRotation;
|
||||
scalingAvail = true;
|
||||
break;
|
||||
}
|
||||
/* if scaling info is not available give caller zero */
|
||||
if(false == scalingAvail)
|
||||
return 0;
|
||||
return retval;
|
||||
double retval = 0;
|
||||
boolean scalingAvail = false;
|
||||
switch(devToLookup){
|
||||
case QuadEncoder:
|
||||
{ /* When caller wants to lookup Quadrature, the QEI may be in 1x if the selected feedback is edge counter.
|
||||
* Additionally if the quadrature source is the CTRE Mag encoder, then the CPR is known.
|
||||
* This is nice in that the calling app does not require knowing the CPR at all.
|
||||
* So do both checks here.
|
||||
*/
|
||||
int qeiPulsePerCount = 4; /* default to 4x */
|
||||
switch(m_feedbackDevice){
|
||||
case CtreMagEncoder_Relative:
|
||||
case CtreMagEncoder_Absolute:
|
||||
/* we assume the quadrature signal comes from the MagEnc,
|
||||
of which we know the CPR already */
|
||||
retval = kNativePwdUnitsPerRotation;
|
||||
scalingAvail = true;
|
||||
break;
|
||||
case EncRising: /* Talon's QEI is setup for 1x, so perform 1x math */
|
||||
case EncFalling:
|
||||
qeiPulsePerCount = 1;
|
||||
break;
|
||||
case QuadEncoder: /* Talon's QEI is 4x */
|
||||
default: /* pulse width and everything else, assume its regular quad use. */
|
||||
break;
|
||||
}
|
||||
if(scalingAvail){
|
||||
/* already deduced the scalar above, we're done. */
|
||||
}else{
|
||||
/* we couldn't deduce the scalar just based on the selection */
|
||||
if(0 == m_codesPerRev){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else{
|
||||
/* Talon expects PPR units */
|
||||
retval = 4 * m_codesPerRev;
|
||||
scalingAvail = true;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case EncRising:
|
||||
case EncFalling:
|
||||
if(0 == m_codesPerRev){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else{
|
||||
/* Talon expects PPR units */
|
||||
retval = 1 * m_codesPerRev;
|
||||
scalingAvail = true;
|
||||
}
|
||||
break;
|
||||
case AnalogPot:
|
||||
case AnalogEncoder:
|
||||
if(0 == m_numPotTurns){
|
||||
/* caller has never set the CPR. Most likely caller
|
||||
is just using engineering units so fall to the
|
||||
bottom of this func.*/
|
||||
}else {
|
||||
retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns;
|
||||
scalingAvail = true;
|
||||
}
|
||||
break;
|
||||
case CtreMagEncoder_Relative:
|
||||
case CtreMagEncoder_Absolute:
|
||||
case PulseWidth:
|
||||
retval = kNativePwdUnitsPerRotation;
|
||||
scalingAvail = true;
|
||||
break;
|
||||
}
|
||||
/* if scaling info is not available give caller zero */
|
||||
if(false == scalingAvail)
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @param fullRotations double precision value representing number of rotations of selected feedback sensor.
|
||||
* If user has never called the config routine for the selected sensor, then the caller
|
||||
* is likely passing rotations in engineering units already, in which case it is returned
|
||||
* as is.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @param fullRotations double precision value representing number of rotations of selected feedback sensor.
|
||||
* If user has never called the config routine for the selected sensor, then the caller
|
||||
* is likely passing rotations in engineering units already, in which case it is returned
|
||||
* as is.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @return fullRotations in native engineering units of the Talon SRX firmware.
|
||||
*/
|
||||
int ScaleRotationsToNativeUnits(FeedbackDevice devToLookup, double fullRotations)
|
||||
{
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int retval = (int)fullRotations;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (int)(fullRotations*scalar);
|
||||
return retval;
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int retval = (int)fullRotations;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (int)(fullRotations*scalar);
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @param rpm double precision value representing number of rotations per minute of selected feedback sensor.
|
||||
* If user has never called the config routine for the selected sensor, then the caller
|
||||
* is likely passing rotations in engineering units already, in which case it is returned
|
||||
* as is.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @param rpm double precision value representing number of rotations per minute of selected feedback sensor.
|
||||
* If user has never called the config routine for the selected sensor, then the caller
|
||||
* is likely passing rotations in engineering units already, in which case it is returned
|
||||
* as is.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @return sensor velocity in native engineering units of the Talon SRX firmware.
|
||||
*/
|
||||
int ScaleVelocityToNativeUnits(FeedbackDevice devToLookup, double rpm)
|
||||
{
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int retval = (int)rpm;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (int)(rpm * kMinutesPer100msUnit * scalar);
|
||||
return retval;
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int retval = (int)rpm;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (int)(rpm * kMinutesPer100msUnit * scalar);
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @param nativePos integral position of the feedback sensor in native Talon SRX units.
|
||||
* If user has never called the config routine for the selected sensor, then the return
|
||||
* will be in TALON SRX units as well to match the behavior in the 2015 season.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @param nativePos integral position of the feedback sensor in native Talon SRX units.
|
||||
* If user has never called the config routine for the selected sensor, then the return
|
||||
* will be in TALON SRX units as well to match the behavior in the 2015 season.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @return double precision number of rotations, unless config was never performed.
|
||||
*/
|
||||
double ScaleNativeUnitsToRotations(FeedbackDevice devToLookup, int nativePos)
|
||||
{
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
double retval = (double)nativePos;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = ((double)nativePos) / scalar;
|
||||
return retval;
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
double retval = (double)nativePos;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = ((double)nativePos) / scalar;
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @param nativeVel integral velocity of the feedback sensor in native Talon SRX units.
|
||||
* If user has never called the config routine for the selected sensor, then the return
|
||||
* will be in TALON SRX units as well to match the behavior in the 2015 season.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @param nativeVel integral velocity of the feedback sensor in native Talon SRX units.
|
||||
* If user has never called the config routine for the selected sensor, then the return
|
||||
* will be in TALON SRX units as well to match the behavior in the 2015 season.
|
||||
* @see configPotentiometerTurns
|
||||
* @see configEncoderCodesPerRev
|
||||
* @return double precision of sensor velocity in RPM, unless config was never performed.
|
||||
*/
|
||||
double ScaleNativeUnitsToRpm(FeedbackDevice devToLookup, long nativeVel)
|
||||
{
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
double retval = (double)nativeVel;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (double)(nativeVel) / (scalar*kMinutesPer100msUnit);
|
||||
return retval;
|
||||
double retval = (double)nativeVel;
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if(scalar > 0)
|
||||
retval = (double)(nativeVel) / (scalar*kMinutesPer100msUnit);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables Talon SRX to automatically zero the Sensor Position whenever an
|
||||
* edge is detected on the index signal.
|
||||
* @param enable boolean input, pass true to enable feature or false to disable.
|
||||
* @param risingEdge boolean input, pass true to clear the position on rising edge,
|
||||
* pass false to clear the position on falling edge.
|
||||
* edge is detected on the index signal.
|
||||
* @param enable boolean input, pass true to enable feature or false to disable.
|
||||
* @param risingEdge boolean input, pass true to clear the position on rising edge,
|
||||
* pass false to clear the position on falling edge.
|
||||
*/
|
||||
public void enableZeroSensorPositionOnIndex(boolean enable, boolean risingEdge) {
|
||||
if(enable){
|
||||
/* enable the feature, update the edge polarity first to ensure
|
||||
it is correct before the feature is enabled. */
|
||||
setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0);
|
||||
setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,1);
|
||||
}else{
|
||||
/* disable the feature first, then update the edge polarity. */
|
||||
setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,0);
|
||||
setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0);
|
||||
}
|
||||
/* enable the feature, update the edge polarity first to ensure
|
||||
it is correct before the feature is enabled. */
|
||||
setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0);
|
||||
setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,1);
|
||||
}else{
|
||||
/* disable the feature first, then update the edge polarity. */
|
||||
setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,0);
|
||||
setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Calling application can opt to speed up the handshaking between the robot API and the Talon to increase the
|
||||
* download rate of the Talon's Motion Profile. Ideally the period should be no more than half the period
|
||||
* of a trajectory point.
|
||||
*/
|
||||
public void changeMotionControlFramePeriod(int periodMs) {
|
||||
m_impl.ChangeMotionControlFramePeriod(periodMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the buffered motion profile in both Talon RAM (bottom), and in the API (top).
|
||||
* Be sure to check getMotionProfileStatus() to know when the buffer is actually cleared.
|
||||
*/
|
||||
public void clearMotionProfileTrajectories() {
|
||||
m_impl.ClearMotionProfileTrajectories();
|
||||
}
|
||||
/**
|
||||
* Retrieve just the buffer count for the api-level (top) buffer.
|
||||
* This routine performs no CAN or data structure lookups, so its fast and ideal
|
||||
* if caller needs to quickly poll the progress of trajectory points being emptied
|
||||
* into Talon's RAM. Otherwise just use GetMotionProfileStatus.
|
||||
* @return number of trajectory points in the top buffer.
|
||||
*/
|
||||
public int getMotionProfileTopLevelBufferCount() {
|
||||
return m_impl.GetMotionProfileTopLevelBufferCount();
|
||||
}
|
||||
/**
|
||||
* Push another trajectory point into the top level buffer (which is emptied into
|
||||
* the Talon's bottom buffer as room allows).
|
||||
* @param targPos servo position in native Talon units (sensor units).
|
||||
* @param targVel velocity to feed-forward in native Talon units (sensor units per 100ms).
|
||||
* @param profileSlotSelect which slot to pull PIDF gains from. Currently supports 0 or 1.
|
||||
* @param timeDurMs time in milliseconds of how long to apply this point.
|
||||
* @param velOnly set to nonzero to signal Talon that only the feed-foward velocity should be
|
||||
* used, i.e. do not perform PID on position. This is equivalent to setting
|
||||
* PID gains to zero, but much more efficient and synchronized to MP.
|
||||
* @param isLastPoint set to nonzero to signal Talon to keep processing this trajectory point,
|
||||
* instead of jumping to the next one when timeDurMs expires. Otherwise
|
||||
* MP executer will eventuall see an empty buffer after the last point expires,
|
||||
* causing it to assert the IsUnderRun flag. However this may be desired
|
||||
* if calling application nevers wants to terminate the MP.
|
||||
* @param zeroPos set to nonzero to signal Talon to "zero" the selected position sensor before executing
|
||||
* this trajectory point. Typically the first point should have this set only thus allowing
|
||||
* the remainder of the MP positions to be relative to zero.
|
||||
* @return CTR_OKAY if trajectory point push ok. CTR_BufferFull if buffer is full due to kMotionProfileTopBufferCapacity.
|
||||
*/
|
||||
public boolean pushMotionProfileTrajectory(TrajectoryPoint trajPt) {
|
||||
/* check if there is room */
|
||||
if(isMotionProfileTopLevelBufferFull())
|
||||
return false;
|
||||
/* convert position and velocity to native units */
|
||||
int targPos = ScaleRotationsToNativeUnits(m_feedbackDevice, trajPt.position);
|
||||
int targVel = ScaleVelocityToNativeUnits(m_feedbackDevice, trajPt.velocity);
|
||||
/* bounds check signals that require it */
|
||||
int profileSlotSelect = (trajPt.profileSlotSelect > 0) ? 1 : 0;
|
||||
int timeDurMs = trajPt.timeDurMs;
|
||||
/* cap time to [0ms, 255ms], 0 and 1 are both interpreted as 1ms. */
|
||||
if(timeDurMs > 255)
|
||||
timeDurMs = 255;
|
||||
if(timeDurMs < 0)
|
||||
timeDurMs = 0;
|
||||
/* send it to the top level buffer */
|
||||
m_impl.PushMotionProfileTrajectory(targPos, targVel, profileSlotSelect, timeDurMs, trajPt.velocityOnly ? 1 : 0, trajPt.isLastPoint ? 1 : 0, trajPt.zeroPos ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @return true if api-level (top) buffer is full.
|
||||
*/
|
||||
public boolean isMotionProfileTopLevelBufferFull() {
|
||||
return m_impl.IsMotionProfileTopLevelBufferFull();
|
||||
}
|
||||
/**
|
||||
* This must be called periodically to funnel the trajectory points from the API's top level buffer to
|
||||
* the Talon's bottom level buffer. Recommendation is to call this twice as fast as the executation rate of the motion profile.
|
||||
* So if MP is running with 20ms trajectory points, try calling this routine every 10ms. All motion profile functions are thread-safe
|
||||
* through the use of a mutex, so there is no harm in having the caller utilize threading.
|
||||
*/
|
||||
public void processMotionProfileBuffer() {
|
||||
m_impl.ProcessMotionProfileBuffer();
|
||||
}
|
||||
/**
|
||||
* Retrieve all Motion Profile status information.
|
||||
* Since this all comes from one CAN frame, its ideal to have one routine to retrieve the frame once and decode everything.
|
||||
* @param [out] motionProfileStatus contains all progress information on the currently running MP. Caller should
|
||||
* must instantiate the motionProfileStatus object first then pass into this routine to be filled.
|
||||
*/
|
||||
public void getMotionProfileStatus(MotionProfileStatus motionProfileStatus) {
|
||||
/* retrieve all motion profile signals from status frame */
|
||||
SWIGTYPE_p_uint32_t _flagsSwig = new SWIGTYPE_p_uint32_t(_flagsPtr, true);
|
||||
SWIGTYPE_p_uint32_t _profileSlotSelectSwig = new SWIGTYPE_p_uint32_t(_profileSlotSelectPtr, true);
|
||||
SWIGTYPE_p_int32_t _targPosSwig = new SWIGTYPE_p_int32_t(_targPosPtr, true);
|
||||
SWIGTYPE_p_int32_t _targVelSwig = new SWIGTYPE_p_int32_t(_targVelPtr, true);
|
||||
SWIGTYPE_p_uint32_t _topBufferRemSwig = new SWIGTYPE_p_uint32_t(_topBufferRemPtr, true);
|
||||
SWIGTYPE_p_uint32_t _topBufferCntSwig = new SWIGTYPE_p_uint32_t(_topBufferCntPtr, true);
|
||||
SWIGTYPE_p_uint32_t _btmBufferCntSwig = new SWIGTYPE_p_uint32_t(_btmBufferCntPtr, true);
|
||||
SWIGTYPE_p_uint32_t _outputEnableSwig = new SWIGTYPE_p_uint32_t(_outputEnablePtr, true);
|
||||
/* call native routine then empty swig values into caller's motionProfileStatus */
|
||||
m_impl.GetMotionProfileStatus(_flagsSwig, _profileSlotSelectSwig, _targPosSwig, _targVelSwig, _topBufferRemSwig, _topBufferCntSwig, _btmBufferCntSwig, _outputEnableSwig);
|
||||
/* cache the params that needs processing */
|
||||
int flags = CanTalonJNI.intp_value(_flagsPtr);
|
||||
int targPos = CanTalonJNI.intp_value(_targPosPtr);
|
||||
int targVel = CanTalonJNI.intp_value(_targVelPtr);
|
||||
/* completely update the caller's structure */
|
||||
motionProfileStatus.topBufferRem = CanTalonJNI.intp_value(_topBufferRemPtr);
|
||||
motionProfileStatus.topBufferCnt = CanTalonJNI.intp_value(_topBufferCntPtr);
|
||||
motionProfileStatus.btmBufferCnt = CanTalonJNI.intp_value(_btmBufferCntPtr);
|
||||
motionProfileStatus.hasUnderrun = ((flags & CanTalonSRX.kMotionProfileFlag_HasUnderrun)>0) ? true :false;
|
||||
motionProfileStatus.isUnderrun = ((flags & CanTalonSRX.kMotionProfileFlag_IsUnderrun)>0) ? true :false;
|
||||
motionProfileStatus.activePointValid = ((flags & CanTalonSRX.kMotionProfileFlag_ActTraj_IsValid)>0) ? true :false;
|
||||
motionProfileStatus.activePoint.isLastPoint = ((flags & CanTalonSRX.kMotionProfileFlag_ActTraj_IsLast)>0) ? true :false;
|
||||
motionProfileStatus.activePoint.velocityOnly = ((flags & CanTalonSRX.kMotionProfileFlag_ActTraj_VelOnly)>0) ? true :false;
|
||||
motionProfileStatus.activePoint.position = ScaleNativeUnitsToRotations(m_feedbackDevice, targPos);
|
||||
motionProfileStatus.activePoint.velocity = ScaleNativeUnitsToRpm(m_feedbackDevice, targVel);
|
||||
motionProfileStatus.activePoint.profileSlotSelect = CanTalonJNI.intp_value(_profileSlotSelectPtr);
|
||||
motionProfileStatus.outputEnable = SetValueMotionProfile.valueOf(CanTalonJNI.intp_value(_outputEnablePtr));
|
||||
motionProfileStatus.activePoint.zeroPos = false; /* this signal is only used sending pts to Talon */
|
||||
motionProfileStatus.activePoint.timeDurMs = 0; /* this signal is only used sending pts to Talon */
|
||||
}
|
||||
/**
|
||||
* Clear the hasUnderrun flag in Talon's Motion Profile Executer when MPE is ready for another point,
|
||||
* but the low level buffer is empty.
|
||||
*
|
||||
* Once the Motion Profile Executer sets the hasUnderrun flag, it stays set until
|
||||
* Robot Application clears it with this routine, which ensures Robot Application
|
||||
* gets a chance to instrument or react. Caller could also check the isUnderrun flag
|
||||
* which automatically clears when fault condition is removed.
|
||||
*/
|
||||
public void clearMotionProfileHasUnderrun() {
|
||||
setParameter(CanTalonSRX.param_t.eMotionProfileHasUnderrunErr, 0);
|
||||
}
|
||||
@Override
|
||||
public void setExpiration(double timeout) {
|
||||
|
||||
@@ -37,16 +37,20 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
super.delete();
|
||||
}
|
||||
|
||||
public CanTalonSRX(int deviceNumber, int controlPeriodMs, int enablePeriodMs) {
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_0(deviceNumber, controlPeriodMs, enablePeriodMs), true);
|
||||
}
|
||||
|
||||
public CanTalonSRX(int deviceNumber, int controlPeriodMs) {
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_0(deviceNumber, controlPeriodMs), true);
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_1(deviceNumber, controlPeriodMs), true);
|
||||
}
|
||||
|
||||
public CanTalonSRX(int deviceNumber) {
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_1(deviceNumber), true);
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_2(deviceNumber), true);
|
||||
}
|
||||
|
||||
public CanTalonSRX() {
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_2(), true);
|
||||
this(CanTalonJNI.new_CanTalonSRX__SWIG_3(), true);
|
||||
}
|
||||
|
||||
public void Set(double value) {
|
||||
@@ -104,8 +108,8 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
slotIdx, closeLoopRampRate), true);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code SetVoltageCompensationRate(double vpers) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetVoltageCompensationRate(swigCPtr, this,vpers), true);
|
||||
public SWIGTYPE_p_CTR_Code SetVoltageCompensationRate(double voltagePerMs) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetVoltageCompensationRate(swigCPtr, this, voltagePerMs), true);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code SetSensorPosition(int pos) {
|
||||
@@ -162,9 +166,9 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
slotIdx, SWIGTYPE_p_int.getCPtr(closeLoopRampRate)), true);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code GetVoltageCompensationRate(SWIGTYPE_p_double vpers) {
|
||||
public SWIGTYPE_p_CTR_Code GetVoltageCompensationRate(SWIGTYPE_p_double voltagePerMs) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetVoltageCompensationRate(swigCPtr, this,
|
||||
SWIGTYPE_p_double.getCPtr(vpers)), true);
|
||||
SWIGTYPE_p_double.getCPtr(voltagePerMs)), true);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code GetForwardSoftLimit(SWIGTYPE_p_int forwardLimit) {
|
||||
@@ -196,6 +200,34 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_ClearStickyFaults(swigCPtr, this), true);
|
||||
}
|
||||
|
||||
|
||||
public void ChangeMotionControlFramePeriod(int periodMs) {
|
||||
CanTalonJNI.CanTalonSRX_ChangeMotionControlFramePeriod(swigCPtr, this, periodMs);
|
||||
}
|
||||
|
||||
public void ClearMotionProfileTrajectories() {
|
||||
CanTalonJNI.CanTalonSRX_ClearMotionProfileTrajectories(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int GetMotionProfileTopLevelBufferCount() {
|
||||
return CanTalonJNI.CanTalonSRX_GetMotionProfileTopLevelBufferCount(swigCPtr, this);
|
||||
}
|
||||
|
||||
public boolean IsMotionProfileTopLevelBufferFull() {
|
||||
return CanTalonJNI.CanTalonSRX_IsMotionProfileTopLevelBufferFull(swigCPtr, this);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code PushMotionProfileTrajectory(int targPos, int targVel, int profileSlotSelect, int timeDurMs, int velOnly, int isLastPoint, int zeroPos) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_PushMotionProfileTrajectory(swigCPtr, this, targPos, targVel, profileSlotSelect, timeDurMs, velOnly, isLastPoint, zeroPos), true);
|
||||
}
|
||||
|
||||
public void ProcessMotionProfileBuffer() {
|
||||
CanTalonJNI.CanTalonSRX_ProcessMotionProfileBuffer(swigCPtr, this);
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_CTR_Code GetMotionProfileStatus(SWIGTYPE_p_uint32_t flags, SWIGTYPE_p_uint32_t profileSlotSelect, SWIGTYPE_p_int32_t targPos, SWIGTYPE_p_int32_t targVel, SWIGTYPE_p_uint32_t topBufferRemaining, SWIGTYPE_p_uint32_t topBufferCnt, SWIGTYPE_p_uint32_t btmBufferCnt, SWIGTYPE_p_uint32_t outputEnable) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetMotionProfileStatus(swigCPtr, this, SWIGTYPE_p_uint32_t.getCPtr(flags), SWIGTYPE_p_uint32_t.getCPtr(profileSlotSelect), SWIGTYPE_p_int32_t.getCPtr(targPos), SWIGTYPE_p_int32_t.getCPtr(targVel), SWIGTYPE_p_uint32_t.getCPtr(topBufferRemaining), SWIGTYPE_p_uint32_t.getCPtr(topBufferCnt), SWIGTYPE_p_uint32_t.getCPtr(btmBufferCnt), SWIGTYPE_p_uint32_t.getCPtr(outputEnable)), true);
|
||||
}
|
||||
public SWIGTYPE_p_CTR_Code GetFault_OverTemp(SWIGTYPE_p_int param) {
|
||||
return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_OverTemp(swigCPtr, this,
|
||||
SWIGTYPE_p_int.getCPtr(param)), true);
|
||||
@@ -448,6 +480,8 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
|
||||
public final static int kDefaultControlPeriodMs = CanTalonJNI
|
||||
.CanTalonSRX_kDefaultControlPeriodMs_get();
|
||||
public final static int kDefaultEnablePeriodMs = CanTalonJNI.CanTalonSRX_kDefaultEnablePeriodMs_get();
|
||||
public final static int kDefaultControl6PeriodMs = CanTalonJNI.CanTalonSRX_kDefaultControl6PeriodMs_get();
|
||||
public final static int kMode_DutyCycle = CanTalonJNI.CanTalonSRX_kMode_DutyCycle_get();
|
||||
public final static int kMode_PositionCloseLoop = CanTalonJNI
|
||||
.CanTalonSRX_kMode_PositionCloseLoop_get();
|
||||
@@ -457,6 +491,7 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
.CanTalonSRX_kMode_CurrentCloseLoop_get();
|
||||
public final static int kMode_VoltCompen = CanTalonJNI.CanTalonSRX_kMode_VoltCompen_get();
|
||||
public final static int kMode_SlaveFollower = CanTalonJNI.CanTalonSRX_kMode_SlaveFollower_get();
|
||||
public final static int kMode_MotionProfile = CanTalonJNI.CanTalonSRX_kMode_MotionProfile_get();
|
||||
public final static int kMode_NoDrive = CanTalonJNI.CanTalonSRX_kMode_NoDrive_get();
|
||||
public final static int kLimitSwitchOverride_UseDefaultsFromFlash = CanTalonJNI
|
||||
.CanTalonSRX_kLimitSwitchOverride_UseDefaultsFromFlash_get();
|
||||
@@ -499,6 +534,15 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
public final static int kStatusFrame_PulseWidthMeas = CanTalonJNI
|
||||
.CanTalonSRX_kStatusFrame_PulseWidthMeas_get();
|
||||
|
||||
public final static int kStatusFrame_MotionProfile = CanTalonJNI.CanTalonSRX_kStatusFrame_MotionProfile_get();
|
||||
public final static int kMotionProfileFlag_ActTraj_IsValid = CanTalonJNI.CanTalonSRX_kMotionProfileFlag_ActTraj_IsValid_get();
|
||||
public final static int kMotionProfileFlag_HasUnderrun = CanTalonJNI.CanTalonSRX_kMotionProfileFlag_HasUnderrun_get();
|
||||
public final static int kMotionProfileFlag_IsUnderrun = CanTalonJNI.CanTalonSRX_kMotionProfileFlag_IsUnderrun_get();
|
||||
public final static int kMotionProfileFlag_ActTraj_IsLast = CanTalonJNI.CanTalonSRX_kMotionProfileFlag_ActTraj_IsLast_get();
|
||||
public final static int kMotionProfileFlag_ActTraj_VelOnly = CanTalonJNI.CanTalonSRX_kMotionProfileFlag_ActTraj_VelOnly_get();
|
||||
public final static int kMotionProf_Disabled = CanTalonJNI.CanTalonSRX_kMotionProf_Disabled_get();
|
||||
public final static int kMotionProf_Enable = CanTalonJNI.CanTalonSRX_kMotionProf_Enable_get();
|
||||
public final static int kMotionProf_Hold = CanTalonJNI.CanTalonSRX_kMotionProf_Hold_get();
|
||||
public final static class param_t {
|
||||
public final static CanTalonSRX.param_t eProfileParamSlot0_P = new CanTalonSRX.param_t(
|
||||
"eProfileParamSlot0_P", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_P_get());
|
||||
@@ -683,6 +727,11 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
CanTalonJNI.CanTalonSRX_eProfileParamVcompRate_get());
|
||||
public final static CanTalonSRX.param_t eProfileParamSlot1_AllowableClosedLoopErr = new CanTalonSRX.param_t("eProfileParamSlot1_AllowableClosedLoopErr",
|
||||
CanTalonJNI.CanTalonSRX_eProfileParamSlot1_AllowableClosedLoopErr_get());
|
||||
public final static CanTalonSRX.param_t eStatus9FrameRate = new CanTalonSRX.param_t("eStatus9FrameRate",
|
||||
CanTalonJNI.CanTalonSRX_eStatus9FrameRate_get());
|
||||
public final static CanTalonSRX.param_t eMotionProfileHasUnderrunErr = new CanTalonSRX.param_t("eMotionProfileHasUnderrunErr", CanTalonJNI.CanTalonSRX_eMotionProfileHasUnderrunErr_get());
|
||||
public final static CanTalonSRX.param_t eReserved120 = new CanTalonSRX.param_t("eReserved120", CanTalonJNI.CanTalonSRX_eReserved120_get());
|
||||
public final static CanTalonSRX.param_t eLegacyControlMode = new CanTalonSRX.param_t("eLegacyControlMode", CanTalonJNI.CanTalonSRX_eLegacyControlMode_get());
|
||||
|
||||
public final int swigValue() {
|
||||
return swigValue;
|
||||
@@ -736,7 +785,15 @@ public class CanTalonSRX extends CtreCanNode {
|
||||
eLimitSwitchClosedFor, eLimitSwitchClosedRev, eSensorPosition, eSensorVelocity, eCurrent,
|
||||
eBrakeIsEnabled, eEncPosition, eEncVel, eEncIndexRiseEvents, eQuadApin, eQuadBpin,
|
||||
eQuadIdxpin, eAnalogInWithOv, eAnalogInVel, eTemp, eBatteryV, eResetCount, eResetFlags,
|
||||
eFirmVers, eSettingsChanged, eQuadFilterEn, ePidIaccum};
|
||||
eFirmVers, eSettingsChanged, eQuadFilterEn, ePidIaccum,
|
||||
eStatus1FrameRate, eStatus2FrameRate, eStatus3FrameRate,
|
||||
eStatus4FrameRate, eStatus6FrameRate, eStatus7FrameRate,
|
||||
eClearPositionOnIdx, ePeakPosOutput, eNominalPosOutput,
|
||||
ePeakNegOutput, eNominalNegOutput, eQuadIdxPolarity,
|
||||
eStatus8FrameRate, eAllowPosOverflow, eProfileParamSlot0_AllowableClosedLoopErr,
|
||||
eNumberPotTurns, eNumberEncoderCPR, ePwdPosition, eAinPosition, eProfileParamVcompRate,
|
||||
eProfileParamSlot1_AllowableClosedLoopErr, eStatus9FrameRate, eMotionProfileHasUnderrunErr,
|
||||
eReserved120, eLegacyControlMode };
|
||||
private static int swigNext = 0;
|
||||
private final int swigValue;
|
||||
private final String swigName;
|
||||
|
||||
@@ -89,11 +89,17 @@ public class CanTalonJNI {
|
||||
|
||||
public final static native int CanTalonSRX_kDefaultControlPeriodMs_get();
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_0(int jarg1, int jarg2);
|
||||
public final static native int CanTalonSRX_kDefaultEnablePeriodMs_get();
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_1(int jarg1);
|
||||
public final static native int CanTalonSRX_kDefaultControl6PeriodMs_get();
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_2();
|
||||
public final static native long new_CanTalonSRX__SWIG_0(int jarg1, int jarg2, int jarg3);
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_1(int jarg1, int jarg2);
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_2(int jarg1);
|
||||
|
||||
public final static native long new_CanTalonSRX__SWIG_3();
|
||||
|
||||
public final static native void delete_CanTalonSRX(long jarg1);
|
||||
|
||||
@@ -111,6 +117,8 @@ public class CanTalonJNI {
|
||||
|
||||
public final static native int CanTalonSRX_kMode_SlaveFollower_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMode_MotionProfile_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMode_NoDrive_get();
|
||||
|
||||
public final static native int CanTalonSRX_kLimitSwitchOverride_UseDefaultsFromFlash_get();
|
||||
@@ -155,6 +163,24 @@ public class CanTalonJNI {
|
||||
|
||||
public final static native int CanTalonSRX_kStatusFrame_PulseWidthMeas_get();
|
||||
|
||||
public final static native int CanTalonSRX_kStatusFrame_MotionProfile_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProfileFlag_ActTraj_IsValid_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProfileFlag_HasUnderrun_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProfileFlag_IsUnderrun_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProfileFlag_ActTraj_IsLast_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProfileFlag_ActTraj_VelOnly_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProf_Disabled_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProf_Enable_get();
|
||||
|
||||
public final static native int CanTalonSRX_kMotionProf_Hold_get();
|
||||
|
||||
public final static native int CanTalonSRX_eProfileParamSlot0_P_get();
|
||||
|
||||
public final static native int CanTalonSRX_eProfileParamSlot0_I_get();
|
||||
@@ -327,6 +353,14 @@ public class CanTalonJNI {
|
||||
|
||||
public final static native int CanTalonSRX_eProfileParamSlot1_AllowableClosedLoopErr_get();
|
||||
|
||||
public final static native int CanTalonSRX_eStatus9FrameRate_get();
|
||||
|
||||
public final static native int CanTalonSRX_eMotionProfileHasUnderrunErr_get();
|
||||
|
||||
public final static native int CanTalonSRX_eReserved120_get();
|
||||
|
||||
public final static native int CanTalonSRX_eLegacyControlMode_get();
|
||||
|
||||
public final static native long CanTalonSRX_SetParam(long jarg1, CanTalonSRX jarg1_, int jarg2,
|
||||
double jarg3);
|
||||
|
||||
@@ -409,6 +443,20 @@ public class CanTalonJNI {
|
||||
|
||||
public final static native long CanTalonSRX_ClearStickyFaults(long jarg1, CanTalonSRX jarg1_);
|
||||
|
||||
public final static native void CanTalonSRX_ChangeMotionControlFramePeriod(long jarg1, CanTalonSRX jarg1_, int jarg2);
|
||||
|
||||
public final static native void CanTalonSRX_ClearMotionProfileTrajectories(long jarg1, CanTalonSRX jarg1_);
|
||||
|
||||
public final static native int CanTalonSRX_GetMotionProfileTopLevelBufferCount(long jarg1, CanTalonSRX jarg1_);
|
||||
|
||||
public final static native boolean CanTalonSRX_IsMotionProfileTopLevelBufferFull(long jarg1, CanTalonSRX jarg1_);
|
||||
|
||||
public final static native long CanTalonSRX_PushMotionProfileTrajectory(long jarg1, CanTalonSRX jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, int jarg6, int jarg7, int jarg8);
|
||||
|
||||
public final static native void CanTalonSRX_ProcessMotionProfileBuffer(long jarg1, CanTalonSRX jarg1_);
|
||||
|
||||
public final static native long CanTalonSRX_GetMotionProfileStatus(long jarg1, CanTalonSRX jarg1_, long jarg2, long jarg3, long jarg4, long jarg5, long jarg6, long jarg7, long jarg8, long jarg9);
|
||||
|
||||
public final static native long CanTalonSRX_GetFault_OverTemp(long jarg1, CanTalonSRX jarg1_,
|
||||
long jarg2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user