mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Remove CAN TalonSRX from WPILib (moving to external library) (#268)
This commit is contained in:
committed by
Fred Silberberg
parent
55346e28d0
commit
567ea1d58d
@@ -31,7 +31,6 @@ genFolderExclude {
|
||||
}
|
||||
|
||||
genFileExclude {
|
||||
CanTalonSRX\.h$
|
||||
NIIMAQdx\.h$
|
||||
can_proto\.h$
|
||||
nivision\.h$
|
||||
|
||||
@@ -1,829 +0,0 @@
|
||||
/**
|
||||
* @brief CAN TALON SRX driver.
|
||||
*
|
||||
* The TALON SRX is designed to instrument all runtime signals periodically.
|
||||
* The default periods are chosen to support 16 TALONs with 10ms update rate
|
||||
* for control (throttle or setpoint). However these can be overridden with
|
||||
* SetStatusFrameRate. @see SetStatusFrameRate
|
||||
* The getters for these unsolicited signals are auto generated at the bottom
|
||||
* of this module.
|
||||
*
|
||||
* Likewise most control signals are sent periodically using the fire-and-forget
|
||||
* CAN API. The setters for these unsolicited signals are auto generated at the
|
||||
* bottom of this module.
|
||||
*
|
||||
* Signals that are not available in an unsolicited fashion are the Close Loop
|
||||
* gains. For teams that have a single profile for their TALON close loop they
|
||||
* can use either the webpage to configure their TALONs once or set the PIDF,
|
||||
* Izone, CloseLoopRampRate, etc... once in the robot application. These
|
||||
* parameters are saved to flash so once they are loaded in the TALON, they
|
||||
* will persist through power cycles and mode changes.
|
||||
*
|
||||
* For teams that have one or two profiles to switch between, they can use the
|
||||
* same strategy since there are two slots to choose from and the
|
||||
* ProfileSlotSelect is periodically sent in the 10 ms control frame.
|
||||
*
|
||||
* For teams that require changing gains frequently, they can use the soliciting
|
||||
* API to get and set those parameters. Most likely they will only need to set
|
||||
* them in a periodic fashion as a function of what motion the application is
|
||||
* attempting. If this API is used, be mindful of the CAN utilization reported
|
||||
* in the driver station.
|
||||
*
|
||||
* If calling application has used the config routines to configure the
|
||||
* selected feedback sensor, then all positions are measured in floating point
|
||||
* precision rotations. All sensor velocities are specified in floating point
|
||||
* precision RPM.
|
||||
* @see ConfigPotentiometerTurns
|
||||
* @see ConfigEncoderCodesPerRev
|
||||
* HOWEVER, if calling application has not called the config routine for
|
||||
* selected feedback sensor, then all getters/setters for position/velocity use
|
||||
* the native engineering units of the Talon SRX firm (just like in 2015).
|
||||
* Signals explained below.
|
||||
*
|
||||
* Encoder position is measured in encoder edges. Every edge is counted
|
||||
* (similar to roboRIO 4X mode). Analog position is 10 bits, meaning 1024
|
||||
* ticks per rotation (0V => 3.3V). Use SetFeedbackDeviceSelect to select
|
||||
* which sensor type you need. Once you do that you can use GetSensorPosition()
|
||||
* and GetSensorVelocity(). These signals are updated on CANBus every 20ms (by
|
||||
* default). If a relative sensor is selected, you can zero (or change the
|
||||
* current value) using SetSensorPosition.
|
||||
*
|
||||
* Analog Input and quadrature position (and velocity) are also explicitly
|
||||
* reported in GetEncPosition, GetEncVel, GetAnalogInWithOv, GetAnalogInVel.
|
||||
* These signals are available all the time, regardless of what sensor is
|
||||
* selected at a rate of 100ms. This allows easy instrumentation for "in the
|
||||
* pits" checking of all sensors regardless of modeselect. The 100ms rate is
|
||||
* overridable for teams who want to acquire sensor data for processing, not
|
||||
* just instrumentation. Or just select the sensor using
|
||||
* SetFeedbackDeviceSelect to get it at 20ms.
|
||||
*
|
||||
* Velocity is in position ticks / 100ms.
|
||||
*
|
||||
* All output units are in respect to duty cycle (throttle) which is -1023(full
|
||||
* reverse) to +1023 (full forward). This includes demand (which specifies
|
||||
* duty cycle when in duty cycle mode) and rampRamp, which is in throttle units
|
||||
* per 10ms (if nonzero).
|
||||
*
|
||||
* Pos and velocity close loops are calc'd as
|
||||
* err = target - posOrVel.
|
||||
* iErr += err;
|
||||
* if( (IZone!=0) and abs(err) > IZone)
|
||||
* ClearIaccum()
|
||||
* output = P X err + I X iErr + D X dErr + F X target
|
||||
* dErr = err - lastErr
|
||||
* P, I, and D gains are always positive. F can be negative.
|
||||
* Motor direction can be reversed using SetRevMotDuringCloseLoopEn if
|
||||
* sensor and motor are out of phase. Similarly feedback sensor can also be
|
||||
* reversed (multiplied by -1) if you prefer the sensor to be inverted.
|
||||
*
|
||||
* P gain is specified in throttle per error tick. For example, a value of 102
|
||||
* is ~9.9% (which is 102/1023) throttle per 1 ADC unit(10bit) or 1 quadrature
|
||||
* encoder edge depending on selected sensor.
|
||||
*
|
||||
* I gain is specified in throttle per integrated error. For example, a value
|
||||
* of 10 equates to ~0.99% (which is 10/1023) for each accumulated ADC unit
|
||||
* (10 bit) or 1 quadrature encoder edge depending on selected sensor.
|
||||
* Close loop and integral accumulator runs every 1ms.
|
||||
*
|
||||
* D gain is specified in throttle per derivative error. For example a value of
|
||||
* 102 equates to ~9.9% (which is 102/1023) per change of 1 unit (ADC or
|
||||
* encoder) per ms.
|
||||
*
|
||||
* I Zone is specified in the same units as sensor position (ADC units or
|
||||
* quadrature edges). If pos/vel error is outside of this value, the
|
||||
* integrated error will auto-clear...
|
||||
* if( (IZone!=0) and abs(err) > IZone)
|
||||
* ClearIaccum()
|
||||
* ...this is very useful in preventing integral windup and is highly
|
||||
* recommended if using full PID to keep stability low.
|
||||
*
|
||||
* CloseLoopRampRate is in throttle units per 1ms. Set to zero to disable
|
||||
* ramping. Works the same as RampThrottle but only is in effect when a close
|
||||
* loop mode and profile slot is selected.
|
||||
*
|
||||
* auto generated using spreadsheet and wpiclassgen.py
|
||||
* @link https://docs.google.com/spreadsheets/d/1OU_ZV7fZLGYUQ-Uhc8sVAmUmWTlT8XBFYK8lfjg_tac/edit#gid=1766046967
|
||||
*/
|
||||
#ifndef CanTalonSRX_H_
|
||||
#define CanTalonSRX_H_
|
||||
#include "ctre/ctre.h" //BIT Defines + Typedefs, TALON_Control_6_MotProfAddTrajPoint_t
|
||||
#include "ctre/CtreCanNode.h"
|
||||
#include <FRC_NetworkCommunication/CANSessionMux.h> //CAN Comm
|
||||
#include <map>
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
class CanTalonSRX : public CtreCanNode {
|
||||
private:
|
||||
// Use this for determining whether the default move constructor has been
|
||||
// called; this prevents us from calling the destructor twice.
|
||||
struct HasBeenMoved {
|
||||
HasBeenMoved(HasBeenMoved &&other) {
|
||||
other.moved = true;
|
||||
moved = false;
|
||||
}
|
||||
HasBeenMoved() = default;
|
||||
std::atomic<bool> moved{false};
|
||||
operator bool() const { return moved; }
|
||||
} m_hasBeenMoved;
|
||||
|
||||
// Vars for opening a CAN stream if caller needs signals that require
|
||||
// soliciting
|
||||
uint32_t _can_h; //!< Session handle for catching response params.
|
||||
int32_t _can_stat; //!< Session handle status.
|
||||
struct tCANStreamMessage _msgBuff[20];
|
||||
static int const kMsgCapacity = 20;
|
||||
typedef std::map<uint32_t, uint32_t> sigs_t;
|
||||
// Catches signal updates that are solicited. Expect this to be very few.
|
||||
sigs_t _sigs;
|
||||
void OpenSessionIfNeedBe();
|
||||
void ProcessStreamMessages();
|
||||
/**
|
||||
* Called in various places to double check we are using the best control
|
||||
* frame. If the Talon firmware is too old, use control 1 framing, which
|
||||
* does not allow setting control signals until robot is enabled. If Talon
|
||||
* firmware can suport control5, use that since that frame can be
|
||||
* transmitted during robot-disable. If calling application uses setParam
|
||||
* to set the signal eLegacyControlMode, caller can force using control1
|
||||
* if needed for some reason.
|
||||
*/
|
||||
void UpdateControlId();
|
||||
/**
|
||||
* @return true if Talon is reporting that it supports control5, and therefore
|
||||
* RIO can send control5 to update control params (even when
|
||||
* disabled).
|
||||
*/
|
||||
bool IsControl5Supported();
|
||||
/**
|
||||
* Get a copy of the control frame to send.
|
||||
* @param [out] pointer to eight byte array to fill.
|
||||
*/
|
||||
void GetControlFrameCopy(uint8_t *toFill);
|
||||
/**
|
||||
* @return the tx task that transmits Control6 (motion profile control).
|
||||
* If it's not scheduled, then schedule it. This is part
|
||||
* of making the lazy-framing that only peforms MotionProf framing
|
||||
* when needed to save bandwidth.
|
||||
*/
|
||||
CtreCanNode::txTask<TALON_Control_6_MotProfAddTrajPoint_t> GetControl6();
|
||||
/**
|
||||
* Caller is either pushing a new motion profile point, or is
|
||||
* calling the Process buffer routine. In either case check our
|
||||
* flow control to see if we need to start sending control6.
|
||||
*/
|
||||
void ReactToMotionProfileCall();
|
||||
/**
|
||||
* Update the NextPt signals inside the control frame given the next pt to
|
||||
* send.
|
||||
* @param control pointer to the CAN frame payload containing control6. Only
|
||||
* the signals that serialize the next trajectory point are
|
||||
* updated from the contents of newPt.
|
||||
* @param newPt point to the next trajectory that needs to be inserted into
|
||||
* Talon RAM.
|
||||
*/
|
||||
void CopyTrajPtIntoControl(
|
||||
TALON_Control_6_MotProfAddTrajPoint_t *control,
|
||||
const TALON_Control_6_MotProfAddTrajPoint_t *newPt);
|
||||
//---------------------- General Control framing ---------------------------//
|
||||
/**
|
||||
* Frame period for control1 or control5, depending on which one we are using.
|
||||
*/
|
||||
int _controlPeriodMs = kDefaultControlPeriodMs;
|
||||
/**
|
||||
* Frame Period of the motion profile control6 frame.
|
||||
*/
|
||||
int _control6PeriodMs = kDefaultControl6PeriodMs;
|
||||
/**
|
||||
* When using control5, we still need to send a frame to enable robot. This
|
||||
* controls the period. This only is used when we are in the control5 state.
|
||||
* @see ControlFrameSelControl5
|
||||
*/
|
||||
int _enablePeriodMs = kDefaultEnablePeriodMs;
|
||||
/**
|
||||
* ArbID to use for control frame. Should be either CONTROL_1 or CONTROL_5.
|
||||
*/
|
||||
uint32_t _controlFrameArbId;
|
||||
/**
|
||||
* Boolean flag to signal calling applications intent to allow using control5
|
||||
* assuming Talon firmware supports it. This can be cleared to force control1
|
||||
* framing.
|
||||
*/
|
||||
bool _useControl5ifSupported = true;
|
||||
//--------------------- Buffering Motion Profile ---------------------------//
|
||||
/**
|
||||
* Top level Buffer for motion profile trajectory buffering.
|
||||
* Basically this buffers up the eight byte CAN frame payloads that are
|
||||
* handshaked into the Talon RAM.
|
||||
* TODO: Should this be moved into a separate header, and if so where
|
||||
* logically should it reside?
|
||||
* TODO: Add compression so that multiple CAN frames can be compressed into
|
||||
* one exchange.
|
||||
*/
|
||||
class TrajectoryBuffer {
|
||||
public:
|
||||
void Clear() { _motProfTopBuffer.clear(); }
|
||||
/**
|
||||
* push caller's uncompressed simple trajectory point.
|
||||
*/
|
||||
void Push(TALON_Control_6_MotProfAddTrajPoint_huff0_t &pt) {
|
||||
_motProfTopBuffer.push_back(pt);
|
||||
}
|
||||
/**
|
||||
* Get the next trajectory point CAN frame to send.
|
||||
* Underlying layer may compress the next few points together
|
||||
* into one control_6 frame.
|
||||
*/
|
||||
TALON_Control_6_MotProfAddTrajPoint_t *Front() {
|
||||
/* TODO : peek ahead and use compression strategies */
|
||||
_lastFront = _motProfTopBuffer.front();
|
||||
return (TALON_Control_6_MotProfAddTrajPoint_t *)&_lastFront;
|
||||
}
|
||||
void Pop() {
|
||||
/* TODO : pop multiple points if last front'd point was compressed. */
|
||||
_motProfTopBuffer.pop_front();
|
||||
}
|
||||
unsigned int GetNumTrajectories() { return _motProfTopBuffer.size(); }
|
||||
bool IsEmpty() { return _motProfTopBuffer.empty(); }
|
||||
|
||||
private:
|
||||
std::deque<TALON_Control_6_MotProfAddTrajPoint_huff0_t> _motProfTopBuffer;
|
||||
TALON_Control_6_MotProfAddTrajPoint_huff0_t _lastFront;
|
||||
};
|
||||
TrajectoryBuffer _motProfTopBuffer;
|
||||
/**
|
||||
* To keep buffers from getting out of control, place a cap on the top level
|
||||
* buffer. Calling application
|
||||
* can stream addition points as they are fed to Talon.
|
||||
* Approx memory footprint is this capacity X 8 bytes.
|
||||
*/
|
||||
static const int kMotionProfileTopBufferCapacity = 2048;
|
||||
/**
|
||||
* Flow control for streaming trajectories.
|
||||
*/
|
||||
int32_t _motProfFlowControl = -1;
|
||||
/**
|
||||
* Since we may need the MP pts to be emptied into Talon in the background
|
||||
* make sure the buffering is thread-safe.
|
||||
*/
|
||||
std::mutex _mutMotProf;
|
||||
/**
|
||||
* Send a one shot frame to set an arbitrary signal.
|
||||
* Most signals are in the control frame so avoid using this API unless you
|
||||
* have to.
|
||||
* Use this api for...
|
||||
* -A motor controller profile signal eProfileParam_XXXs. These are backed up
|
||||
* in flash. If you are gain-scheduling then call this periodically.
|
||||
* -Default brake and limit switch signals... eOnBoot_XXXs. Avoid doing this,
|
||||
* use the override signals in the control frame.
|
||||
* Talon will automatically send a PARAM_RESPONSE after the set, so
|
||||
* GetParamResponse will catch the latest value after a couple ms.
|
||||
*/
|
||||
CTR_Code SetParamRaw(uint32_t paramEnum, int32_t rawBits);
|
||||
/**
|
||||
* Checks cached CAN frames and updating solicited signals.
|
||||
*/
|
||||
CTR_Code GetParamResponseRaw(uint32_t paramEnum, int32_t &rawBits);
|
||||
|
||||
public:
|
||||
// default control update rate is 10ms.
|
||||
static const int kDefaultControlPeriodMs = 10;
|
||||
// default enable update rate is 50ms (when using the new control5 frame).
|
||||
static const int kDefaultEnablePeriodMs = 50;
|
||||
// Default update rate for motion profile control 6. This only takes effect
|
||||
// when calling uses MP functions.
|
||||
static const int kDefaultControl6PeriodMs = 10;
|
||||
explicit CanTalonSRX(int deviceNumber = 0,
|
||||
int controlPeriodMs = kDefaultControlPeriodMs,
|
||||
int enablePeriodMs = kDefaultEnablePeriodMs);
|
||||
~CanTalonSRX();
|
||||
void Set(double value);
|
||||
/* mode select enumerations */
|
||||
// Demand is 11bit signed duty cycle [-1023,1023].
|
||||
static const int kMode_DutyCycle = 0;
|
||||
// Position PIDF.
|
||||
static const int kMode_PositionCloseLoop = 1;
|
||||
// Velocity PIDF.
|
||||
static const int kMode_VelocityCloseLoop = 2;
|
||||
// Current close loop - not done.
|
||||
static const int kMode_CurrentCloseLoop = 3;
|
||||
// Voltage Compensation Mode - not done. Demand is fixed pt target 8.8 volts.
|
||||
static const int kMode_VoltCompen = 4;
|
||||
// Demand is the 6 bit Device ID of the 'master' TALON SRX.
|
||||
static const int kMode_SlaveFollower = 5;
|
||||
// Demand is '0' (Disabled), '1' (Enabled), or '2' (Hold).
|
||||
static const int kMode_MotionProfile = 6;
|
||||
// Zero the output (honors brake/coast) regardless of demand.
|
||||
// Might be useful if we need to change modes but can't atomically
|
||||
// change all the signals we want in between.
|
||||
static const int kMode_NoDrive = 15;
|
||||
/* limit switch enumerations */
|
||||
static const int kLimitSwitchOverride_UseDefaultsFromFlash = 1;
|
||||
static const int kLimitSwitchOverride_DisableFwd_DisableRev = 4;
|
||||
static const int kLimitSwitchOverride_DisableFwd_EnableRev = 5;
|
||||
static const int kLimitSwitchOverride_EnableFwd_DisableRev = 6;
|
||||
static const int kLimitSwitchOverride_EnableFwd_EnableRev = 7;
|
||||
/* brake override enumerations */
|
||||
static const int kBrakeOverride_UseDefaultsFromFlash = 0;
|
||||
static const int kBrakeOverride_OverrideCoast = 1;
|
||||
static const int kBrakeOverride_OverrideBrake = 2;
|
||||
/* feedback device enumerations */
|
||||
static const int kFeedbackDev_DigitalQuadEnc = 0;
|
||||
static const int kFeedbackDev_AnalogPot = 2;
|
||||
static const int kFeedbackDev_AnalogEncoder = 3;
|
||||
static const int kFeedbackDev_CountEveryRisingEdge = 4;
|
||||
static const int kFeedbackDev_CountEveryFallingEdge = 5;
|
||||
static const int kFeedbackDev_PosIsPulseWidth = 8;
|
||||
/* ProfileSlotSelect enumerations*/
|
||||
static const int kProfileSlotSelect_Slot0 = 0;
|
||||
static const int kProfileSlotSelect_Slot1 = 1;
|
||||
/* status frame rate types */
|
||||
static const int kStatusFrame_General = 0;
|
||||
static const int kStatusFrame_Feedback = 1;
|
||||
static const int kStatusFrame_Encoder = 2;
|
||||
static const int kStatusFrame_AnalogTempVbat = 3;
|
||||
static const int kStatusFrame_PulseWidthMeas = 4;
|
||||
static const int kStatusFrame_MotionProfile = 5;
|
||||
/* Motion Profile status bits */
|
||||
static const int kMotionProfileFlag_ActTraj_IsValid = 0x1;
|
||||
static const int kMotionProfileFlag_HasUnderrun = 0x2;
|
||||
static const int kMotionProfileFlag_IsUnderrun = 0x4;
|
||||
static const int kMotionProfileFlag_ActTraj_IsLast = 0x8;
|
||||
static const int kMotionProfileFlag_ActTraj_VelOnly = 0x10;
|
||||
/* Motion Profile Set Output */
|
||||
// Motor output is neutral, Motion Profile Executer is not running.
|
||||
static const int kMotionProf_Disabled = 0;
|
||||
// Motor output is updated from Motion Profile Executer, MPE will
|
||||
// process the buffered points.
|
||||
static const int kMotionProf_Enable = 1;
|
||||
// Motor output is updated from Motion Profile Executer, MPE will
|
||||
// stay processing current trajectory point.
|
||||
static const int kMotionProf_Hold = 2;
|
||||
/**
|
||||
* Signal enumeration for generic signal access.
|
||||
* Although every signal is enumerated, only use this for traffic that must
|
||||
* be solicited.
|
||||
* Use the auto generated getters/setters at bottom of this header as much as
|
||||
* possible.
|
||||
*/
|
||||
enum param_t {
|
||||
eProfileParamSlot0_P = 1,
|
||||
eProfileParamSlot0_I = 2,
|
||||
eProfileParamSlot0_D = 3,
|
||||
eProfileParamSlot0_F = 4,
|
||||
eProfileParamSlot0_IZone = 5,
|
||||
eProfileParamSlot0_CloseLoopRampRate = 6,
|
||||
eProfileParamSlot1_P = 11,
|
||||
eProfileParamSlot1_I = 12,
|
||||
eProfileParamSlot1_D = 13,
|
||||
eProfileParamSlot1_F = 14,
|
||||
eProfileParamSlot1_IZone = 15,
|
||||
eProfileParamSlot1_CloseLoopRampRate = 16,
|
||||
eProfileParamSoftLimitForThreshold = 21,
|
||||
eProfileParamSoftLimitRevThreshold = 22,
|
||||
eProfileParamSoftLimitForEnable = 23,
|
||||
eProfileParamSoftLimitRevEnable = 24,
|
||||
eOnBoot_BrakeMode = 31,
|
||||
eOnBoot_LimitSwitch_Forward_NormallyClosed = 32,
|
||||
eOnBoot_LimitSwitch_Reverse_NormallyClosed = 33,
|
||||
eOnBoot_LimitSwitch_Forward_Disable = 34,
|
||||
eOnBoot_LimitSwitch_Reverse_Disable = 35,
|
||||
eFault_OverTemp = 41,
|
||||
eFault_UnderVoltage = 42,
|
||||
eFault_ForLim = 43,
|
||||
eFault_RevLim = 44,
|
||||
eFault_HardwareFailure = 45,
|
||||
eFault_ForSoftLim = 46,
|
||||
eFault_RevSoftLim = 47,
|
||||
eStckyFault_OverTemp = 48,
|
||||
eStckyFault_UnderVoltage = 49,
|
||||
eStckyFault_ForLim = 50,
|
||||
eStckyFault_RevLim = 51,
|
||||
eStckyFault_ForSoftLim = 52,
|
||||
eStckyFault_RevSoftLim = 53,
|
||||
eAppliedThrottle = 61,
|
||||
eCloseLoopErr = 62,
|
||||
eFeedbackDeviceSelect = 63,
|
||||
eRevMotDuringCloseLoopEn = 64,
|
||||
eModeSelect = 65,
|
||||
eProfileSlotSelect = 66,
|
||||
eRampThrottle = 67,
|
||||
eRevFeedbackSensor = 68,
|
||||
eLimitSwitchEn = 69,
|
||||
eLimitSwitchClosedFor = 70,
|
||||
eLimitSwitchClosedRev = 71,
|
||||
eSensorPosition = 73,
|
||||
eSensorVelocity = 74,
|
||||
eCurrent = 75,
|
||||
eBrakeIsEnabled = 76,
|
||||
eEncPosition = 77,
|
||||
eEncVel = 78,
|
||||
eEncIndexRiseEvents = 79,
|
||||
eQuadApin = 80,
|
||||
eQuadBpin = 81,
|
||||
eQuadIdxpin = 82,
|
||||
eAnalogInWithOv = 83,
|
||||
eAnalogInVel = 84,
|
||||
eTemp = 85,
|
||||
eBatteryV = 86,
|
||||
eResetCount = 87,
|
||||
eResetFlags = 88,
|
||||
eFirmVers = 89,
|
||||
eSettingsChanged = 90,
|
||||
eQuadFilterEn = 91,
|
||||
ePidIaccum = 93,
|
||||
eStatus1FrameRate = 94, // TALON_Status_1_General_10ms_t
|
||||
eStatus2FrameRate = 95, // TALON_Status_2_Feedback_20ms_t
|
||||
eStatus3FrameRate = 96, // TALON_Status_3_Enc_100ms_t
|
||||
eStatus4FrameRate = 97, // TALON_Status_4_AinTempVbat_100ms_t
|
||||
eStatus6FrameRate = 98, // TALON_Status_6_Eol_t
|
||||
eStatus7FrameRate = 99, // TALON_Status_7_Debug_200ms_t
|
||||
eClearPositionOnIdx = 100,
|
||||
// reserved,
|
||||
// reserved,
|
||||
// reserved,
|
||||
ePeakPosOutput = 104,
|
||||
eNominalPosOutput = 105,
|
||||
ePeakNegOutput = 106,
|
||||
eNominalNegOutput = 107,
|
||||
eQuadIdxPolarity = 108,
|
||||
eStatus8FrameRate = 109, // TALON_Status_8_PulseWid_100ms_t
|
||||
eAllowPosOverflow = 110,
|
||||
eProfileParamSlot0_AllowableClosedLoopErr = 111,
|
||||
eNumberPotTurns = 112,
|
||||
eNumberEncoderCPR = 113,
|
||||
ePwdPosition = 114,
|
||||
eAinPosition = 115,
|
||||
eProfileParamVcompRate = 116,
|
||||
eProfileParamSlot1_AllowableClosedLoopErr = 117,
|
||||
eStatus9FrameRate = 118, // TALON_Status_9_MotProfBuffer_100ms_t
|
||||
eMotionProfileHasUnderrunErr = 119,
|
||||
eReserved120 = 120,
|
||||
eLegacyControlMode = 121,
|
||||
};
|
||||
//---- setters and getters that use the solicated param request/response ---//
|
||||
/**
|
||||
* Send a one shot frame to set an arbitrary signal.
|
||||
* Most signals are in the control frame so avoid using this API unless you
|
||||
* have to.
|
||||
* Use this api for...
|
||||
* -A motor controller profile signal eProfileParam_XXXs. These are backed
|
||||
* up in flash. If you are gain-scheduling then call this periodically.
|
||||
* -Default brake and limit switch signals... eOnBoot_XXXs. Avoid doing
|
||||
* this, use the override signals in the control frame.
|
||||
* Talon will automatically send a PARAM_RESPONSE after the set, so
|
||||
* GetParamResponse will catch the latest value after a couple ms.
|
||||
*/
|
||||
CTR_Code SetParam(param_t paramEnum, double value);
|
||||
/**
|
||||
* Asks TALON to immedietely respond with signal value. This API is only used
|
||||
* for signals that are not sent periodically.
|
||||
* This can be useful for reading params that rarely change like Limit Switch
|
||||
* settings and PIDF values.
|
||||
* @param param to request.
|
||||
*/
|
||||
CTR_Code RequestParam(param_t paramEnum);
|
||||
CTR_Code GetParamResponse(param_t paramEnum, double &value);
|
||||
CTR_Code GetParamResponseInt32(param_t paramEnum, int &value);
|
||||
//----------- getters and setters that use param request/response ----------//
|
||||
/**
|
||||
* These signals are backed up in flash and will survive a power cycle.
|
||||
* If your application requires changing these values consider using both
|
||||
* slots and switch between slot0 <=> slot1.
|
||||
* If your application requires changing these signals frequently then it
|
||||
* makes sense to leverage this API.
|
||||
* Getters don't block, so it may require several calls to get the latest
|
||||
* value.
|
||||
*/
|
||||
CTR_Code SetPgain(unsigned slotIdx, double gain);
|
||||
CTR_Code SetIgain(unsigned slotIdx, double gain);
|
||||
CTR_Code SetDgain(unsigned slotIdx, double gain);
|
||||
CTR_Code SetFgain(unsigned slotIdx, double gain);
|
||||
CTR_Code SetIzone(unsigned slotIdx, int zone);
|
||||
CTR_Code SetCloseLoopRampRate(unsigned slotIdx, int closeLoopRampRate);
|
||||
CTR_Code SetVoltageCompensationRate(double voltagePerMs);
|
||||
CTR_Code SetSensorPosition(int pos);
|
||||
CTR_Code SetForwardSoftLimit(int forwardLimit);
|
||||
CTR_Code SetReverseSoftLimit(int reverseLimit);
|
||||
CTR_Code SetForwardSoftEnable(int enable);
|
||||
CTR_Code SetReverseSoftEnable(int enable);
|
||||
CTR_Code GetPgain(unsigned slotIdx, double &gain);
|
||||
CTR_Code GetIgain(unsigned slotIdx, double &gain);
|
||||
CTR_Code GetDgain(unsigned slotIdx, double &gain);
|
||||
CTR_Code GetFgain(unsigned slotIdx, double &gain);
|
||||
CTR_Code GetIzone(unsigned slotIdx, int &zone);
|
||||
CTR_Code GetCloseLoopRampRate(unsigned slotIdx, int &closeLoopRampRate);
|
||||
CTR_Code GetVoltageCompensationRate(double &voltagePerMs);
|
||||
CTR_Code GetForwardSoftLimit(int &forwardLimit);
|
||||
CTR_Code GetReverseSoftLimit(int &reverseLimit);
|
||||
CTR_Code GetForwardSoftEnable(int &enable);
|
||||
CTR_Code GetReverseSoftEnable(int &enable);
|
||||
CTR_Code GetPulseWidthRiseToFallUs(int ¶m);
|
||||
CTR_Code IsPulseWidthSensorPresent(int ¶m);
|
||||
CTR_Code SetModeSelect(int modeSelect, int demand);
|
||||
/**
|
||||
* Change the periodMs of a TALON's status frame. See kStatusFrame_* enums
|
||||
* for what's available.
|
||||
*/
|
||||
CTR_Code SetStatusFrameRate(unsigned frameEnum, unsigned periodMs);
|
||||
/**
|
||||
* Clear all sticky faults in TALON.
|
||||
*/
|
||||
CTR_Code ClearStickyFaults();
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void ChangeMotionControlFramePeriod(uint32_t periodMs);
|
||||
/**
|
||||
* Clear the buffered motion profile in both Talon RAM (bottom), and in the
|
||||
* API (top).
|
||||
*/
|
||||
void 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.
|
||||
*/
|
||||
uint32_t GetMotionProfileTopLevelBufferCount();
|
||||
/**
|
||||
* Retrieve just the buffer full 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. Otherwise just use
|
||||
* GetMotionProfileStatus.
|
||||
* @return number of trajectory points in the top buffer.
|
||||
*/
|
||||
bool IsMotionProfileTopLevelBufferFull();
|
||||
/**
|
||||
* 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
|
||||
* eventually 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.
|
||||
*/
|
||||
CTR_Code PushMotionProfileTrajectory(int targPos, int targVel,
|
||||
int profileSlotSelect, int timeDurMs,
|
||||
int velOnly, int isLastPoint,
|
||||
int zeroPos);
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void ProcessMotionProfileBuffer();
|
||||
/**
|
||||
* Retrieve all 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] flags bitfield for status bools. Starting with least
|
||||
* significant bit: IsValid, HasUnderrun, IsUnderrun, IsLast, VelOnly.
|
||||
*
|
||||
* IsValid set when MP executer is processing a trajectory point,
|
||||
* and that point's status is instrumented with IsLast,
|
||||
* VelOnly, targPos, targVel. However if MP executor is
|
||||
* not processing a trajectory point, then this flag is
|
||||
* false, and the instrumented signals will be zero.
|
||||
* HasUnderrun is set anytime the MP executer is ready to pop
|
||||
* another trajectory point from the Talon's RAM,
|
||||
* but the buffer is empty. It can only be cleared
|
||||
* by using SetParam(eMotionProfileHasUnderrunErr,0);
|
||||
* IsUnderrun is set when the MP executer is ready for another
|
||||
* point, but the buffer is empty, and cleared when
|
||||
* the MP executer does not need another point.
|
||||
* HasUnderrun shadows this registor when this
|
||||
* register gets set, however HasUnderrun stays
|
||||
* asserted until application has process it, and
|
||||
* IsUnderrun auto-clears when the condition is
|
||||
* resolved.
|
||||
* IsLast is set/cleared based on the MP executer's current
|
||||
* trajectory point's IsLast value. This assumes
|
||||
* IsLast was set when PushMotionProfileTrajectory
|
||||
* was used to insert the currently processed trajectory
|
||||
* point.
|
||||
* VelOnly is set/cleared based on the MP executer's current
|
||||
* trajectory point's VelOnly value.
|
||||
*
|
||||
* @param [out] profileSlotSelect The currently processed trajectory point's
|
||||
* selected slot. This can differ in the currently selected slot used
|
||||
* for Position and Velocity servo modes.
|
||||
* @param [out] targPos The currently processed trajectory point's position
|
||||
* in native units. This param is zero if IsValid is zero.
|
||||
* @param [out] targVel The currently processed trajectory point's velocity
|
||||
* in native units. This param is zero if IsValid is zero.
|
||||
* @param [out] topBufferRem The remaining number of points in the top level
|
||||
* buffer.
|
||||
* @param [out] topBufferCnt The number of points in the top level buffer to
|
||||
* be sent to Talon.
|
||||
* @param [out] btmBufferCnt The number of points in the bottom level buffer
|
||||
* inside Talon.
|
||||
* @return CTR error code
|
||||
*/
|
||||
CTR_Code GetMotionProfileStatus(uint32_t &flags, uint32_t &profileSlotSelect,
|
||||
int32_t &targPos, int32_t &targVel,
|
||||
uint32_t &topBufferRemaining,
|
||||
uint32_t &topBufferCnt,
|
||||
uint32_t &btmBufferCnt,
|
||||
uint32_t &outputEnable);
|
||||
//------------------------ auto generated ------------------------------------//
|
||||
/* This API is optimal since it uses the fire-and-forget CAN interface.
|
||||
* These signals should cover the majority of all use cases.
|
||||
*/
|
||||
CTR_Code GetFault_OverTemp(int ¶m);
|
||||
CTR_Code GetFault_UnderVoltage(int ¶m);
|
||||
CTR_Code GetFault_ForLim(int ¶m);
|
||||
CTR_Code GetFault_RevLim(int ¶m);
|
||||
CTR_Code GetFault_HardwareFailure(int ¶m);
|
||||
CTR_Code GetFault_ForSoftLim(int ¶m);
|
||||
CTR_Code GetFault_RevSoftLim(int ¶m);
|
||||
CTR_Code GetStckyFault_OverTemp(int ¶m);
|
||||
CTR_Code GetStckyFault_UnderVoltage(int ¶m);
|
||||
CTR_Code GetStckyFault_ForLim(int ¶m);
|
||||
CTR_Code GetStckyFault_RevLim(int ¶m);
|
||||
CTR_Code GetStckyFault_ForSoftLim(int ¶m);
|
||||
CTR_Code GetStckyFault_RevSoftLim(int ¶m);
|
||||
CTR_Code GetAppliedThrottle(int ¶m);
|
||||
CTR_Code GetCloseLoopErr(int ¶m);
|
||||
CTR_Code GetFeedbackDeviceSelect(int ¶m);
|
||||
CTR_Code GetModeSelect(int ¶m);
|
||||
CTR_Code GetLimitSwitchEn(int ¶m);
|
||||
CTR_Code GetLimitSwitchClosedFor(int ¶m);
|
||||
CTR_Code GetLimitSwitchClosedRev(int ¶m);
|
||||
CTR_Code GetSensorPosition(int ¶m);
|
||||
CTR_Code GetSensorVelocity(int ¶m);
|
||||
CTR_Code GetCurrent(double ¶m);
|
||||
CTR_Code GetBrakeIsEnabled(int ¶m);
|
||||
CTR_Code GetEncPosition(int ¶m);
|
||||
CTR_Code GetEncVel(int ¶m);
|
||||
CTR_Code GetEncIndexRiseEvents(int ¶m);
|
||||
CTR_Code GetQuadApin(int ¶m);
|
||||
CTR_Code GetQuadBpin(int ¶m);
|
||||
CTR_Code GetQuadIdxpin(int ¶m);
|
||||
CTR_Code GetAnalogInWithOv(int ¶m);
|
||||
CTR_Code GetAnalogInVel(int ¶m);
|
||||
CTR_Code GetTemp(double ¶m);
|
||||
CTR_Code GetBatteryV(double ¶m);
|
||||
CTR_Code GetResetCount(int ¶m);
|
||||
CTR_Code GetResetFlags(int ¶m);
|
||||
CTR_Code GetFirmVers(int ¶m);
|
||||
CTR_Code GetPulseWidthPosition(int ¶m);
|
||||
CTR_Code GetPulseWidthVelocity(int ¶m);
|
||||
CTR_Code GetPulseWidthRiseToRiseUs(int ¶m);
|
||||
CTR_Code GetActTraj_IsValid(int ¶m);
|
||||
CTR_Code GetActTraj_ProfileSlotSelect(int ¶m);
|
||||
CTR_Code GetActTraj_VelOnly(int ¶m);
|
||||
CTR_Code GetActTraj_IsLast(int ¶m);
|
||||
CTR_Code GetOutputType(int ¶m);
|
||||
CTR_Code GetHasUnderrun(int ¶m);
|
||||
CTR_Code GetIsUnderrun(int ¶m);
|
||||
CTR_Code GetNextID(int ¶m);
|
||||
CTR_Code GetBufferIsFull(int ¶m);
|
||||
CTR_Code GetCount(int ¶m);
|
||||
CTR_Code GetActTraj_Velocity(int ¶m);
|
||||
CTR_Code GetActTraj_Position(int ¶m);
|
||||
CTR_Code SetDemand(int param);
|
||||
CTR_Code SetOverrideLimitSwitchEn(int param);
|
||||
CTR_Code SetFeedbackDeviceSelect(int param);
|
||||
CTR_Code SetRevMotDuringCloseLoopEn(int param);
|
||||
CTR_Code SetOverrideBrakeType(int param);
|
||||
CTR_Code SetModeSelect(int param);
|
||||
CTR_Code SetProfileSlotSelect(int param);
|
||||
CTR_Code SetRampThrottle(int param);
|
||||
CTR_Code SetRevFeedbackSensor(int param);
|
||||
};
|
||||
extern "C" {
|
||||
void *c_TalonSRX_Create3(int deviceNumber, int controlPeriodMs, int enablePeriodMs);
|
||||
void *c_TalonSRX_Create2(int deviceNumber, int controlPeriodMs);
|
||||
void *c_TalonSRX_Create1(int deviceNumber);
|
||||
void c_TalonSRX_Destroy(void *handle);
|
||||
void c_TalonSRX_Set(void *handle, double value);
|
||||
CTR_Code c_TalonSRX_SetParam(void *handle, int paramEnum, double value);
|
||||
CTR_Code c_TalonSRX_RequestParam(void *handle, int paramEnum);
|
||||
CTR_Code c_TalonSRX_GetParamResponse(void *handle, int paramEnum, double *value);
|
||||
CTR_Code c_TalonSRX_GetParamResponseInt32(void *handle, int paramEnum, int *value);
|
||||
CTR_Code c_TalonSRX_SetPgain(void *handle, int slotIdx, double gain);
|
||||
CTR_Code c_TalonSRX_SetIgain(void *handle, int slotIdx, double gain);
|
||||
CTR_Code c_TalonSRX_SetDgain(void *handle, int slotIdx, double gain);
|
||||
CTR_Code c_TalonSRX_SetFgain(void *handle, int slotIdx, double gain);
|
||||
CTR_Code c_TalonSRX_SetIzone(void *handle, int slotIdx, int zone);
|
||||
CTR_Code c_TalonSRX_SetCloseLoopRampRate(void *handle, int slotIdx, int closeLoopRampRate);
|
||||
CTR_Code c_TalonSRX_SetVoltageCompensationRate(void *handle, double voltagePerMs);
|
||||
CTR_Code c_TalonSRX_SetSensorPosition(void *handle, int pos);
|
||||
CTR_Code c_TalonSRX_SetForwardSoftLimit(void *handle, int forwardLimit);
|
||||
CTR_Code c_TalonSRX_SetReverseSoftLimit(void *handle, int reverseLimit);
|
||||
CTR_Code c_TalonSRX_SetForwardSoftEnable(void *handle, int enable);
|
||||
CTR_Code c_TalonSRX_SetReverseSoftEnable(void *handle, int enable);
|
||||
CTR_Code c_TalonSRX_GetPgain(void *handle, int slotIdx, double *gain);
|
||||
CTR_Code c_TalonSRX_GetIgain(void *handle, int slotIdx, double *gain);
|
||||
CTR_Code c_TalonSRX_GetDgain(void *handle, int slotIdx, double *gain);
|
||||
CTR_Code c_TalonSRX_GetFgain(void *handle, int slotIdx, double *gain);
|
||||
CTR_Code c_TalonSRX_GetIzone(void *handle, int slotIdx, int *zone);
|
||||
CTR_Code c_TalonSRX_GetCloseLoopRampRate(void *handle, int slotIdx, int *closeLoopRampRate);
|
||||
CTR_Code c_TalonSRX_GetVoltageCompensationRate(void *handle, double *voltagePerMs);
|
||||
CTR_Code c_TalonSRX_GetForwardSoftLimit(void *handle, int *forwardLimit);
|
||||
CTR_Code c_TalonSRX_GetReverseSoftLimit(void *handle, int *reverseLimit);
|
||||
CTR_Code c_TalonSRX_GetForwardSoftEnable(void *handle, int *enable);
|
||||
CTR_Code c_TalonSRX_GetReverseSoftEnable(void *handle, int *enable);
|
||||
CTR_Code c_TalonSRX_GetPulseWidthRiseToFallUs(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_IsPulseWidthSensorPresent(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_SetModeSelect2(void *handle, int modeSelect, int demand);
|
||||
CTR_Code c_TalonSRX_SetStatusFrameRate(void *handle, int frameEnum, int periodMs);
|
||||
CTR_Code c_TalonSRX_ClearStickyFaults(void *handle);
|
||||
void c_TalonSRX_ChangeMotionControlFramePeriod(void *handle, int periodMs);
|
||||
void c_TalonSRX_ClearMotionProfileTrajectories(void *handle);
|
||||
int c_TalonSRX_GetMotionProfileTopLevelBufferCount(void *handle);
|
||||
int c_TalonSRX_IsMotionProfileTopLevelBufferFull(void *handle);
|
||||
CTR_Code c_TalonSRX_PushMotionProfileTrajectory(void *handle, int targPos, int targVel, int profileSlotSelect, int timeDurMs, int velOnly, int isLastPoint, int zeroPos);
|
||||
void c_TalonSRX_ProcessMotionProfileBuffer(void *handle);
|
||||
CTR_Code c_TalonSRX_GetMotionProfileStatus(void *handle, int *flags, int *profileSlotSelect, int *targPos, int *targVel, int *topBufferRemaining, int *topBufferCnt, int *btmBufferCnt, int *outputEnable);
|
||||
CTR_Code c_TalonSRX_GetFault_OverTemp(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_UnderVoltage(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_ForLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_RevLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_HardwareFailure(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_ForSoftLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFault_RevSoftLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_OverTemp(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_UnderVoltage(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_ForLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_RevLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_ForSoftLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetStckyFault_RevSoftLim(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetAppliedThrottle(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetCloseLoopErr(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFeedbackDeviceSelect(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetModeSelect(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetLimitSwitchEn(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetLimitSwitchClosedFor(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetLimitSwitchClosedRev(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetSensorPosition(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetSensorVelocity(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetCurrent(void *handle, double *param);
|
||||
CTR_Code c_TalonSRX_GetBrakeIsEnabled(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetEncPosition(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetEncVel(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetEncIndexRiseEvents(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetQuadApin(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetQuadBpin(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetQuadIdxpin(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetAnalogInWithOv(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetAnalogInVel(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetTemp(void *handle, double *param);
|
||||
CTR_Code c_TalonSRX_GetBatteryV(void *handle, double *param);
|
||||
CTR_Code c_TalonSRX_GetResetCount(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetResetFlags(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetFirmVers(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetPulseWidthPosition(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetPulseWidthVelocity(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetPulseWidthRiseToRiseUs(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_IsValid(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_ProfileSlotSelect(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_VelOnly(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_IsLast(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetOutputType(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetHasUnderrun(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetIsUnderrun(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetNextID(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetBufferIsFull(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetCount(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_Velocity(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_GetActTraj_Position(void *handle, int *param);
|
||||
CTR_Code c_TalonSRX_SetDemand(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetOverrideLimitSwitchEn(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetFeedbackDeviceSelect(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetRevMotDuringCloseLoopEn(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetOverrideBrakeType(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetModeSelect(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetProfileSlotSelect(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetRampThrottle(void *handle, int param);
|
||||
CTR_Code c_TalonSRX_SetRevFeedbackSensor(void *handle, int param);
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,583 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "CANSpeedController.h"
|
||||
#include "HAL/CanTalonSRX.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "MotorSafetyHelper.h"
|
||||
#include "PIDInterface.h"
|
||||
#include "PIDOutput.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SafePWM.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
/**
|
||||
* CTRE Talon SRX Speed Controller with CAN Control
|
||||
*/
|
||||
class CANTalon : public MotorSafety,
|
||||
public CANSpeedController,
|
||||
public ErrorBase,
|
||||
public LiveWindowSendable,
|
||||
public ITableListener,
|
||||
public PIDSource,
|
||||
public PIDInterface {
|
||||
public:
|
||||
enum FeedbackDevice {
|
||||
QuadEncoder = 0,
|
||||
AnalogPot = 2,
|
||||
AnalogEncoder = 3,
|
||||
EncRising = 4,
|
||||
EncFalling = 5,
|
||||
CtreMagEncoder_Relative = 6, //!< Cross The Road Electronics Magnetic
|
||||
//! Encoder in Absolute/PulseWidth Mode
|
||||
CtreMagEncoder_Absolute = 7, //!< Cross The Road Electronics Magnetic
|
||||
//! Encoder in Relative/Quadrature Mode
|
||||
PulseWidth = 8,
|
||||
};
|
||||
/**
|
||||
* Depending on the sensor type, Talon can determine if sensor is plugged in
|
||||
* ot not.
|
||||
*/
|
||||
enum FeedbackDeviceStatus {
|
||||
FeedbackStatusUnknown = 0, //!< Sensor status could not be determined. Not
|
||||
//! all sensors can do this.
|
||||
FeedbackStatusPresent = 1, //!< Sensor is present and working okay.
|
||||
FeedbackStatusNotPresent =
|
||||
2, //!< Sensor is not present, not plugged in, not powered, etc...
|
||||
};
|
||||
enum StatusFrameRate {
|
||||
StatusFrameRateGeneral = 0,
|
||||
StatusFrameRateFeedback = 1,
|
||||
StatusFrameRateQuadEncoder = 2,
|
||||
StatusFrameRateAnalogTempVbat = 3,
|
||||
StatusFrameRatePulseWidthMeas = 4,
|
||||
};
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
enum SetValueMotionProfile {
|
||||
SetValueMotionProfileDisable = 0,
|
||||
SetValueMotionProfileEnable = 1,
|
||||
SetValueMotionProfileHold = 2,
|
||||
};
|
||||
/**
|
||||
* Motion Profile Trajectory Point
|
||||
* This is simply a data transer object.
|
||||
*/
|
||||
struct TrajectoryPoint {
|
||||
double position; //!< The position to servo to.
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
bool 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.
|
||||
*/
|
||||
bool 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.
|
||||
*/
|
||||
bool zeroPos;
|
||||
};
|
||||
/**
|
||||
* Motion Profile Status
|
||||
* This is simply a data transer object.
|
||||
*/
|
||||
struct 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.
|
||||
*/
|
||||
int topBufferRem;
|
||||
/**
|
||||
* The number of points in the top trajectory buffer.
|
||||
*/
|
||||
int topBufferCnt;
|
||||
/**
|
||||
* The number of points in the low level Talon buffer.
|
||||
*/
|
||||
int btmBufferCnt;
|
||||
/**
|
||||
* Set if isUnderrun ever gets set.
|
||||
* Only is cleared by clearMotionProfileHasUnderrun() to ensure
|
||||
* robot logic can react or instrument it.
|
||||
* @see clearMotionProfileHasUnderrun()
|
||||
*/
|
||||
bool 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.
|
||||
*/
|
||||
bool isUnderrun;
|
||||
/**
|
||||
* True if the active trajectory point has not empty, false otherwise.
|
||||
* The members in activePoint are only valid if this signal is set.
|
||||
*/
|
||||
bool activePointValid;
|
||||
/**
|
||||
* The number of points in the low level Talon buffer.
|
||||
*/
|
||||
TrajectoryPoint activePoint;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
SetValueMotionProfile outputEnable;
|
||||
};
|
||||
explicit CANTalon(int deviceNumber);
|
||||
explicit CANTalon(int deviceNumber, int controlPeriodMs);
|
||||
DEFAULT_MOVE_CONSTRUCTOR(CANTalon);
|
||||
virtual ~CANTalon();
|
||||
|
||||
// PIDOutput interface
|
||||
void PIDWrite(float output) override;
|
||||
|
||||
// PIDSource interface
|
||||
double PIDGet() override;
|
||||
|
||||
// MotorSafety interface
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
void SetSafetyEnabled(bool enabled) override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
void GetDescription(std::ostringstream& desc) const override;
|
||||
|
||||
// CANSpeedController interface
|
||||
float Get() const override;
|
||||
void Set(float value) override;
|
||||
void Reset() override;
|
||||
void SetSetpoint(float value) override;
|
||||
void Disable() override;
|
||||
virtual void EnableControl();
|
||||
void Enable() override;
|
||||
void SetP(double p) override;
|
||||
void SetI(double i) override;
|
||||
void SetD(double d) override;
|
||||
void SetF(double f);
|
||||
void SetIzone(int iz);
|
||||
void SetPID(double p, double i, double d) override;
|
||||
virtual void SetPID(double p, double i, double d, double f);
|
||||
double GetP() const override;
|
||||
double GetI() const override;
|
||||
double GetD() const override;
|
||||
virtual double GetF() const;
|
||||
bool IsModePID(CANSpeedController::ControlMode mode) const override;
|
||||
float GetBusVoltage() const override;
|
||||
float GetOutputVoltage() const override;
|
||||
float GetOutputCurrent() const override;
|
||||
float GetTemperature() const override;
|
||||
void SetPosition(double pos);
|
||||
double GetPosition() const override;
|
||||
double GetSpeed() const override;
|
||||
virtual int GetClosedLoopError() const;
|
||||
virtual void SetAllowableClosedLoopErr(int allowableCloseLoopError);
|
||||
virtual int GetAnalogIn() const;
|
||||
virtual void SetAnalogPosition(int newPosition);
|
||||
virtual int GetAnalogInRaw() const;
|
||||
virtual int GetAnalogInVel() const;
|
||||
virtual int GetEncPosition() const;
|
||||
virtual void SetEncPosition(int);
|
||||
virtual int GetEncVel() const;
|
||||
int GetPinStateQuadA() const;
|
||||
int GetPinStateQuadB() const;
|
||||
int GetPinStateQuadIdx() const;
|
||||
int IsFwdLimitSwitchClosed() const;
|
||||
int IsRevLimitSwitchClosed() const;
|
||||
int GetNumberOfQuadIdxRises() const;
|
||||
void SetNumberOfQuadIdxRises(int rises);
|
||||
virtual int GetPulseWidthPosition() const;
|
||||
virtual void SetPulseWidthPosition(int newpos);
|
||||
virtual int GetPulseWidthVelocity() const;
|
||||
virtual int GetPulseWidthRiseToFallUs() const;
|
||||
virtual int GetPulseWidthRiseToRiseUs() const;
|
||||
virtual FeedbackDeviceStatus IsSensorPresent(
|
||||
FeedbackDevice feedbackDevice) const;
|
||||
bool GetForwardLimitOK() const override;
|
||||
bool GetReverseLimitOK() const override;
|
||||
uint16_t GetFaults() const override;
|
||||
uint16_t GetStickyFaults() const;
|
||||
void ClearStickyFaults();
|
||||
void SetVoltageRampRate(double rampRate) override;
|
||||
virtual void SetVoltageCompensationRampRate(double rampRate);
|
||||
int GetFirmwareVersion() const override;
|
||||
void ConfigNeutralMode(NeutralMode mode) override;
|
||||
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
|
||||
void ConfigPotentiometerTurns(uint16_t turns) override;
|
||||
void ConfigSoftPositionLimits(double forwardLimitPosition,
|
||||
double reverseLimitPosition) override;
|
||||
void DisableSoftPositionLimits() override;
|
||||
void ConfigLimitMode(LimitMode mode) override;
|
||||
void ConfigForwardLimit(double forwardLimitPosition) override;
|
||||
void ConfigReverseLimit(double reverseLimitPosition) override;
|
||||
void ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn,
|
||||
bool bReverseLimitSwitchEn);
|
||||
void ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn);
|
||||
void ConfigReverseSoftLimitEnable(bool bReverseSoftLimitEn);
|
||||
/**
|
||||
* Change the fwd limit switch setting to normally open or closed.
|
||||
* Talon will disable momentarilly if the Talon's current setting
|
||||
* is dissimilar to the caller's requested setting.
|
||||
*
|
||||
* Since Talon saves setting to flash this should only affect
|
||||
* a given Talon initially during robot install.
|
||||
*
|
||||
* @param normallyOpen true for normally open. false for normally closed.
|
||||
*/
|
||||
void ConfigFwdLimitSwitchNormallyOpen(bool normallyOpen);
|
||||
/**
|
||||
* Change the rev limit switch setting to normally open or closed.
|
||||
* Talon will disable momentarilly if the Talon's current setting
|
||||
* is dissimilar to the caller's requested setting.
|
||||
*
|
||||
* Since Talon saves setting to flash this should only affect
|
||||
* a given Talon initially during robot install.
|
||||
*
|
||||
* @param normallyOpen true for normally open. false for normally closed.
|
||||
*/
|
||||
void ConfigRevLimitSwitchNormallyOpen(bool normallyOpen);
|
||||
void ConfigMaxOutputVoltage(double voltage) override;
|
||||
void ConfigPeakOutputVoltage(double forwardVoltage, double reverseVoltage);
|
||||
void ConfigNominalOutputVoltage(double forwardVoltage, double reverseVoltage);
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void EnableZeroSensorPositionOnIndex(bool enable, bool risingEdge);
|
||||
void ConfigSetParameter(int paramEnum, double value);
|
||||
bool GetParameter(int paramEnum, double& dvalue) const;
|
||||
|
||||
void ConfigFaultTime(float faultTime) override;
|
||||
virtual void SetControlMode(ControlMode mode);
|
||||
void SetFeedbackDevice(FeedbackDevice device);
|
||||
void SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs);
|
||||
virtual ControlMode GetControlMode() const;
|
||||
void SetSensorDirection(bool reverseSensor);
|
||||
void SetClosedLoopOutputDirection(bool reverseOutput);
|
||||
void SetCloseLoopRampRate(double rampRate);
|
||||
void SelectProfileSlot(int slotIdx);
|
||||
int GetIzone() const;
|
||||
int GetIaccum() const;
|
||||
void ClearIaccum();
|
||||
int GetBrakeEnableDuringNeutral() const;
|
||||
|
||||
bool IsControlEnabled() const;
|
||||
bool IsEnabled() const override;
|
||||
double GetSetpoint() const override;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void ChangeMotionControlFramePeriod(int 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.
|
||||
*/
|
||||
void 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.
|
||||
*/
|
||||
int GetMotionProfileTopLevelBufferCount();
|
||||
|
||||
/**
|
||||
* Push another trajectory point into the top level buffer (which is emptied
|
||||
* into the Talon's bottom buffer as room allows).
|
||||
*
|
||||
* @param trajPt the trajectory point to insert into buffer.
|
||||
* @return true if trajectory point push ok. CTR_BufferFull if buffer is full
|
||||
* due to kMotionProfileTopBufferCapacity.
|
||||
*/
|
||||
bool PushMotionProfileTrajectory(const TrajectoryPoint& trajPt);
|
||||
|
||||
/**
|
||||
* @return true if api-level (top) buffer is full.
|
||||
*/
|
||||
bool 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.
|
||||
*/
|
||||
void ProcessMotionProfileBuffer();
|
||||
|
||||
/**
|
||||
* Retrieve all 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.
|
||||
*/
|
||||
void GetMotionProfileStatus(MotionProfileStatus& motionProfileStatus);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void ClearMotionProfileHasUnderrun();
|
||||
|
||||
// LiveWindow stuff.
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
// SpeedController overrides
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
private:
|
||||
// Values for various modes as is sent in the CAN packets for the Talon.
|
||||
enum TalonControlMode {
|
||||
kThrottle = 0,
|
||||
kFollowerMode = 5,
|
||||
kVoltageMode = 4,
|
||||
kPositionMode = 1,
|
||||
kSpeedMode = 2,
|
||||
kCurrentMode = 3,
|
||||
kMotionProfileMode = 6,
|
||||
kDisabled = 15
|
||||
};
|
||||
|
||||
int m_deviceNumber;
|
||||
std::unique_ptr<CanTalonSRX> m_impl;
|
||||
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
|
||||
int m_profile = 0; // Profile from CANTalon to use. Set to zero until we
|
||||
// can actually test this.
|
||||
|
||||
bool m_controlEnabled = true;
|
||||
bool m_stopped = false;
|
||||
ControlMode m_controlMode = kPercentVbus;
|
||||
TalonControlMode m_sendMode;
|
||||
|
||||
double m_setPoint = 0;
|
||||
/**
|
||||
* Encoder CPR, counts per rotations, also called codes per revoluion.
|
||||
* Default value of zero means the API behaves as it did during the 2015
|
||||
* season, each position unit is a single pulse and there are four pulses per
|
||||
* count (4X). Caller can use ConfigEncoderCodesPerRev to set the quadrature
|
||||
* encoder CPR.
|
||||
*/
|
||||
int m_codesPerRev = 0;
|
||||
/**
|
||||
* Number of turns per rotation. For example, a 10-turn pot spins ten full
|
||||
* rotations from a wiper voltage of zero to 3.3 volts. Therefore knowing
|
||||
* the number of turns a full voltage sweep represents is necessary for
|
||||
* calculating rotations and velocity. A default value of zero means the API
|
||||
* behaves as it did during the 2015 season, there are 1024 position units
|
||||
* from zero to 3.3V.
|
||||
*/
|
||||
int m_numPotTurns = 0;
|
||||
/**
|
||||
* Although the Talon handles feedback selection, caching the feedback
|
||||
* selection is helpful at the API level for scaling into rotations and RPM.
|
||||
*/
|
||||
FeedbackDevice m_feedbackDevice = QuadEncoder;
|
||||
|
||||
static constexpr int kDelayForSolicitedSignalsUs = 4000;
|
||||
/**
|
||||
* @param devToLookup FeedbackDevice to lookup the scalar for. Because Talon
|
||||
* allows multiple sensors to be attached simultaneously,
|
||||
* caller must specify which sensor to lookup.
|
||||
* @return The number of native Talon units per rotation of the selected
|
||||
* sensor. Zero if the necessary sensor information is not available.
|
||||
* @see ConfigEncoderCodesPerRev
|
||||
* @see ConfigPotentiometerTurns
|
||||
*/
|
||||
double GetNativeUnitsPerRotationScalar(FeedbackDevice devToLookup) const;
|
||||
/**
|
||||
* Fixup the sendMode so Set() serializes the correct demand value.
|
||||
* Also fills the modeSelecet in the control frame to disabled.
|
||||
* @param mode Control mode to ultimately enter once user calls Set().
|
||||
* @see Set()
|
||||
*/
|
||||
void ApplyControlMode(CANSpeedController::ControlMode mode);
|
||||
/**
|
||||
* @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) const;
|
||||
/**
|
||||
* @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) const;
|
||||
/**
|
||||
* @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) const;
|
||||
/**
|
||||
* @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, int nativeVel) const;
|
||||
|
||||
// LiveWindow stuff.
|
||||
std::shared_ptr<ITable> m_table;
|
||||
/**
|
||||
* Flips the output direction during open-loop modes like percent
|
||||
* voltage, or certain closed loop modes like speed/current mode.
|
||||
*/
|
||||
bool m_isInverted = false;
|
||||
|
||||
HasBeenMoved m_hasBeenMoved;
|
||||
};
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "Buttons/JoystickButton.h"
|
||||
#include "Buttons/NetworkButton.h"
|
||||
#include "CANJaguar.h"
|
||||
#include "CANTalon.h"
|
||||
#include "CameraServer.h"
|
||||
#include "Commands/Command.h"
|
||||
#include "Commands/CommandGroup.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CANTalon.h" // NOLINT(build/include_order)
|
||||
|
||||
#include "TestBench.h"
|
||||
#include "Timer.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
const int32_t deviceId = 0;
|
||||
|
||||
TEST(CANTalonTest, QuickTest) {
|
||||
double throttle = 0.1;
|
||||
CANTalon talon(deviceId);
|
||||
talon.SetControlMode(CANSpeedController::kPercentVbus);
|
||||
talon.EnableControl();
|
||||
talon.Set(throttle);
|
||||
Wait(0.25);
|
||||
EXPECT_NEAR(talon.Get(), throttle, 5e-3);
|
||||
talon.Set(-throttle);
|
||||
Wait(0.25);
|
||||
EXPECT_NEAR(talon.Get(), -throttle, 5e-3);
|
||||
|
||||
talon.Disable();
|
||||
Wait(0.1);
|
||||
EXPECT_FLOAT_EQ(talon.Get(), 0.0);
|
||||
}
|
||||
|
||||
TEST(CANTalonTest, SetGetPID) {
|
||||
// Tests that we can actually set and get PID values as intended.
|
||||
CANTalon talon(deviceId);
|
||||
double p = 0.05, i = 0.098, d = 1.23;
|
||||
talon.SetPID(p, i, d);
|
||||
// Wait(0.03);
|
||||
EXPECT_NEAR(p, talon.GetP(), 1e-5);
|
||||
EXPECT_NEAR(i, talon.GetI(), 1e-5);
|
||||
EXPECT_NEAR(d, talon.GetD(), 1e-5);
|
||||
// Test with new values in case the talon was already set to the previous
|
||||
// ones.
|
||||
p = 0.15;
|
||||
i = 0.198;
|
||||
d = 1.03;
|
||||
talon.SetPID(p, i, d);
|
||||
// Wait(0.03);
|
||||
EXPECT_NEAR(p, talon.GetP(), 1e-5);
|
||||
EXPECT_NEAR(i, talon.GetI(), 1e-5);
|
||||
EXPECT_NEAR(d, talon.GetD(), 1e-5);
|
||||
}
|
||||
|
||||
TEST(CANTalonTest, DISABLED_PositionModeWorks) {
|
||||
CANTalon talon(deviceId);
|
||||
talon.SetFeedbackDevice(CANTalon::AnalogPot);
|
||||
talon.SetControlMode(CANSpeedController::kPosition);
|
||||
Wait(0.1);
|
||||
double p = 2;
|
||||
double i = 0.00;
|
||||
double d = 0.00;
|
||||
Wait(0.2);
|
||||
talon.SetControlMode(CANSpeedController::kPosition);
|
||||
talon.SetFeedbackDevice(CANTalon::AnalogPot);
|
||||
talon.SetPID(p, i, d);
|
||||
Wait(0.2);
|
||||
talon.Set(100);
|
||||
Wait(100);
|
||||
talon.Disable();
|
||||
EXPECT_NEAR(talon.Get(), 500, 1000);
|
||||
}
|
||||
|
||||
TEST(CANTalonTest, GetFaults) {
|
||||
CANTalon talon(deviceId);
|
||||
EXPECT_EQ(talon.GetFaults(), 0);
|
||||
EXPECT_EQ(talon.GetStickyFaults(), 0);
|
||||
}
|
||||
@@ -163,7 +163,6 @@ task jniHeaders {
|
||||
args 'edu.wpi.first.wpilibj.hal.AccelerometerJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.AnalogJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.AnalogGyroJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.CanTalonJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.ConstantsJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.CounterJNI'
|
||||
args 'edu.wpi.first.wpilibj.hal.DigitalGlitchFilterJNI'
|
||||
|
||||
@@ -1,836 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_CanTalonJNI.h"
|
||||
|
||||
#include "HAL/CanTalonSRX.h"
|
||||
|
||||
#include "HALUtil.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
inline bool CheckCTRStatus(JNIEnv *env, CTR_Code status) {
|
||||
if (status != CTR_OKAY) ReportError(env, (int32_t)status, false);
|
||||
return status == CTR_OKAY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: new_CanTalonSRX
|
||||
* Signature: (III)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX__III
|
||||
(JNIEnv *env, jclass, jint deviceNumber, jint controlPeriodMs, jint enablePeriodMs)
|
||||
{
|
||||
return (jlong)(new CanTalonSRX((int)deviceNumber, (int)controlPeriodMs, (int)enablePeriodMs));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: new_CanTalonSRX
|
||||
* Signature: (II)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX__II
|
||||
(JNIEnv *env, jclass, jint deviceNumber, jint controlPeriodMs)
|
||||
{
|
||||
return (jlong)(new CanTalonSRX((int)deviceNumber, (int)controlPeriodMs));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: new_CanTalonSRX
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX__I
|
||||
(JNIEnv *env, jclass, jint deviceNumber)
|
||||
{
|
||||
return (jlong)(new CanTalonSRX((int)deviceNumber));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: new_CanTalonSRX
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX__
|
||||
(JNIEnv *env, jclass)
|
||||
{
|
||||
return (jlong)(new CanTalonSRX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: delete_CanTalonSRX
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1CanTalonSRX
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
delete (CanTalonSRX*)handle;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CanTalonJNI
|
||||
* Method: GetMotionProfileStatus
|
||||
* Signature: (JLedu/wpi/first/wpilibj/CANTalon;Ledu/wpi/first/wpilibj/CANTalon/MotionProfileStatus;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetMotionProfileStatus
|
||||
(JNIEnv *env, jclass, jlong handle, jobject canTalon, jobject motionProfileStatus)
|
||||
{
|
||||
static jmethodID setMotionProfileStatusFromJNI = nullptr;
|
||||
if (!setMotionProfileStatusFromJNI) {
|
||||
jclass cls = env->GetObjectClass(canTalon);
|
||||
setMotionProfileStatusFromJNI = env->GetMethodID(cls, "setMotionProfileStatusFromJNI", "(Ledu/wpi/first/wpilibj/CANTalon$MotionProfileStatus;IIIIIIII)V");
|
||||
if (!setMotionProfileStatusFromJNI) return;
|
||||
}
|
||||
|
||||
uint32_t flags;
|
||||
uint32_t profileSlotSelect;
|
||||
int32_t targPos;
|
||||
int32_t targVel;
|
||||
uint32_t topBufferRem;
|
||||
uint32_t topBufferCnt;
|
||||
uint32_t btmBufferCnt;
|
||||
uint32_t outputEnable;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetMotionProfileStatus(flags, profileSlotSelect, targPos, targVel, topBufferRem, topBufferCnt, btmBufferCnt, outputEnable);
|
||||
if (!CheckCTRStatus(env, status)) return;
|
||||
|
||||
env->CallVoidMethod(canTalon, setMotionProfileStatusFromJNI, motionProfileStatus, (jint)flags, (jint)profileSlotSelect, (jint)targPos, (jint)targVel, (jint)topBufferRem, (jint)topBufferCnt, (jint)btmBufferCnt, (jint)outputEnable);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_Set
|
||||
(JNIEnv *env, jclass, jlong handle, jdouble value)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->Set((double)value);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetParam
|
||||
(JNIEnv *env, jclass, jlong handle, jint paramEnum, jdouble value)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetParam((CanTalonSRX::param_t)paramEnum, (double)value);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_RequestParam
|
||||
(JNIEnv *env, jclass, jlong handle, jint paramEnum)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->RequestParam((CanTalonSRX::param_t)paramEnum);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetParamResponse
|
||||
(JNIEnv *env, jclass, jlong handle, jint paramEnum)
|
||||
{
|
||||
double value;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetParamResponse((CanTalonSRX::param_t)paramEnum, value);
|
||||
CheckCTRStatus(env, status);
|
||||
return value;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetParamResponseInt32
|
||||
(JNIEnv *env, jclass, jlong handle, jint paramEnum)
|
||||
{
|
||||
int value;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetParamResponseInt32((CanTalonSRX::param_t)paramEnum, value);
|
||||
CheckCTRStatus(env, status);
|
||||
return value;
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetPgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jdouble gain)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetPgain((unsigned)slotIdx, (double)gain);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetIgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jdouble gain)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetIgain((unsigned)slotIdx, (double)gain);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetDgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jdouble gain)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetDgain((unsigned)slotIdx, (double)gain);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetFgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jdouble gain)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetFgain((unsigned)slotIdx, (double)gain);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetIzone
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jint zone)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetIzone((unsigned)slotIdx, (int)zone);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetCloseLoopRampRate
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx, jint closeLoopRampRate)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetCloseLoopRampRate((unsigned)slotIdx, (int)closeLoopRampRate);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetVoltageCompensationRate
|
||||
(JNIEnv *env, jclass, jlong handle, jdouble voltagePerMs)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetVoltageCompensationRate((double)voltagePerMs);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetSensorPosition
|
||||
(JNIEnv *env, jclass, jlong handle, jint pos)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetSensorPosition((int)pos);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetForwardSoftLimit
|
||||
(JNIEnv *env, jclass, jlong handle, jint forwardLimit)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetForwardSoftLimit((int)forwardLimit);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetReverseSoftLimit
|
||||
(JNIEnv *env, jclass, jlong handle, jint reverseLimit)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetReverseSoftLimit((int)reverseLimit);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetForwardSoftEnable
|
||||
(JNIEnv *env, jclass, jlong handle, jint enable)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetForwardSoftEnable((int)enable);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetReverseSoftEnable
|
||||
(JNIEnv *env, jclass, jlong handle, jint enable)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetReverseSoftEnable((int)enable);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetPgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
double gain;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetPgain((unsigned)slotIdx, gain);
|
||||
CheckCTRStatus(env, status);
|
||||
return gain;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetIgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
double gain;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetIgain((unsigned)slotIdx, gain);
|
||||
CheckCTRStatus(env, status);
|
||||
return gain;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetDgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
double gain;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetDgain((unsigned)slotIdx, gain);
|
||||
CheckCTRStatus(env, status);
|
||||
return gain;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFgain
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
double gain;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFgain((unsigned)slotIdx, gain);
|
||||
CheckCTRStatus(env, status);
|
||||
return gain;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetIzone
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
int zone;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetIzone((unsigned)slotIdx, zone);
|
||||
CheckCTRStatus(env, status);
|
||||
return zone;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetCloseLoopRampRate
|
||||
(JNIEnv *env, jclass, jlong handle, jint slotIdx)
|
||||
{
|
||||
int closeLoopRampRate;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetCloseLoopRampRate((unsigned)slotIdx, closeLoopRampRate);
|
||||
CheckCTRStatus(env, status);
|
||||
return closeLoopRampRate;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetVoltageCompensationRate
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
double voltagePerMs;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetVoltageCompensationRate(voltagePerMs);
|
||||
CheckCTRStatus(env, status);
|
||||
return voltagePerMs;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetForwardSoftLimit
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int forwardLimit;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetForwardSoftLimit(forwardLimit);
|
||||
CheckCTRStatus(env, status);
|
||||
return forwardLimit;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetReverseSoftLimit
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int reverseLimit;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetReverseSoftLimit(reverseLimit);
|
||||
CheckCTRStatus(env, status);
|
||||
return reverseLimit;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetForwardSoftEnable
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int enable;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetForwardSoftEnable(enable);
|
||||
CheckCTRStatus(env, status);
|
||||
return enable;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetReverseSoftEnable
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int enable;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetReverseSoftEnable(enable);
|
||||
CheckCTRStatus(env, status);
|
||||
return enable;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetPulseWidthRiseToFallUs
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int param;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetPulseWidthRiseToFallUs(param);
|
||||
CheckCTRStatus(env, status);
|
||||
return param;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_IsPulseWidthSensorPresent
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
int param;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->IsPulseWidthSensorPresent(param);
|
||||
CheckCTRStatus(env, status);
|
||||
return param;
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetModeSelect2
|
||||
(JNIEnv *env, jclass, jlong handle, jint modeSelect, jint demand)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetModeSelect((int)modeSelect, (int)demand);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetStatusFrameRate
|
||||
(JNIEnv *env, jclass, jlong handle, jint frameEnum, jint periodMs)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetStatusFrameRate((unsigned)frameEnum, (unsigned)periodMs);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_ClearStickyFaults
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->ClearStickyFaults();
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_ChangeMotionControlFramePeriod
|
||||
(JNIEnv *env, jclass, jlong handle, jint periodMs)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->ChangeMotionControlFramePeriod((uint32_t)periodMs);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_ClearMotionProfileTrajectories
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->ClearMotionProfileTrajectories();
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetMotionProfileTopLevelBufferCount
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->GetMotionProfileTopLevelBufferCount();
|
||||
}
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_IsMotionProfileTopLevelBufferFull
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->IsMotionProfileTopLevelBufferFull();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_PushMotionProfileTrajectory
|
||||
(JNIEnv *env, jclass, jlong handle, jint targPos, jint targVel, jint profileSlotSelect, jint timeDurMs, jint velOnly, jint isLastPoint, jint zeroPos)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->PushMotionProfileTrajectory((int)targPos, (int)targVel, (int)profileSlotSelect, (int)timeDurMs, (int)velOnly, (int)isLastPoint, (int)zeroPos);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_ProcessMotionProfileBuffer
|
||||
(JNIEnv *env, jclass, jlong handle)
|
||||
{
|
||||
return ((CanTalonSRX*)handle)->ProcessMotionProfileBuffer();
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1OverTemp
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_OverTemp(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1UnderVoltage
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_UnderVoltage(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1ForLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_ForLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1RevLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_RevLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1HardwareFailure
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_HardwareFailure(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1ForSoftLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_ForSoftLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFault_1RevSoftLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFault_RevSoftLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1OverTemp
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_OverTemp(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1UnderVoltage
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_UnderVoltage(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1ForLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_ForLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1RevLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_RevLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1ForSoftLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_ForSoftLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetStckyFault_1RevSoftLim
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetStckyFault_RevSoftLim(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetAppliedThrottle
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetAppliedThrottle(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetCloseLoopErr
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetCloseLoopErr(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFeedbackDeviceSelect
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFeedbackDeviceSelect(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetModeSelect
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetModeSelect(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetLimitSwitchEn
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetLimitSwitchEn(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetLimitSwitchClosedFor
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetLimitSwitchClosedFor(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetLimitSwitchClosedRev
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetLimitSwitchClosedRev(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetSensorPosition
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetSensorPosition(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetSensorVelocity
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetSensorVelocity(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetCurrent
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
double retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetCurrent(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetBrakeIsEnabled
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetBrakeIsEnabled(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetEncPosition
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetEncPosition(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetEncVel
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetEncVel(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetEncIndexRiseEvents
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetEncIndexRiseEvents(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetQuadApin
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetQuadApin(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetQuadBpin
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetQuadBpin(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetQuadIdxpin
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetQuadIdxpin(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetAnalogInWithOv
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetAnalogInWithOv(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetAnalogInVel
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetAnalogInVel(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetTemp
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
double retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetTemp(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetBatteryV
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
double retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetBatteryV(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetResetCount
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetResetCount(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetResetFlags
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetResetFlags(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetFirmVers
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetFirmVers(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetPulseWidthPosition
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetPulseWidthPosition(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetPulseWidthVelocity
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetPulseWidthVelocity(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetPulseWidthRiseToRiseUs
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetPulseWidthRiseToRiseUs(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1IsValid
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_IsValid(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1ProfileSlotSelect
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_ProfileSlotSelect(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1VelOnly
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_VelOnly(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1IsLast
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_IsLast(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetOutputType
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetOutputType(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetHasUnderrun
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetHasUnderrun(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetIsUnderrun
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetIsUnderrun(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetNextID
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetNextID(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetBufferIsFull
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetBufferIsFull(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetCount
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetCount(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1Velocity
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_Velocity(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_GetActTraj_1Position
|
||||
(JNIEnv * env, jclass, jlong handle)
|
||||
{
|
||||
int retval;
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->GetActTraj_Position(retval);
|
||||
CheckCTRStatus(env, status);
|
||||
return retval;
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetDemand
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetDemand(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetOverrideLimitSwitchEn
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetOverrideLimitSwitchEn(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetFeedbackDeviceSelect
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetFeedbackDeviceSelect(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetRevMotDuringCloseLoopEn
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetRevMotDuringCloseLoopEn(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetOverrideBrakeType
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetOverrideBrakeType(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetModeSelect
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetModeSelect(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetProfileSlotSelect
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetProfileSlotSelect(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetRampThrottle
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetRampThrottle(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_SetRevFeedbackSensor
|
||||
(JNIEnv * env, jclass, jlong handle, jint param)
|
||||
{
|
||||
CTR_Code status = ((CanTalonSRX*)handle)->SetRevFeedbackSensor(param);
|
||||
CheckCTRStatus(env, status);
|
||||
}
|
||||
} // extern "C"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,343 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj.hal;
|
||||
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CanTalonJNI extends JNIWrapper {
|
||||
// Motion Profile status bits
|
||||
public static final int kMotionProfileFlag_ActTraj_IsValid = 0x1;
|
||||
public static final int kMotionProfileFlag_HasUnderrun = 0x2;
|
||||
public static final int kMotionProfileFlag_IsUnderrun = 0x4;
|
||||
public static final int kMotionProfileFlag_ActTraj_IsLast = 0x8;
|
||||
public static final int kMotionProfileFlag_ActTraj_VelOnly = 0x10;
|
||||
|
||||
/**
|
||||
* Signal enumeration for generic signal access. Although every signal is enumerated, only use
|
||||
* this for traffic that must be solicited. Use the auto generated getters/setters at bottom of
|
||||
* this header as much as possible.
|
||||
*/
|
||||
@SuppressWarnings("TypeName")
|
||||
public enum param_t {
|
||||
eProfileParamSlot0_P(1),
|
||||
eProfileParamSlot0_I(2),
|
||||
eProfileParamSlot0_D(3),
|
||||
eProfileParamSlot0_F(4),
|
||||
eProfileParamSlot0_IZone(5),
|
||||
eProfileParamSlot0_CloseLoopRampRate(6),
|
||||
eProfileParamSlot1_P(11),
|
||||
eProfileParamSlot1_I(12),
|
||||
eProfileParamSlot1_D(13),
|
||||
eProfileParamSlot1_F(14),
|
||||
eProfileParamSlot1_IZone(15),
|
||||
eProfileParamSlot1_CloseLoopRampRate(16),
|
||||
eProfileParamSoftLimitForThreshold(21),
|
||||
eProfileParamSoftLimitRevThreshold(22),
|
||||
eProfileParamSoftLimitForEnable(23),
|
||||
eProfileParamSoftLimitRevEnable(24),
|
||||
eOnBoot_BrakeMode(31),
|
||||
eOnBoot_LimitSwitch_Forward_NormallyClosed(32),
|
||||
eOnBoot_LimitSwitch_Reverse_NormallyClosed(33),
|
||||
eOnBoot_LimitSwitch_Forward_Disable(34),
|
||||
eOnBoot_LimitSwitch_Reverse_Disable(35),
|
||||
eFault_OverTemp(41),
|
||||
eFault_UnderVoltage(42),
|
||||
eFault_ForLim(43),
|
||||
eFault_RevLim(44),
|
||||
eFault_HardwareFailure(45),
|
||||
eFault_ForSoftLim(46),
|
||||
eFault_RevSoftLim(47),
|
||||
eStckyFault_OverTemp(48),
|
||||
eStckyFault_UnderVoltage(49),
|
||||
eStckyFault_ForLim(50),
|
||||
eStckyFault_RevLim(51),
|
||||
eStckyFault_ForSoftLim(52),
|
||||
eStckyFault_RevSoftLim(53),
|
||||
eAppliedThrottle(61),
|
||||
eCloseLoopErr(62),
|
||||
eFeedbackDeviceSelect(63),
|
||||
eRevMotDuringCloseLoopEn(64),
|
||||
eModeSelect(65),
|
||||
eProfileSlotSelect(66),
|
||||
eRampThrottle(67),
|
||||
eRevFeedbackSensor(68),
|
||||
eLimitSwitchEn(69),
|
||||
eLimitSwitchClosedFor(70),
|
||||
eLimitSwitchClosedRev(71),
|
||||
eSensorPosition(73),
|
||||
eSensorVelocity(74),
|
||||
eCurrent(75),
|
||||
eBrakeIsEnabled(76),
|
||||
eEncPosition(77),
|
||||
eEncVel(78),
|
||||
eEncIndexRiseEvents(79),
|
||||
eQuadApin(80),
|
||||
eQuadBpin(81),
|
||||
eQuadIdxpin(82),
|
||||
eAnalogInWithOv(83),
|
||||
eAnalogInVel(84),
|
||||
eTemp(85),
|
||||
eBatteryV(86),
|
||||
eResetCount(87),
|
||||
eResetFlags(88),
|
||||
eFirmVers(89),
|
||||
eSettingsChanged(90),
|
||||
eQuadFilterEn(91),
|
||||
ePidIaccum(93),
|
||||
eStatus1FrameRate(94), // TALON_Status_1_General_10ms_t
|
||||
eStatus2FrameRate(95), // TALON_Status_2_Feedback_20ms_t
|
||||
eStatus3FrameRate(96), // TALON_Status_3_Enc_100ms_t
|
||||
eStatus4FrameRate(97), // TALON_Status_4_AinTempVbat_100ms_t
|
||||
eStatus6FrameRate(98), // TALON_Status_6_Eol_t
|
||||
eStatus7FrameRate(99), // TALON_Status_7_Debug_200ms_t
|
||||
eClearPositionOnIdx(100),
|
||||
//reserved
|
||||
//reserved
|
||||
//reserved
|
||||
ePeakPosOutput(104),
|
||||
eNominalPosOutput(105),
|
||||
ePeakNegOutput(106),
|
||||
eNominalNegOutput(107),
|
||||
eQuadIdxPolarity(108),
|
||||
eStatus8FrameRate(109), // TALON_Status_8_PulseWid_100ms_t
|
||||
eAllowPosOverflow(110),
|
||||
eProfileParamSlot0_AllowableClosedLoopErr(111),
|
||||
eNumberPotTurns(112),
|
||||
eNumberEncoderCPR(113),
|
||||
ePwdPosition(114),
|
||||
eAinPosition(115),
|
||||
eProfileParamVcompRate(116),
|
||||
eProfileParamSlot1_AllowableClosedLoopErr(117),
|
||||
eStatus9FrameRate(118), // TALON_Status_9_MotProfBuffer_100ms_t
|
||||
eMotionProfileHasUnderrunErr(119),
|
||||
eReserved120(120),
|
||||
eLegacyControlMode(121);
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int value;
|
||||
|
||||
param_t(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static native long new_CanTalonSRX(int deviceNumber, int controlPeriodMs,
|
||||
int enablePeriodMs);
|
||||
|
||||
public static native long new_CanTalonSRX(int deviceNumber, int controlPeriodMs);
|
||||
|
||||
public static native long new_CanTalonSRX(int deviceNumber);
|
||||
|
||||
public static native long new_CanTalonSRX();
|
||||
|
||||
public static native void delete_CanTalonSRX(long handle);
|
||||
|
||||
public static native void GetMotionProfileStatus(long handle, Object canTalon,
|
||||
Object motionProfileStatus);
|
||||
|
||||
public static native void Set(long handle, double value);
|
||||
|
||||
public static native void SetParam(long handle, int paramEnum, double value);
|
||||
|
||||
public static native void RequestParam(long handle, int paramEnum);
|
||||
|
||||
public static native double GetParamResponse(long handle, int paramEnum);
|
||||
|
||||
public static native int GetParamResponseInt32(long handle, int paramEnum);
|
||||
|
||||
public static native void SetPgain(long handle, int slotIdx, double gain);
|
||||
|
||||
public static native void SetIgain(long handle, int slotIdx, double gain);
|
||||
|
||||
public static native void SetDgain(long handle, int slotIdx, double gain);
|
||||
|
||||
public static native void SetFgain(long handle, int slotIdx, double gain);
|
||||
|
||||
public static native void SetIzone(long handle, int slotIdx, int zone);
|
||||
|
||||
public static native void SetCloseLoopRampRate(long handle, int slotIdx, int closeLoopRampRate);
|
||||
|
||||
public static native void SetVoltageCompensationRate(long handle, double voltagePerMs);
|
||||
|
||||
public static native void SetSensorPosition(long handle, int pos);
|
||||
|
||||
public static native void SetForwardSoftLimit(long handle, int forwardLimit);
|
||||
|
||||
public static native void SetReverseSoftLimit(long handle, int reverseLimit);
|
||||
|
||||
public static native void SetForwardSoftEnable(long handle, int enable);
|
||||
|
||||
public static native void SetReverseSoftEnable(long handle, int enable);
|
||||
|
||||
public static native double GetPgain(long handle, int slotIdx);
|
||||
|
||||
public static native double GetIgain(long handle, int slotIdx);
|
||||
|
||||
public static native double GetDgain(long handle, int slotIdx);
|
||||
|
||||
public static native double GetFgain(long handle, int slotIdx);
|
||||
|
||||
public static native int GetIzone(long handle, int slotIdx);
|
||||
|
||||
public static native int GetCloseLoopRampRate(long handle, int slotIdx);
|
||||
|
||||
public static native double GetVoltageCompensationRate(long handle);
|
||||
|
||||
public static native int GetForwardSoftLimit(long handle);
|
||||
|
||||
public static native int GetReverseSoftLimit(long handle);
|
||||
|
||||
public static native int GetForwardSoftEnable(long handle);
|
||||
|
||||
public static native int GetReverseSoftEnable(long handle);
|
||||
|
||||
public static native int GetPulseWidthRiseToFallUs(long handle);
|
||||
|
||||
public static native int IsPulseWidthSensorPresent(long handle);
|
||||
|
||||
public static native void SetModeSelect2(long handle, int modeSelect, int demand);
|
||||
|
||||
public static native void SetStatusFrameRate(long handle, int frameEnum, int periodMs);
|
||||
|
||||
public static native void ClearStickyFaults(long handle);
|
||||
|
||||
public static native void ChangeMotionControlFramePeriod(long handle, int periodMs);
|
||||
|
||||
public static native void ClearMotionProfileTrajectories(long handle);
|
||||
|
||||
public static native int GetMotionProfileTopLevelBufferCount(long handle);
|
||||
|
||||
public static native boolean IsMotionProfileTopLevelBufferFull(long handle);
|
||||
|
||||
public static native void PushMotionProfileTrajectory(long handle, int targPos, int targVel,
|
||||
int profileSlotSelect, int timeDurMs,
|
||||
int velOnly, int isLastPoint, int zeroPos);
|
||||
|
||||
public static native void ProcessMotionProfileBuffer(long handle);
|
||||
|
||||
public static native int GetFault_OverTemp(long handle);
|
||||
|
||||
public static native int GetFault_UnderVoltage(long handle);
|
||||
|
||||
public static native int GetFault_ForLim(long handle);
|
||||
|
||||
public static native int GetFault_RevLim(long handle);
|
||||
|
||||
public static native int GetFault_HardwareFailure(long handle);
|
||||
|
||||
public static native int GetFault_ForSoftLim(long handle);
|
||||
|
||||
public static native int GetFault_RevSoftLim(long handle);
|
||||
|
||||
public static native int GetStckyFault_OverTemp(long handle);
|
||||
|
||||
public static native int GetStckyFault_UnderVoltage(long handle);
|
||||
|
||||
public static native int GetStckyFault_ForLim(long handle);
|
||||
|
||||
public static native int GetStckyFault_RevLim(long handle);
|
||||
|
||||
public static native int GetStckyFault_ForSoftLim(long handle);
|
||||
|
||||
public static native int GetStckyFault_RevSoftLim(long handle);
|
||||
|
||||
public static native int GetAppliedThrottle(long handle);
|
||||
|
||||
public static native int GetCloseLoopErr(long handle);
|
||||
|
||||
public static native int GetFeedbackDeviceSelect(long handle);
|
||||
|
||||
public static native int GetModeSelect(long handle);
|
||||
|
||||
public static native int GetLimitSwitchEn(long handle);
|
||||
|
||||
public static native int GetLimitSwitchClosedFor(long handle);
|
||||
|
||||
public static native int GetLimitSwitchClosedRev(long handle);
|
||||
|
||||
public static native int GetSensorPosition(long handle);
|
||||
|
||||
public static native int GetSensorVelocity(long handle);
|
||||
|
||||
public static native double GetCurrent(long handle);
|
||||
|
||||
public static native int GetBrakeIsEnabled(long handle);
|
||||
|
||||
public static native int GetEncPosition(long handle);
|
||||
|
||||
public static native int GetEncVel(long handle);
|
||||
|
||||
public static native int GetEncIndexRiseEvents(long handle);
|
||||
|
||||
public static native int GetQuadApin(long handle);
|
||||
|
||||
public static native int GetQuadBpin(long handle);
|
||||
|
||||
public static native int GetQuadIdxpin(long handle);
|
||||
|
||||
public static native int GetAnalogInWithOv(long handle);
|
||||
|
||||
public static native int GetAnalogInVel(long handle);
|
||||
|
||||
public static native double GetTemp(long handle);
|
||||
|
||||
public static native double GetBatteryV(long handle);
|
||||
|
||||
public static native int GetResetCount(long handle);
|
||||
|
||||
public static native int GetResetFlags(long handle);
|
||||
|
||||
public static native int GetFirmVers(long handle);
|
||||
|
||||
public static native int GetPulseWidthPosition(long handle);
|
||||
|
||||
public static native int GetPulseWidthVelocity(long handle);
|
||||
|
||||
public static native int GetPulseWidthRiseToRiseUs(long handle);
|
||||
|
||||
public static native int GetActTraj_IsValid(long handle);
|
||||
|
||||
public static native int GetActTraj_ProfileSlotSelect(long handle);
|
||||
|
||||
public static native int GetActTraj_VelOnly(long handle);
|
||||
|
||||
public static native int GetActTraj_IsLast(long handle);
|
||||
|
||||
public static native int GetOutputType(long handle);
|
||||
|
||||
public static native int GetHasUnderrun(long handle);
|
||||
|
||||
public static native int GetIsUnderrun(long handle);
|
||||
|
||||
public static native int GetNextID(long handle);
|
||||
|
||||
public static native int GetBufferIsFull(long handle);
|
||||
|
||||
public static native int GetCount(long handle);
|
||||
|
||||
public static native int GetActTraj_Velocity(long handle);
|
||||
|
||||
public static native int GetActTraj_Position(long handle);
|
||||
|
||||
public static native void SetDemand(long handle, int param);
|
||||
|
||||
public static native void SetOverrideLimitSwitchEn(long handle, int param);
|
||||
|
||||
public static native void SetFeedbackDeviceSelect(long handle, int param);
|
||||
|
||||
public static native void SetRevMotDuringCloseLoopEn(long handle, int param);
|
||||
|
||||
public static native void SetOverrideBrakeType(long handle, int param);
|
||||
|
||||
public static native void SetModeSelect(long handle, int param);
|
||||
|
||||
public static native void SetProfileSlotSelect(long handle, int param);
|
||||
|
||||
public static native void SetRampThrottle(long handle, int param);
|
||||
|
||||
public static native void SetRevFeedbackSensor(long handle, int param);
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.fixtures.SampleFixture;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Basic test (borrowed straight from SampleTest) for running the CAN TalonSRX.
|
||||
*/
|
||||
public class CANTalonTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(SampleTest.class.getName());
|
||||
|
||||
static SampleFixture m_fixture = new SampleFixture();
|
||||
|
||||
protected Logger getClassLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetup() {
|
||||
// Set up the fixture before the test is created
|
||||
m_fixture.setup();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Reset the fixture elements before every test
|
||||
m_fixture.reset();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
// Clean up the fixture after the test
|
||||
m_fixture.teardown();
|
||||
}
|
||||
|
||||
private String errorMessage(double actual, double expected) {
|
||||
String start = "Actual value was: ";
|
||||
start += actual;
|
||||
start += " Expected: ";
|
||||
start += expected;
|
||||
return start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Briefly run a CAN Talon and assert true.
|
||||
*/
|
||||
@Test
|
||||
public void throttle() {
|
||||
double throttle = 0.1;
|
||||
CANTalon tal = new CANTalon(0);
|
||||
tal.set(throttle);
|
||||
Timer.delay(5.0);
|
||||
assertTrue(errorMessage(tal.get(), throttle), Math.abs(throttle - tal.get()) < 1e-2);
|
||||
|
||||
tal.set(-throttle);
|
||||
Timer.delay(1.25);
|
||||
assertTrue(errorMessage(tal.get(), -throttle), Math.abs(throttle + tal.get()) < 1e-2);
|
||||
tal.reverseOutput(true);
|
||||
tal.set(-throttle);
|
||||
Timer.delay(1.25);
|
||||
assertTrue(errorMessage(tal.get(), -throttle), Math.abs(throttle + tal.get()) < 1e-2);
|
||||
|
||||
tal.disable();
|
||||
Timer.delay(0.2);
|
||||
assertTrue(errorMessage(tal.get(), 0.0), Math.abs(tal.get()) < 1e-10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setGetPID() {
|
||||
CANTalon talon = new CANTalon(0);
|
||||
talon.changeControlMode(CANTalon.TalonControlMode.Position);
|
||||
@SuppressWarnings({"LocalVariableName", "MultipleVariableDeclarations"})
|
||||
double p = 0.05, i = 0.098, d = 1.23;
|
||||
talon.setPID(p, i, d);
|
||||
assertTrue(errorMessage(talon.getP(), p), Math.abs(p - talon.getP()) < 1e-5);
|
||||
assertTrue(errorMessage(talon.getI(), i), Math.abs(i - talon.getI()) < 1e-5);
|
||||
assertTrue(errorMessage(talon.getD(), d), Math.abs(d - talon.getD()) < 1e-5);
|
||||
// Test with new values in case the talon was already set to the previous
|
||||
// ones.
|
||||
p = 0.15;
|
||||
i = 0.198;
|
||||
d = 1.03;
|
||||
talon.setPID(p, i, d);
|
||||
assertTrue(errorMessage(talon.getP(), p), Math.abs(p - talon.getP()) < 1e-5);
|
||||
assertTrue(errorMessage(talon.getI(), i), Math.abs(i - talon.getI()) < 1e-5);
|
||||
assertTrue(errorMessage(talon.getD(), d), Math.abs(d - talon.getD()) < 1e-5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void positionModeWorks() {
|
||||
CANTalon talon = new CANTalon(0);
|
||||
talon.changeControlMode(CANTalon.TalonControlMode.Position);
|
||||
talon.setFeedbackDevice(CANTalon.FeedbackDevice.AnalogPot);
|
||||
Timer.delay(0.2);
|
||||
@SuppressWarnings({"LocalVariableName", "MultipleVariableDeclarations"})
|
||||
double p = 1.0, i = 0.0, d = 0.00;
|
||||
talon.setPID(p, i, d);
|
||||
talon.set(100);
|
||||
Timer.delay(5.0);
|
||||
talon.reverseOutput(true);
|
||||
Timer.delay(5.0);
|
||||
// assertTrue(errorMessage(talon.get(), 100), Math.abs(100 - talon.get()) <
|
||||
// 10);
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrake() {
|
||||
CANTalon talon = new CANTalon(0);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
talon.enableBrakeMode(true);
|
||||
Timer.delay(0.5);
|
||||
talon.enableBrakeMode(false);
|
||||
Timer.delay(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
//Test Get Fault methods (artf4814)
|
||||
@Test
|
||||
public void testGetFaults() {
|
||||
CANTalon talon = new CANTalon(0);
|
||||
talon.clearStickyFaults();
|
||||
|
||||
assertTrue(talon.getFaultOverTemp() == 0);
|
||||
assertTrue(talon.getFaultUnderVoltage() == 0);
|
||||
assertTrue(talon.getFaultForLim() == 0);
|
||||
assertTrue(talon.getFaultRevLim() == 0);
|
||||
assertTrue(talon.getFaultHardwareFailure() == 0);
|
||||
assertTrue(talon.getFaultForSoftLim() == 0);
|
||||
assertTrue(talon.getFaultRevSoftLim() == 0);
|
||||
|
||||
assertTrue(talon.getStickyFaultOverTemp() == 0);
|
||||
// assertTrue(talon.getStickyFaultUnderVoltage()==0);
|
||||
assertTrue(talon.getStickyFaultForLim() == 0);
|
||||
assertTrue(talon.getStickyFaultRevLim() == 0);
|
||||
assertTrue(talon.getStickyFaultForSoftLim() == 0);
|
||||
assertTrue(talon.getStickyFaultRevSoftLim() == 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,10 +58,7 @@ public class SampleTest extends AbstractComsSetup {
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
CANTalon cantalon = new CANTalon(0);
|
||||
cantalon.set(0.5);
|
||||
Timer.delay(0.5);
|
||||
cantalon.set(0.0);
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.test.AbstractTestSuite;
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({AnalogCrossConnectTest.class, AnalogPotentiometerTest.class,
|
||||
BuiltInAccelerometerTest.class, CANTalonTest.class,
|
||||
BuiltInAccelerometerTest.class,
|
||||
CircularBufferTest.class, ConstantsPortsTest.class, CounterTest.class,
|
||||
DigitalGlitchFilterTest.class, DIOCrossConnectTest.class, DriverStationTest.class,
|
||||
EncoderTest.class, FilterNoiseTest.class, FilterOutputTest.class, GyroTest.class,
|
||||
|
||||
Reference in New Issue
Block a user