diff --git a/hal/include/HAL/CanTalonSRX.h b/hal/include/HAL/CanTalonSRX.h index 4cbff71eec..87e2bf020c 100644 --- a/hal/include/HAL/CanTalonSRX.h +++ b/hal/include/HAL/CanTalonSRX.h @@ -1,421 +1,829 @@ -/** - * @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. - * - * 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(10bit) 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.csproj - * @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 -#include "ctre/CtreCanNode.h" -#include //CAN Comm -#include -#include -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 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 sigs_t; - sigs_t _sigs; //!< Catches signal updates that are solicited. Expect this to be very few. - void OpenSessionIfNeedBe(); - void ProcessStreamMessages(); - /** - * 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: - static const int kDefaultControlPeriodMs = 10; //!< default control update rate is 10ms. - CanTalonSRX(int deviceNumber = 0,int controlPeriodMs = kDefaultControlPeriodMs); - ~CanTalonSRX(); - void Set(double value); - /* mode select enumerations */ - static const int kMode_DutyCycle = 0; //!< Demand is 11bit signed duty cycle [-1023,1023]. - static const int kMode_PositionCloseLoop = 1; //!< Position PIDF. - static const int kMode_VelocityCloseLoop = 2; //!< Velocity PIDF. - static const int kMode_CurrentCloseLoop = 3; //!< Current close loop - not done. - static const int kMode_VoltCompen = 4; //!< Voltage Compensation Mode - not done. Demand is fixed pt target 8.8 volts. - static const int kMode_SlaveFollower = 5; //!< Demand is the 6 bit Device ID of the 'master' TALON SRX. - static const int kMode_NoDrive = 15; //!< 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. - /* 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; - /** - * 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. - */ - typedef 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, - }param_t; - /*---------------------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); - /** - * 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(); - /*------------------------ 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 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 SetModeSelect(int modeSelect,int demand); - CTR_Code SetProfileSlotSelect(int param); - CTR_Code SetRampThrottle(int param); - CTR_Code SetRevFeedbackSensor(int param); - CTR_Code GetPulseWidthPosition(int ¶m); - CTR_Code GetPulseWidthVelocity(int ¶m); - CTR_Code GetPulseWidthRiseToFallUs(int ¶m); - CTR_Code GetPulseWidthRiseToRiseUs(int ¶m); - CTR_Code IsPulseWidthSensorPresent(int ¶m); -}; -extern "C" { - void *c_TalonSRX_Create(int deviceNumber, int controlPeriodMs); - void c_TalonSRX_Destroy(void *handle); - 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_SetStatusFrameRate(void *handle, unsigned frameEnum, unsigned periodMs); - CTR_Code c_TalonSRX_ClearStickyFaults(void *handle); - 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_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_SetModeSelect2(void *handle, int modeSelect, int demand); - 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); - CTR_Code c_TalonSRX_GetPulseWidthPosition(void *handle, int *param); - CTR_Code c_TalonSRX_GetPulseWidthVelocity(void *handle, int *param); - CTR_Code c_TalonSRX_GetPulseWidthRiseToFallUs(void *handle, int *param); - CTR_Code c_TalonSRX_GetPulseWidthRiseToRiseUs(void *handle, int *param); - CTR_Code c_TalonSRX_IsPulseWidthSensorPresent(void *handle, int *param); -} -#endif - +/** + * @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 //CAN Comm +#include +#include +#include +#include +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 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 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 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 _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 diff --git a/hal/include/ctre/CtreCanNode.h b/hal/include/ctre/CtreCanNode.h index 4af7307c4b..270759866c 100644 --- a/hal/include/ctre/CtreCanNode.h +++ b/hal/include/ctre/CtreCanNode.h @@ -52,10 +52,26 @@ protected: }; UINT8 _deviceNumber; void RegisterRx(uint32_t arbId); + /** + * Schedule a CAN Frame for periodic transmit. Assume eight byte DLC and zero value for initial transmission. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + * @param periodMs Period to transmit CAN frame. Pass 0 for one-shot, which also disables that ArbID's preceding periodic transmit. + */ void RegisterTx(uint32_t arbId, uint32_t periodMs); + /** + * Schedule a CAN Frame for periodic transmit. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + * @param periodMs Period to transmit CAN frame. Pass 0 for one-shot, which also disables that ArbID's preceding periodic transmit. + * @param dlc Number of bytes to transmit (0 to 8). + * @param initialFrame Ptr to the frame data to schedule for transmitting. Passing null will result + * in defaulting to zero data value. + */ + void RegisterTx(uint32_t arbId, uint32_t periodMs, uint32_t dlc, const uint8_t * initialFrame); + void UnregisterTx(uint32_t arbId); CTR_Code GetRx(uint32_t arbId,uint8_t * dataBytes,uint32_t timeoutMs); void FlushTx(uint32_t arbId); + bool ChangeTxPeriod(uint32_t arbId, uint32_t periodMs); template txTask GetTx(uint32_t arbId) { @@ -86,6 +102,7 @@ private: uint32_t arbId; uint8_t toSend[8]; uint32_t periodMs; + uint8_t dlc; }; class rxEvent_t{ diff --git a/hal/include/ctre/ctre.h b/hal/include/ctre/ctre.h index c2d3f69614..a0f99b3071 100644 --- a/hal/include/ctre/ctre.h +++ b/hal/include/ctre/ctre.h @@ -1,5 +1,9 @@ -#ifndef GLOBAL_H -#define GLOBAL_H +/** + * @file ctre.h + * Common header for all CTRE HAL modules. + */ +#ifndef CTRE_H +#define CTRE_H //Bit Defines #define BIT0 0x01 @@ -45,6 +49,9 @@ typedef enum { CTR_UnexpectedArbId, //!< Specified CAN Id is invalid. CTR_TxFailed, //!< Could not transmit the CAN frame. CTR_SigNotUpdated, //!< Have not received an value response for signal. + CTR_BufferFull, //!< Caller attempted to insert data into a buffer that is full. }CTR_Code; -#endif +#include "ctre_frames.h" + +#endif /* CTRE_H */ diff --git a/hal/include/ctre/ctre_frames.h b/hal/include/ctre/ctre_frames.h new file mode 100644 index 0000000000..f131538fa9 --- /dev/null +++ b/hal/include/ctre/ctre_frames.h @@ -0,0 +1,243 @@ +/** + * @file ctre_frames.h + * CAN Encoder/Decoder Structures for CTRE devices. + */ +#ifndef CTRE_FRAMES_H +#define CTRE_FRAMES_H + +/** control */ +typedef struct _TALON_Control_1_General_10ms_t { + unsigned TokenH:8; + unsigned TokenL:8; + unsigned DemandH:8; + unsigned DemandM:8; + unsigned DemandL:8; + unsigned ProfileSlotSelect:1; + unsigned FeedbackDeviceSelect:4; + unsigned OverrideLimitSwitchEn:3; + unsigned RevFeedbackSensor:1; + unsigned RevMotDuringCloseLoopEn:1; + unsigned OverrideBrakeType:2; + unsigned ModeSelect:4; + unsigned RampThrottle:8; +} TALON_Control_1_General_10ms_t ; + +/* TALON_Control_2_Rates_OneShot_t removed since it has been deprecated */ + +typedef struct _TALON_Control_3_ClearFlags_OneShot_t { + unsigned ZeroFeedbackSensor:1; + unsigned ClearStickyFaults:1; +} TALON_Control_3_ClearFlags_OneShot_t ; + +typedef struct _TALON_Control_5_General_10ms_t { + unsigned ThrottleBump_h3:3; + unsigned ReservedZero:5; + unsigned ThrottleBump_l8:8; + unsigned DemandH:8; + unsigned DemandM:8; + unsigned DemandL:8; + unsigned ProfileSlotSelect:1; + unsigned FeedbackDeviceSelect:4; + unsigned OverrideLimitSwitchEn:3; + unsigned RevFeedbackSensor:1; + unsigned RevMotDuringCloseLoopEn:1; + unsigned OverrideBrakeType:2; + unsigned ModeSelect:4; + unsigned RampThrottle:8; +} TALON_Control_5_General_10ms_t ; + +typedef struct _TALON_Control_6_MotProfAddTrajPoint_t { + unsigned huffCode:2; //!< Compression coding + unsigned NextPt_VelOnly:1; + unsigned NextPt_IsLast:1; + unsigned reserved0:2; + unsigned NextPt_ZeroPosition:1; + unsigned NextPt_ProfileSlotSelect:1; + unsigned Idx:4; + unsigned reserved1:4; + unsigned restOfFrame0:8; + unsigned restOfFrame1:8; + unsigned restOfFrame2:8; + unsigned restOfFrame3:8; + unsigned restOfFrame4:8; + unsigned restOfFrame5:8; +} TALON_Control_6_MotProfAddTrajPoint_t; + +typedef struct _TALON_Control_6_MotProfAddTrajPoint_huff0_t { + unsigned huffCode_expect_0:2; //!< Compression coding + unsigned NextPt_VelOnly:1; + unsigned NextPt_IsLast:1; + unsigned reserved0:2; + unsigned NextPt_ZeroPosition:1; + unsigned NextPt_ProfileSlotSelect:1; + unsigned Idx:4; + unsigned reserved1:4; + unsigned NextPt_DurationMs:8; + unsigned NextPt_VelocityH:8; + unsigned NextPt_VelocityL:8; + unsigned NextPt_PositionH:8; + unsigned NextPt_PositionM:8; + unsigned NextPt_PositionL:8; +} TALON_Control_6_MotProfAddTrajPoint_huff0_t; + +typedef struct _TALON_Control_6_MotProfAddTrajPoint_huff1_t { + unsigned huffCode_expect_1:2; //!< Compression coding + unsigned NextPt_VelOnly:1; + unsigned NextPt_IsLast:1; + unsigned reserved0:2; + unsigned NextPt_ZeroPosition:1; + unsigned NextPt_ProfileSlotSelect:1; + unsigned Idx:4; + unsigned reserved1:4; + unsigned NextPt_DurationMs:8; + unsigned NextPt_SameVelocityH:8; + unsigned NextPt_SameVelocityL:8; + unsigned NextPt_DeltaPositionH:8; + unsigned NextPt_DeltaPositionL:8; + unsigned NextPt_Count:8; +} TALON_Control_6_MotProfAddTrajPoint_huff1_t; + +/** status */ +typedef struct _TALON_Status_1_General_10ms_t { + unsigned CloseLoopErrH:8; + unsigned CloseLoopErrM:8; + unsigned CloseLoopErrL:8; + unsigned AppliedThrottle_h3:3; + unsigned Fault_RevSoftLim:1; + unsigned Fault_ForSoftLim:1; + unsigned TokLocked:1; + unsigned LimitSwitchClosedRev:1; + unsigned LimitSwitchClosedFor:1; + unsigned AppliedThrottle_l8:8; + unsigned ModeSelect_h1:1; + unsigned FeedbackDeviceSelect:4; + unsigned LimitSwitchEn:3; + unsigned Fault_HardwareFailure:1; + unsigned Fault_RevLim:1; + unsigned Fault_ForLim:1; + unsigned Fault_UnderVoltage:1; + unsigned Fault_OverTemp:1; + unsigned ModeSelect_b3:3; + unsigned TokenSeed:8; +} TALON_Status_1_General_10ms_t ; +typedef struct _TALON_Status_2_Feedback_20ms_t { + unsigned SensorPositionH:8; + unsigned SensorPositionM:8; + unsigned SensorPositionL:8; + unsigned SensorVelocityH:8; + unsigned SensorVelocityL:8; + unsigned Current_h8:8; + unsigned StckyFault_RevSoftLim:1; + unsigned StckyFault_ForSoftLim:1; + unsigned StckyFault_RevLim:1; + unsigned StckyFault_ForLim:1; + unsigned StckyFault_UnderVoltage:1; + unsigned StckyFault_OverTemp:1; + unsigned Current_l2:2; + unsigned reserved:3; + unsigned Cmd5Allowed:1; + unsigned VelDiv4:1; + unsigned PosDiv8:1; + unsigned ProfileSlotSelect:1; + unsigned BrakeIsEnabled:1; +} TALON_Status_2_Feedback_20ms_t ; +typedef struct _TALON_Status_3_Enc_100ms_t { + unsigned EncPositionH:8; + unsigned EncPositionM:8; + unsigned EncPositionL:8; + unsigned EncVelH:8; + unsigned EncVelL:8; + unsigned EncIndexRiseEventsH:8; + unsigned EncIndexRiseEventsL:8; + unsigned reserved:3; + unsigned VelDiv4:1; + unsigned PosDiv8:1; + unsigned QuadIdxpin:1; + unsigned QuadBpin:1; + unsigned QuadApin:1; +} TALON_Status_3_Enc_100ms_t ; +typedef struct _TALON_Status_4_AinTempVbat_100ms_t { + unsigned AnalogInWithOvH:8; + unsigned AnalogInWithOvM:8; + unsigned AnalogInWithOvL:8; + unsigned AnalogInVelH:8; + unsigned AnalogInVelL:8; + unsigned Temp:8; + unsigned BatteryV:8; + unsigned reserved:6; + unsigned VelDiv4:1; + unsigned PosDiv8:1; +} TALON_Status_4_AinTempVbat_100ms_t ; +typedef struct _TALON_Status_5_Startup_OneShot_t { + unsigned ResetCountH:8; + unsigned ResetCountL:8; + unsigned ResetFlagsH:8; + unsigned ResetFlagsL:8; + unsigned FirmVersH:8; + unsigned FirmVersL:8; +} TALON_Status_5_Startup_OneShot_t ; +typedef struct _TALON_Status_6_Eol_t { + unsigned currentAdcUncal_h2:2; + unsigned reserved1:5; + unsigned SpiCsPin_GadgeteerPin6:1; + unsigned currentAdcUncal_l8:8; + unsigned tempAdcUncal_h2:2; + unsigned reserved2:6; + unsigned tempAdcUncal_l8:8; + unsigned vbatAdcUncal_h2:2; + unsigned reserved3:6; + unsigned vbatAdcUncal_l8:8; + unsigned analogAdcUncal_h2:2; + unsigned reserved4:6; + unsigned analogAdcUncal_l8:8; +} TALON_Status_6_Eol_t ; +typedef struct _TALON_Status_7_Debug_200ms_t { + unsigned TokenizationFails_h8:8; + unsigned TokenizationFails_l8:8; + unsigned LastFailedToken_h8:8; + unsigned LastFailedToken_l8:8; + unsigned TokenizationSucceses_h8:8; + unsigned TokenizationSucceses_l8:8; +} TALON_Status_7_Debug_200ms_t ; +typedef struct _TALON_Status_8_PulseWid_100ms_t { + unsigned PulseWidPositionH:8; + unsigned PulseWidPositionM:8; + unsigned PulseWidPositionL:8; + unsigned reserved:6; + unsigned VelDiv4:1; + unsigned PosDiv8:1; + unsigned PeriodUsM8:8; + unsigned PeriodUsL8:8; + unsigned PulseWidVelH:8; + unsigned PulseWidVelL:8; +} TALON_Status_8_PulseWid_100ms_t ; +typedef struct _TALON_Status_9_MotProfBuffer_100ms_t { + unsigned ActTraj_IsValid:1; //!< '1' if other ActTraj_* signals are valid. '0' if there is no active trajectory pt. + unsigned ActTraj_ProfileSlotSelect:1; + unsigned ActTraj_VelOnly:1; + unsigned ActTraj_IsLast:1; + unsigned OutputType:2; + unsigned HasUnderrun:1; + unsigned IsUnderrun:1; + unsigned NextID:4; + unsigned reserved1:3; + unsigned BufferIsFull:1; + unsigned Count:8; + unsigned ActTraj_VelocityH:8; + unsigned ActTraj_VelocityL:8; + unsigned ActTraj_PositionH:8; + unsigned ActTraj_PositionM:8; + unsigned ActTraj_PositionL:8; +} TALON_Status_9_MotProfBuffer_100ms_t ; +typedef struct _TALON_Param_Request_t { + unsigned ParamEnum:8; +} TALON_Param_Request_t ; +typedef struct _TALON_Param_Response_t { + unsigned ParamEnum:8; + unsigned ParamValueL:8; + unsigned ParamValueML:8; + unsigned ParamValueMH:8; + unsigned ParamValueH:8; +} TALON_Param_Response_t ; + +#endif /* CTRE_FRAMES_H */ diff --git a/hal/lib/Athena/ctre/CanTalonSRX.cpp b/hal/lib/Athena/ctre/CanTalonSRX.cpp index 56e68e1ec1..2f6198d4ba 100644 --- a/hal/lib/Athena/ctre/CanTalonSRX.cpp +++ b/hal/lib/Athena/ctre/CanTalonSRX.cpp @@ -1,1417 +1,2020 @@ -/** - * @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(10bit) 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.csproj - * @link https://docs.google.com/spreadsheets/d/1OU_ZV7fZLGYUQ-Uhc8sVAmUmWTlT8XBFYK8lfjg_tac/edit#gid=1766046967 - */ -#include "HAL/CanTalonSRX.h" -#include "FRC_NetworkCommunication/CANSessionMux.h" //CAN Comm -#include // memset -#include // usleep - -#define STATUS_1 0x02041400 -#define STATUS_2 0x02041440 -#define STATUS_3 0x02041480 -#define STATUS_4 0x020414C0 -#define STATUS_5 0x02041500 -#define STATUS_6 0x02041540 -#define STATUS_7 0x02041580 -#define STATUS_8 0x020415C0 - -#define CONTROL_1 0x02040000 -#define CONTROL_2 0x02040040 -#define CONTROL_3 0x02040080 - -#define EXPECTED_RESPONSE_TIMEOUT_MS (200) -#define GET_STATUS1() CtreCanNode::recMsg rx = GetRx(STATUS_1 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS2() CtreCanNode::recMsg rx = GetRx(STATUS_2 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS3() CtreCanNode::recMsg rx = GetRx(STATUS_3 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS4() CtreCanNode::recMsg rx = GetRx(STATUS_4 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS5() CtreCanNode::recMsg rx = GetRx(STATUS_5 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS6() CtreCanNode::recMsg rx = GetRx(STATUS_6 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS7() CtreCanNode::recMsg rx = GetRx(STATUS_7 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) -#define GET_STATUS8() CtreCanNode::recMsg rx = GetRx(STATUS_8 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) - -#define PARAM_REQUEST 0x02041800 -#define PARAM_RESPONSE 0x02041840 -#define PARAM_SET 0x02041880 - -const int kParamArbIdValue = PARAM_RESPONSE; -const int kParamArbIdMask = 0xFFFFFFFF; - -const double FLOAT_TO_FXP_10_22 = (double)0x400000; -const double FXP_TO_FLOAT_10_22 = 0.0000002384185791015625; - -const double FLOAT_TO_FXP_0_8 = (double)0x100; -const double FXP_TO_FLOAT_0_8 = 0.00390625; - -/* encoder/decoders */ -/** control */ -typedef struct _TALON_Control_1_General_10ms_t { - unsigned TokenH:8; - unsigned TokenL:8; - unsigned DemandH:8; - unsigned DemandM:8; - unsigned DemandL:8; - unsigned ProfileSlotSelect:1; - unsigned FeedbackDeviceSelect:4; - unsigned OverrideLimitSwitchEn:3; - unsigned RevFeedbackSensor:1; - unsigned RevMotDuringCloseLoopEn:1; - unsigned OverrideBrakeType:2; - unsigned ModeSelect:4; - unsigned RampThrottle:8; -} TALON_Control_1_General_10ms_t ; -typedef struct _TALON_Control_2_Rates_OneShot_t { - unsigned Status1Ms:8; - unsigned Status2Ms:8; - unsigned Status3Ms:8; - unsigned Status4Ms:8; - unsigned StatusPulWidMs:8; // TALON_Status_8_PulseWid_100ms_t -} TALON_Control_2_Rates_OneShot_t ; -typedef struct _TALON_Control_3_ClearFlags_OneShot_t { - unsigned ZeroFeedbackSensor:1; - unsigned ClearStickyFaults:1; -} TALON_Control_3_ClearFlags_OneShot_t ; - -/** status */ -typedef struct _TALON_Status_1_General_10ms_t { - unsigned CloseLoopErrH:8; - unsigned CloseLoopErrM:8; - unsigned CloseLoopErrL:8; - unsigned AppliedThrottle_h3:3; - unsigned Fault_RevSoftLim:1; - unsigned Fault_ForSoftLim:1; - unsigned TokLocked:1; - unsigned LimitSwitchClosedRev:1; - unsigned LimitSwitchClosedFor:1; - unsigned AppliedThrottle_l8:8; - unsigned ModeSelect_h1:1; - unsigned FeedbackDeviceSelect:4; - unsigned LimitSwitchEn:3; - unsigned Fault_HardwareFailure:1; - unsigned Fault_RevLim:1; - unsigned Fault_ForLim:1; - unsigned Fault_UnderVoltage:1; - unsigned Fault_OverTemp:1; - unsigned ModeSelect_b3:3; - unsigned TokenSeed:8; -} TALON_Status_1_General_10ms_t ; -typedef struct _TALON_Status_2_Feedback_20ms_t { - unsigned SensorPositionH:8; - unsigned SensorPositionM:8; - unsigned SensorPositionL:8; - unsigned SensorVelocityH:8; - unsigned SensorVelocityL:8; - unsigned Current_h8:8; - unsigned StckyFault_RevSoftLim:1; - unsigned StckyFault_ForSoftLim:1; - unsigned StckyFault_RevLim:1; - unsigned StckyFault_ForLim:1; - unsigned StckyFault_UnderVoltage:1; - unsigned StckyFault_OverTemp:1; - unsigned Current_l2:2; - unsigned reserved2:4; - unsigned VelDiv4:1; - unsigned PosDiv8:1; - unsigned ProfileSlotSelect:1; - unsigned BrakeIsEnabled:1; -} TALON_Status_2_Feedback_20ms_t ; -typedef struct _TALON_Status_3_Enc_100ms_t { - unsigned EncPositionH:8; - unsigned EncPositionM:8; - unsigned EncPositionL:8; - unsigned EncVelH:8; - unsigned EncVelL:8; - unsigned EncIndexRiseEventsH:8; - unsigned EncIndexRiseEventsL:8; - unsigned reserved:3; - unsigned VelDiv4:1; - unsigned PosDiv8:1; - unsigned QuadIdxpin:1; - unsigned QuadBpin:1; - unsigned QuadApin:1; -} TALON_Status_3_Enc_100ms_t ; -typedef struct _TALON_Status_4_AinTempVbat_100ms_t { - unsigned AnalogInWithOvH:8; - unsigned AnalogInWithOvM:8; - unsigned AnalogInWithOvL:8; - unsigned AnalogInVelH:8; - unsigned AnalogInVelL:8; - unsigned Temp:8; - unsigned BatteryV:8; - unsigned reserved:6; - unsigned VelDiv4:1; - unsigned PosDiv8:1; -} TALON_Status_4_AinTempVbat_100ms_t ; -typedef struct _TALON_Status_5_Startup_OneShot_t { - unsigned ResetCountH:8; - unsigned ResetCountL:8; - unsigned ResetFlagsH:8; - unsigned ResetFlagsL:8; - unsigned FirmVersH:8; - unsigned FirmVersL:8; -} TALON_Status_5_Startup_OneShot_t ; -typedef struct _TALON_Status_6_Eol_t { - unsigned currentAdcUncal_h2:2; - unsigned reserved1:5; - unsigned SpiCsPin_GadgeteerPin6:1; - unsigned currentAdcUncal_l8:8; - unsigned tempAdcUncal_h2:2; - unsigned reserved2:6; - unsigned tempAdcUncal_l8:8; - unsigned vbatAdcUncal_h2:2; - unsigned reserved3:6; - unsigned vbatAdcUncal_l8:8; - unsigned analogAdcUncal_h2:2; - unsigned reserved4:6; - unsigned analogAdcUncal_l8:8; -} TALON_Status_6_Eol_t ; -typedef struct _TALON_Status_7_Debug_200ms_t { - unsigned TokenizationFails_h8:8; - unsigned TokenizationFails_l8:8; - unsigned LastFailedToken_h8:8; - unsigned LastFailedToken_l8:8; - unsigned TokenizationSucceses_h8:8; - unsigned TokenizationSucceses_l8:8; -} TALON_Status_7_Debug_200ms_t ; -typedef struct _TALON_Status_8_PulseWid_100ms_t { - unsigned PulseWidPositionH:8; - unsigned PulseWidPositionM:8; - unsigned PulseWidPositionL:8; - unsigned reserved:6; - unsigned VelDiv4:1; - unsigned PosDiv8:1; - unsigned PeriodUsM8:8; - unsigned PeriodUsL8:8; - unsigned PulseWidVelH:8; - unsigned PulseWidVelL:8; -} TALON_Status_8_PulseWid_100ms_t ; -typedef struct _TALON_Param_Request_t { - unsigned ParamEnum:8; -} TALON_Param_Request_t ; -typedef struct _TALON_Param_Response_t { - unsigned ParamEnum:8; - unsigned ParamValueL:8; - unsigned ParamValueML:8; - unsigned ParamValueMH:8; - unsigned ParamValueH:8; -} TALON_Param_Response_t ; - -CanTalonSRX::CanTalonSRX(int deviceNumber,int controlPeriodMs): CtreCanNode(deviceNumber), _can_h(0), _can_stat(0) -{ - /* bound period to be within [1 ms,95 ms] */ - if(controlPeriodMs < 1) - controlPeriodMs = 1; - else if(controlPeriodMs > 95) - controlPeriodMs = 95; - RegisterRx(STATUS_1 | (UINT8)deviceNumber ); - RegisterRx(STATUS_2 | (UINT8)deviceNumber ); - RegisterRx(STATUS_3 | (UINT8)deviceNumber ); - RegisterRx(STATUS_4 | (UINT8)deviceNumber ); - RegisterRx(STATUS_5 | (UINT8)deviceNumber ); - RegisterRx(STATUS_6 | (UINT8)deviceNumber ); - RegisterRx(STATUS_7 | (UINT8)deviceNumber ); - RegisterTx(CONTROL_1 | (UINT8)deviceNumber, (UINT8)controlPeriodMs); - /* the only default param that is nonzero is limit switch. - * Default to using the flash settings. */ - SetOverrideLimitSwitchEn(kLimitSwitchOverride_UseDefaultsFromFlash); -} -/* CanTalonSRX D'tor - */ -CanTalonSRX::~CanTalonSRX() -{ - if (m_hasBeenMoved){ - /* Another CANTalonSRX still exists, so - don't un-register the periodic control frame */ - }else{ - /* un-register the control frame so Talon is disabled */ - RegisterTx(CONTROL_1 | (UINT8)GetDeviceNumber(), 0); - } - /* free the stream we used for SetParam/GetParamResponse */ - if(_can_h){ - FRC_NetworkCommunication_CANSessionMux_closeStreamSession(_can_h); - _can_h = 0; - } -} -void CanTalonSRX::OpenSessionIfNeedBe() -{ - _can_stat = 0; - if (_can_h == 0) { - /* bit30 - bit8 must match $000002XX. Top bit is not masked to get remote frames */ - FRC_NetworkCommunication_CANSessionMux_openStreamSession(&_can_h,kParamArbIdValue | GetDeviceNumber(), kParamArbIdMask, kMsgCapacity, &_can_stat); - if (_can_stat == 0) { - /* success */ - } else { - /* something went wrong, try again later */ - _can_h = 0; - } - } -} -void CanTalonSRX::ProcessStreamMessages() -{ - if(0 == _can_h) - OpenSessionIfNeedBe(); - /* process receive messages */ - uint32_t i; - uint32_t messagesToRead = sizeof(_msgBuff) / sizeof(_msgBuff[0]); - uint32_t messagesRead = 0; - /* read out latest bunch of messages */ - _can_stat = 0; - if (_can_h){ - FRC_NetworkCommunication_CANSessionMux_readStreamSession(_can_h,_msgBuff, messagesToRead, &messagesRead, &_can_stat); - } - /* loop thru each message of interest */ - for (i = 0; i < messagesRead; ++i) { - tCANStreamMessage * msg = _msgBuff + i; - if(msg->messageID == (PARAM_RESPONSE | GetDeviceNumber()) ){ - TALON_Param_Response_t * paramResp = (TALON_Param_Response_t*)msg->data; - /* decode value */ - int32_t val = paramResp->ParamValueH; - val <<= 8; - val |= paramResp->ParamValueMH; - val <<= 8; - val |= paramResp->ParamValueML; - val <<= 8; - val |= paramResp->ParamValueL; - /* save latest signal */ - _sigs[paramResp->ParamEnum] = val; - }else{ - int brkpthere = 42; - ++brkpthere; - } - } -} -void CanTalonSRX::Set(double value) -{ - if(value > 1) - value = 1; - else if(value < -1) - value = -1; - SetDemand(1023*value); /* must be within [-1023,1023] */ -} -/*---------------------setters and getters that use the 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 CanTalonSRX::SetParamRaw(unsigned paramEnum, int rawBits) -{ - /* caller is using param API. Open session if it hasn'T been done. */ - if(0 == _can_h) - OpenSessionIfNeedBe(); - TALON_Param_Response_t frame; - memset(&frame,0,sizeof(frame)); - frame.ParamEnum = paramEnum; - frame.ParamValueH = rawBits >> 0x18; - frame.ParamValueMH = rawBits >> 0x10; - frame.ParamValueML = rawBits >> 0x08; - frame.ParamValueL = rawBits; - int32_t status = 0; - FRC_NetworkCommunication_CANSessionMux_sendMessage(PARAM_SET | GetDeviceNumber(), (const uint8_t*)&frame, 5, 0, &status); - if(status) - return CTR_TxFailed; - return CTR_OKAY; -} -/** - * Checks cached CAN frames and updating solicited signals. - */ -CTR_Code CanTalonSRX::GetParamResponseRaw(unsigned paramEnum, int & rawBits) -{ - CTR_Code retval = CTR_OKAY; - /* process received param events. We don't expect many since this API is not used often. */ - ProcessStreamMessages(); - /* grab the solicited signal value */ - sigs_t::iterator i = _sigs.find(paramEnum); - if(i == _sigs.end()){ - retval = CTR_SigNotUpdated; - }else{ - rawBits = i->second; - } - return retval; -} -/** - * 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 CanTalonSRX::RequestParam(param_t paramEnum) -{ - /* process received param events. We don't expect many since this API is not used often. */ - ProcessStreamMessages(); - TALON_Param_Request_t frame; - memset(&frame,0,sizeof(frame)); - frame.ParamEnum = paramEnum; - int32_t status = 0; - FRC_NetworkCommunication_CANSessionMux_sendMessage(PARAM_REQUEST | GetDeviceNumber(), (const uint8_t*)&frame, 1, 0, &status); - if(status) - return CTR_TxFailed; - return CTR_OKAY; -} - -CTR_Code CanTalonSRX::SetParam(param_t paramEnum, double value) -{ - int32_t rawbits = 0; - switch(paramEnum){ - case eProfileParamSlot0_P:/* unsigned 10.22 fixed pt value */ - case eProfileParamSlot0_I: - case eProfileParamSlot0_D: - case eProfileParamSlot1_P: - case eProfileParamSlot1_I: - case eProfileParamSlot1_D: - { - uint32_t urawbits; - value = std::min(value,1023.0); /* bounds check doubles that are outside u10.22 */ - value = std::max(value,0.0); - urawbits = value * FLOAT_TO_FXP_10_22; /* perform unsign arithmetic */ - rawbits = urawbits; /* copy bits over. SetParamRaw just stuffs into CAN frame with no sense of signedness */ - } break; - case eProfileParamSlot1_F: /* signed 10.22 fixed pt value */ - case eProfileParamSlot0_F: - value = std::min(value, 512.0); /* bounds check doubles that are outside s10.22 */ - value = std::max(value,-512.0); - rawbits = value * FLOAT_TO_FXP_10_22; - break; - case eProfileParamVcompRate: /* unsigned 0.8 fixed pt value volts per ms */ - /* within [0,1) volts per ms. - Slowest ramp is 1/256 VperMilliSec or 3.072 seconds from 0-to-12V. - Fastest ramp is 255/256 VperMilliSec or 12.1ms from 0-to-12V. - */ - if(value <= 0){ - /* negative or zero (disable), send raw value of zero */ - rawbits = 0; - }else{ - /* nonzero ramping */ - rawbits = value * FLOAT_TO_FXP_0_8; - /* since whole part is cleared, cap to just under whole unit */ - if(rawbits > (FLOAT_TO_FXP_0_8-1) ) - rawbits = (FLOAT_TO_FXP_0_8-1); - /* since ramping is nonzero, cap to smallest ramp rate possible */ - if(rawbits == 0){ - /* caller is providing a nonzero ramp rate that's too small - to serialize, so cap to smallest possible */ - rawbits = 1; - } - } - break; - default: /* everything else is integral */ - rawbits = (int32_t)value; - break; - } - return SetParamRaw(paramEnum,rawbits); -} -CTR_Code CanTalonSRX::GetParamResponse(param_t paramEnum, double & value) -{ - int32_t rawbits = 0; - CTR_Code retval = GetParamResponseRaw(paramEnum,rawbits); - switch(paramEnum){ - case eProfileParamSlot0_P:/* 10.22 fixed pt value */ - case eProfileParamSlot0_I: - case eProfileParamSlot0_D: - case eProfileParamSlot0_F: - case eProfileParamSlot1_P: - case eProfileParamSlot1_I: - case eProfileParamSlot1_D: - case eProfileParamSlot1_F: - case eCurrent: - case eTemp: - case eBatteryV: - value = ((double)rawbits) * FXP_TO_FLOAT_10_22; - break; - case eProfileParamVcompRate: - value = ((double)rawbits) * FXP_TO_FLOAT_0_8; - break; - default: /* everything else is integral */ - value = (double)rawbits; - break; - } - return retval; -} -CTR_Code CanTalonSRX::GetParamResponseInt32(param_t paramEnum, int & value) -{ - double dvalue = 0; - CTR_Code retval = GetParamResponse(paramEnum, dvalue); - value = (int32_t)dvalue; - return retval; -} -/*----- 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 CanTalonSRX::SetPgain(unsigned slotIdx,double gain) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_P, gain); - return SetParam(eProfileParamSlot1_P, gain); -} -CTR_Code CanTalonSRX::SetIgain(unsigned slotIdx,double gain) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_I, gain); - return SetParam(eProfileParamSlot1_I, gain); -} -CTR_Code CanTalonSRX::SetDgain(unsigned slotIdx,double gain) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_D, gain); - return SetParam(eProfileParamSlot1_D, gain); -} -CTR_Code CanTalonSRX::SetFgain(unsigned slotIdx,double gain) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_F, gain); - return SetParam(eProfileParamSlot1_F, gain); -} -CTR_Code CanTalonSRX::SetIzone(unsigned slotIdx,int zone) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_IZone, zone); - return SetParam(eProfileParamSlot1_IZone, zone); -} -CTR_Code CanTalonSRX::SetCloseLoopRampRate(unsigned slotIdx,int closeLoopRampRate) -{ - if(slotIdx == 0) - return SetParam(eProfileParamSlot0_CloseLoopRampRate, closeLoopRampRate); - return SetParam(eProfileParamSlot1_CloseLoopRampRate, closeLoopRampRate); -} -CTR_Code CanTalonSRX::SetVoltageCompensationRate(double voltagePerMs) -{ - return SetParam(eProfileParamVcompRate, voltagePerMs); -} -CTR_Code CanTalonSRX::GetPgain(unsigned slotIdx,double & gain) -{ - if(slotIdx == 0) - return GetParamResponse(eProfileParamSlot0_P, gain); - return GetParamResponse(eProfileParamSlot1_P, gain); -} -CTR_Code CanTalonSRX::GetIgain(unsigned slotIdx,double & gain) -{ - if(slotIdx == 0) - return GetParamResponse(eProfileParamSlot0_I, gain); - return GetParamResponse(eProfileParamSlot1_I, gain); -} -CTR_Code CanTalonSRX::GetDgain(unsigned slotIdx,double & gain) -{ - if(slotIdx == 0) - return GetParamResponse(eProfileParamSlot0_D, gain); - return GetParamResponse(eProfileParamSlot1_D, gain); -} -CTR_Code CanTalonSRX::GetFgain(unsigned slotIdx,double & gain) -{ - if(slotIdx == 0) - return GetParamResponse(eProfileParamSlot0_F, gain); - return GetParamResponse(eProfileParamSlot1_F, gain); -} -CTR_Code CanTalonSRX::GetIzone(unsigned slotIdx,int & zone) -{ - if(slotIdx == 0) - return GetParamResponseInt32(eProfileParamSlot0_IZone, zone); - return GetParamResponseInt32(eProfileParamSlot1_IZone, zone); -} -CTR_Code CanTalonSRX::GetCloseLoopRampRate(unsigned slotIdx,int & closeLoopRampRate) -{ - if(slotIdx == 0) - return GetParamResponseInt32(eProfileParamSlot0_CloseLoopRampRate, closeLoopRampRate); - return GetParamResponseInt32(eProfileParamSlot1_CloseLoopRampRate, closeLoopRampRate); -} -CTR_Code CanTalonSRX::GetVoltageCompensationRate(double & voltagePerMs) -{ - return GetParamResponse(eProfileParamVcompRate, voltagePerMs); -} -CTR_Code CanTalonSRX::SetSensorPosition(int pos) -{ - return SetParam(eSensorPosition, pos); -} -CTR_Code CanTalonSRX::SetForwardSoftLimit(int forwardLimit) -{ - return SetParam(eProfileParamSoftLimitForThreshold, forwardLimit); -} -CTR_Code CanTalonSRX::SetReverseSoftLimit(int reverseLimit) -{ - return SetParam(eProfileParamSoftLimitRevThreshold, reverseLimit); -} -CTR_Code CanTalonSRX::SetForwardSoftEnable(int enable) -{ - return SetParam(eProfileParamSoftLimitForEnable, enable); -} -CTR_Code CanTalonSRX::SetReverseSoftEnable(int enable) -{ - return SetParam(eProfileParamSoftLimitRevEnable, enable); -} -CTR_Code CanTalonSRX::GetForwardSoftLimit(int & forwardLimit) -{ - return GetParamResponseInt32(eProfileParamSoftLimitForThreshold, forwardLimit); -} -CTR_Code CanTalonSRX::GetReverseSoftLimit(int & reverseLimit) -{ - return GetParamResponseInt32(eProfileParamSoftLimitRevThreshold, reverseLimit); -} -CTR_Code CanTalonSRX::GetForwardSoftEnable(int & enable) -{ - return GetParamResponseInt32(eProfileParamSoftLimitForEnable, enable); -} -CTR_Code CanTalonSRX::GetReverseSoftEnable(int & enable) -{ - return GetParamResponseInt32(eProfileParamSoftLimitRevEnable, enable); -} -/** - * Change the periodMs of a TALON's status frame. See kStatusFrame_* enums for what's available. - */ -CTR_Code CanTalonSRX::SetStatusFrameRate(unsigned frameEnum, unsigned periodMs) -{ - CTR_Code retval = CTR_OKAY; - int32_t paramEnum = 0; - /* bounds check the period */ - if(periodMs < 1) - periodMs = 1; - else if (periodMs > 255) - periodMs = 255; - uint8_t period = (uint8_t)periodMs; - /* lookup the correct param enum based on what frame to rate-change */ - switch(frameEnum){ - case kStatusFrame_General: - paramEnum = eStatus1FrameRate; - break; - case kStatusFrame_Feedback: - paramEnum = eStatus2FrameRate; - break; - case kStatusFrame_Encoder: - paramEnum = eStatus3FrameRate; - break; - case kStatusFrame_AnalogTempVbat: - paramEnum = eStatus4FrameRate; - break; - case kStatusFrame_PulseWidthMeas: - paramEnum = eStatus8FrameRate; - break; - default: - /* caller's request is not support, return an error code */ - retval = CTR_InvalidParamValue; - break; - } - /* if lookup was succesful, send set-request out */ - if(retval == CTR_OKAY){ - /* paramEnum is updated, sent it out */ - retval = SetParamRaw(paramEnum, period); - } - return retval; -} -/** - * Clear all sticky faults in TALON. - */ -CTR_Code CanTalonSRX::ClearStickyFaults() -{ - int32_t status = 0; - /* build request frame */ - TALON_Control_3_ClearFlags_OneShot_t frame; - memset(&frame,0,sizeof(frame)); - frame.ClearStickyFaults = 1; - FRC_NetworkCommunication_CANSessionMux_sendMessage(CONTROL_3 | GetDeviceNumber(), (const uint8_t*)&frame, sizeof(frame), 0, &status); - if(status) - return CTR_TxFailed; - return CTR_OKAY; -} -/*------------------------ 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 CanTalonSRX::GetFault_OverTemp(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_OverTemp; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_UnderVoltage(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_UnderVoltage; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_ForLim(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_ForLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_RevLim(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_RevLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_HardwareFailure(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_HardwareFailure; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_ForSoftLim(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_ForSoftLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetFault_RevSoftLim(int ¶m) -{ - GET_STATUS1(); - param = rx->Fault_RevSoftLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_OverTemp(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_OverTemp; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_UnderVoltage(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_UnderVoltage; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_ForLim(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_ForLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_RevLim(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_RevLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_ForSoftLim(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_ForSoftLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetStckyFault_RevSoftLim(int ¶m) -{ - GET_STATUS2(); - param = rx->StckyFault_RevSoftLim; - return rx.err; -} -CTR_Code CanTalonSRX::GetAppliedThrottle(int ¶m) -{ - GET_STATUS1(); - int32_t raw = 0; - raw |= rx->AppliedThrottle_h3; - raw <<= 8; - raw |= rx->AppliedThrottle_l8; - raw <<= (32-11); /* sign extend */ - raw >>= (32-11); /* sign extend */ - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetCloseLoopErr(int ¶m) -{ - GET_STATUS1(); - int32_t raw = 0; - raw |= rx->CloseLoopErrH; - raw <<= 8; - raw |= rx->CloseLoopErrM; - raw <<= 8; - raw |= rx->CloseLoopErrL; - raw <<= (32-24); /* sign extend */ - raw >>= (32-24); /* sign extend */ - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetFeedbackDeviceSelect(int ¶m) -{ - GET_STATUS1(); - param = rx->FeedbackDeviceSelect; - return rx.err; -} -CTR_Code CanTalonSRX::GetModeSelect(int ¶m) -{ - GET_STATUS1(); - uint32_t raw = 0; - raw |= rx->ModeSelect_h1; - raw <<= 3; - raw |= rx->ModeSelect_b3; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetLimitSwitchEn(int ¶m) -{ - GET_STATUS1(); - param = rx->LimitSwitchEn; - return rx.err; -} -CTR_Code CanTalonSRX::GetLimitSwitchClosedFor(int ¶m) -{ - GET_STATUS1(); - param = rx->LimitSwitchClosedFor; - return rx.err; -} -CTR_Code CanTalonSRX::GetLimitSwitchClosedRev(int ¶m) -{ - GET_STATUS1(); - param = rx->LimitSwitchClosedRev; - return rx.err; -} -CTR_Code CanTalonSRX::GetSensorPosition(int ¶m) -{ - GET_STATUS2(); - int32_t raw = 0; - raw |= rx->SensorPositionH; - raw <<= 8; - raw |= rx->SensorPositionM; - raw <<= 8; - raw |= rx->SensorPositionL; - raw <<= (32-24); /* sign extend */ - raw >>= (32-24); /* sign extend */ - if(rx->PosDiv8) - raw *= 8; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetSensorVelocity(int ¶m) -{ - GET_STATUS2(); - int32_t raw = 0; - raw |= rx->SensorVelocityH; - raw <<= 8; - raw |= rx->SensorVelocityL; - raw <<= (32-16); /* sign extend */ - raw >>= (32-16); /* sign extend */ - if(rx->VelDiv4) - raw *= 4; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetCurrent(double ¶m) -{ - GET_STATUS2(); - uint32_t raw = 0; - raw |= rx->Current_h8; - raw <<= 2; - raw |= rx->Current_l2; - param = (double)raw * 0.125 + 0; - return rx.err; -} -CTR_Code CanTalonSRX::GetBrakeIsEnabled(int ¶m) -{ - GET_STATUS2(); - param = rx->BrakeIsEnabled; - return rx.err; -} -CTR_Code CanTalonSRX::GetEncPosition(int ¶m) -{ - GET_STATUS3(); - int32_t raw = 0; - raw |= rx->EncPositionH; - raw <<= 8; - raw |= rx->EncPositionM; - raw <<= 8; - raw |= rx->EncPositionL; - raw <<= (32-24); /* sign extend */ - raw >>= (32-24); /* sign extend */ - if(rx->PosDiv8) - raw *= 8; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetEncVel(int ¶m) -{ - GET_STATUS3(); - int32_t raw = 0; - raw |= rx->EncVelH; - raw <<= 8; - raw |= rx->EncVelL; - raw <<= (32-16); /* sign extend */ - raw >>= (32-16); /* sign extend */ - if(rx->VelDiv4) - raw *= 4; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetEncIndexRiseEvents(int ¶m) -{ - GET_STATUS3(); - uint32_t raw = 0; - raw |= rx->EncIndexRiseEventsH; - raw <<= 8; - raw |= rx->EncIndexRiseEventsL; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetQuadApin(int ¶m) -{ - GET_STATUS3(); - param = rx->QuadApin; - return rx.err; -} -CTR_Code CanTalonSRX::GetQuadBpin(int ¶m) -{ - GET_STATUS3(); - param = rx->QuadBpin; - return rx.err; -} -CTR_Code CanTalonSRX::GetQuadIdxpin(int ¶m) -{ - GET_STATUS3(); - param = rx->QuadIdxpin; - return rx.err; -} -CTR_Code CanTalonSRX::GetAnalogInWithOv(int ¶m) -{ - GET_STATUS4(); - int32_t raw = 0; - raw |= rx->AnalogInWithOvH; - raw <<= 8; - raw |= rx->AnalogInWithOvM; - raw <<= 8; - raw |= rx->AnalogInWithOvL; - raw <<= (32-24); /* sign extend */ - raw >>= (32-24); /* sign extend */ - if(rx->PosDiv8) - raw *= 8; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetAnalogInVel(int ¶m) -{ - GET_STATUS4(); - int32_t raw = 0; - raw |= rx->AnalogInVelH; - raw <<= 8; - raw |= rx->AnalogInVelL; - raw <<= (32-16); /* sign extend */ - raw >>= (32-16); /* sign extend */ - if(rx->VelDiv4) - raw *= 4; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetTemp(double ¶m) -{ - GET_STATUS4(); - uint32_t raw = rx->Temp; - param = (double)raw * 0.6451612903 + -50; - return rx.err; -} -CTR_Code CanTalonSRX::GetBatteryV(double ¶m) -{ - GET_STATUS4(); - uint32_t raw = rx->BatteryV; - param = (double)raw * 0.05 + 4; - return rx.err; -} -CTR_Code CanTalonSRX::GetResetCount(int ¶m) -{ - GET_STATUS5(); - uint32_t raw = 0; - raw |= rx->ResetCountH; - raw <<= 8; - raw |= rx->ResetCountL; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetResetFlags(int ¶m) -{ - GET_STATUS5(); - uint32_t raw = 0; - raw |= rx->ResetFlagsH; - raw <<= 8; - raw |= rx->ResetFlagsL; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetFirmVers(int ¶m) -{ - GET_STATUS5(); - uint32_t raw = 0; - raw |= rx->FirmVersH; - raw <<= 8; - raw |= rx->FirmVersL; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::SetDemand(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->DemandH = param>>16; - toFill->DemandM = param>>8; - toFill->DemandL = param>>0; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetOverrideLimitSwitchEn(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->OverrideLimitSwitchEn = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetFeedbackDeviceSelect(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->FeedbackDeviceSelect = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetRevMotDuringCloseLoopEn(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->RevMotDuringCloseLoopEn = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetOverrideBrakeType(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->OverrideBrakeType = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetModeSelect(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->ModeSelect = param; - FlushTx(toFill); - return CTR_OKAY; -} -/** - * @param modeSelect selects which mode. - * @param demand setpt or throttle or masterId to follow. - * @return error code, 0 iff successful. - * This function has the advantage of atomically setting mode and demand. - */ -CTR_Code CanTalonSRX::SetModeSelect(int modeSelect,int demand) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->ModeSelect = modeSelect; - toFill->DemandH = demand>>16; - toFill->DemandM = demand>>8; - toFill->DemandL = demand>>0; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetProfileSlotSelect(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->ProfileSlotSelect = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetRampThrottle(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->RampThrottle = param; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::SetRevFeedbackSensor(int param) -{ - CtreCanNode::txTask toFill = GetTx(CONTROL_1 | GetDeviceNumber()); - if (toFill.IsEmpty()) return CTR_UnexpectedArbId; - toFill->RevFeedbackSensor = param ? 1 : 0; - FlushTx(toFill); - return CTR_OKAY; -} -CTR_Code CanTalonSRX::GetPulseWidthPosition(int ¶m) -{ - GET_STATUS8(); - int32_t raw = 0; - raw |= rx->PulseWidPositionH; - raw <<= 8; - raw |= rx->PulseWidPositionM; - raw <<= 8; - raw |= rx->PulseWidPositionL; - raw <<= (32-24); /* sign extend */ - raw >>= (32-24); /* sign extend */ - if(rx->PosDiv8) - raw *= 8; - param = (int)raw; - return rx.err; -} -CTR_Code CanTalonSRX::GetPulseWidthVelocity(int ¶m) -{ - GET_STATUS8(); - int32_t raw = 0; - raw |= rx->PulseWidVelH; - raw <<= 8; - raw |= rx->PulseWidVelL; - raw <<= (32-16); /* sign extend */ - raw >>= (32-16); /* sign extend */ - if(rx->VelDiv4) - raw *= 4; - param = (int)raw; - return rx.err; -} -/** - * @param param [out] Rise to rise timeperiod in microseconds. - */ -CTR_Code CanTalonSRX::GetPulseWidthRiseToRiseUs(int ¶m) -{ - GET_STATUS8(); - uint32_t raw = 0; - raw |= rx->PeriodUsM8; - raw <<= 8; - raw |= rx->PeriodUsL8; - param = (int)raw; - return rx.err; -} -/** - * @param param [out] Rise to fall time period in microseconds. - */ -CTR_Code CanTalonSRX::GetPulseWidthRiseToFallUs(int ¶m) -{ - int temp = 0; - int periodUs = 0; - /* first grab our 12.12 position */ - CTR_Code retval1 = GetPulseWidthPosition(temp); - /* mask off number of turns */ - temp &= 0xFFF; - /* next grab the waveform period. This value - * will be zero if we stop getting pulses **/ - CTR_Code retval2 = GetPulseWidthRiseToRiseUs(periodUs); - /* now we have 0.12 position that is scaled to the waveform period. - Use fixed pt multiply to scale our 0.16 period into us.*/ - param = (temp * periodUs) / BIT12; - /* pass the worst error code to caller. - Assume largest value is the most pressing error code.*/ - return (CTR_Code)std::max((int)retval1, (int)retval2); -} -CTR_Code CanTalonSRX::IsPulseWidthSensorPresent(int ¶m) -{ - int periodUs = 0; - CTR_Code retval = GetPulseWidthRiseToRiseUs(periodUs); - /* if a nonzero period is present, we are getting good pules. - Otherwise the sensor is not present. */ - if(periodUs != 0) - param = 1; - else - param = 0; - return retval; -} -//------------------ C interface --------------------------------------------// -extern "C" { -void *c_TalonSRX_Create(int deviceNumber, int controlPeriodMs) -{ - return new CanTalonSRX(deviceNumber, controlPeriodMs); -} -void c_TalonSRX_Destroy(void *handle) -{ - delete (CanTalonSRX*)handle; -} -CTR_Code c_TalonSRX_SetParam(void *handle, int paramEnum, double value) -{ - return ((CanTalonSRX*)handle)->SetParam((CanTalonSRX::param_t)paramEnum, value); -} -CTR_Code c_TalonSRX_RequestParam(void *handle, int paramEnum) -{ - return ((CanTalonSRX*)handle)->RequestParam((CanTalonSRX::param_t)paramEnum); -} -CTR_Code c_TalonSRX_GetParamResponse(void *handle, int paramEnum, double *value) -{ - return ((CanTalonSRX*)handle)->GetParamResponse((CanTalonSRX::param_t)paramEnum, *value); -} -CTR_Code c_TalonSRX_GetParamResponseInt32(void *handle, int paramEnum, int *value) -{ - return ((CanTalonSRX*)handle)->GetParamResponseInt32((CanTalonSRX::param_t)paramEnum, *value); -} -CTR_Code c_TalonSRX_SetStatusFrameRate(void *handle, unsigned frameEnum, unsigned periodMs) -{ - return ((CanTalonSRX*)handle)->SetStatusFrameRate(frameEnum, periodMs); -} -CTR_Code c_TalonSRX_ClearStickyFaults(void *handle) -{ - return ((CanTalonSRX*)handle)->ClearStickyFaults(); -} -CTR_Code c_TalonSRX_GetFault_OverTemp(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_OverTemp(*param); -} -CTR_Code c_TalonSRX_GetFault_UnderVoltage(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_UnderVoltage(*param); -} -CTR_Code c_TalonSRX_GetFault_ForLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_ForLim(*param); -} -CTR_Code c_TalonSRX_GetFault_RevLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_RevLim(*param); -} -CTR_Code c_TalonSRX_GetFault_HardwareFailure(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_HardwareFailure(*param); -} -CTR_Code c_TalonSRX_GetFault_ForSoftLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_ForSoftLim(*param); -} -CTR_Code c_TalonSRX_GetFault_RevSoftLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFault_RevSoftLim(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_OverTemp(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_OverTemp(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_UnderVoltage(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_UnderVoltage(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_ForLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_ForLim(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_RevLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_RevLim(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_ForSoftLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_ForSoftLim(*param); -} -CTR_Code c_TalonSRX_GetStckyFault_RevSoftLim(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetStckyFault_RevSoftLim(*param); -} -CTR_Code c_TalonSRX_GetAppliedThrottle(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetAppliedThrottle(*param); -} -CTR_Code c_TalonSRX_GetCloseLoopErr(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetCloseLoopErr(*param); -} -CTR_Code c_TalonSRX_GetFeedbackDeviceSelect(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFeedbackDeviceSelect(*param); -} -CTR_Code c_TalonSRX_GetModeSelect(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetModeSelect(*param); -} -CTR_Code c_TalonSRX_GetLimitSwitchEn(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetLimitSwitchEn(*param); -} -CTR_Code c_TalonSRX_GetLimitSwitchClosedFor(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetLimitSwitchClosedFor(*param); -} -CTR_Code c_TalonSRX_GetLimitSwitchClosedRev(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetLimitSwitchClosedRev(*param); -} -CTR_Code c_TalonSRX_GetSensorPosition(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetSensorPosition(*param); -} -CTR_Code c_TalonSRX_GetSensorVelocity(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetSensorVelocity(*param); -} -CTR_Code c_TalonSRX_GetCurrent(void *handle, double *param) -{ - return ((CanTalonSRX*)handle)->GetCurrent(*param); -} -CTR_Code c_TalonSRX_GetBrakeIsEnabled(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetBrakeIsEnabled(*param); -} -CTR_Code c_TalonSRX_GetEncPosition(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetEncPosition(*param); -} -CTR_Code c_TalonSRX_GetEncVel(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetEncVel(*param); -} -CTR_Code c_TalonSRX_GetEncIndexRiseEvents(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetEncIndexRiseEvents(*param); -} -CTR_Code c_TalonSRX_GetQuadApin(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetQuadApin(*param); -} -CTR_Code c_TalonSRX_GetQuadBpin(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetQuadBpin(*param); -} -CTR_Code c_TalonSRX_GetQuadIdxpin(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetQuadIdxpin(*param); -} -CTR_Code c_TalonSRX_GetAnalogInWithOv(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetAnalogInWithOv(*param); -} -CTR_Code c_TalonSRX_GetAnalogInVel(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetAnalogInVel(*param); -} -CTR_Code c_TalonSRX_GetTemp(void *handle, double *param) -{ - return ((CanTalonSRX*)handle)->GetTemp(*param); -} -CTR_Code c_TalonSRX_GetBatteryV(void *handle, double *param) -{ - return ((CanTalonSRX*)handle)->GetBatteryV(*param); -} -CTR_Code c_TalonSRX_GetResetCount(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetResetCount(*param); -} -CTR_Code c_TalonSRX_GetResetFlags(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetResetFlags(*param); -} -CTR_Code c_TalonSRX_GetFirmVers(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetFirmVers(*param); -} -CTR_Code c_TalonSRX_SetDemand(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetDemand(param); -} -CTR_Code c_TalonSRX_SetOverrideLimitSwitchEn(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetOverrideLimitSwitchEn(param); -} -CTR_Code c_TalonSRX_SetFeedbackDeviceSelect(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetFeedbackDeviceSelect(param); -} -CTR_Code c_TalonSRX_SetRevMotDuringCloseLoopEn(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetRevMotDuringCloseLoopEn(param); -} -CTR_Code c_TalonSRX_SetOverrideBrakeType(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetOverrideBrakeType(param); -} -CTR_Code c_TalonSRX_SetModeSelect(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetModeSelect(param); -} -CTR_Code c_TalonSRX_SetModeSelect2(void *handle, int modeSelect, int demand) -{ - return ((CanTalonSRX*)handle)->SetModeSelect(modeSelect, demand); -} -CTR_Code c_TalonSRX_SetProfileSlotSelect(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetProfileSlotSelect(param); -} -CTR_Code c_TalonSRX_SetRampThrottle(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetRampThrottle(param); -} -CTR_Code c_TalonSRX_SetRevFeedbackSensor(void *handle, int param) -{ - return ((CanTalonSRX*)handle)->SetRevFeedbackSensor(param); -} -CTR_Code c_TalonSRX_GetPulseWidthPosition(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetPulseWidthPosition(*param); -} -CTR_Code c_TalonSRX_GetPulseWidthVelocity(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetPulseWidthVelocity(*param); -} -CTR_Code c_TalonSRX_GetPulseWidthRiseToFallUs(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetPulseWidthRiseToFallUs(*param); -} -CTR_Code c_TalonSRX_GetPulseWidthRiseToRiseUs(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->GetPulseWidthRiseToRiseUs(*param); -} -CTR_Code c_TalonSRX_IsPulseWidthSensorPresent(void *handle, int *param) -{ - return ((CanTalonSRX*)handle)->IsPulseWidthSensorPresent(*param); -} -} +/** + * @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 + */ +#include "HAL/CanTalonSRX.h" +#include "FRC_NetworkCommunication/CANSessionMux.h" //CAN Comm +#include // memset +#include // usleep + +#define STATUS_1 0x02041400 +#define STATUS_2 0x02041440 +#define STATUS_3 0x02041480 +#define STATUS_4 0x020414C0 +#define STATUS_5 0x02041500 +#define STATUS_6 0x02041540 +#define STATUS_7 0x02041580 +#define STATUS_8 0x020415C0 +#define STATUS_9 0x02041600 + +#define CONTROL_1 0x02040000 +#define CONTROL_2 0x02040040 +#define CONTROL_3 0x02040080 +#define CONTROL_5 0x02040100 +#define CONTROL_6 0x02040140 + +#define EXPECTED_RESPONSE_TIMEOUT_MS (200) +#define GET_STATUS1() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_1 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS2() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_2 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS3() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_3 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS4() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_4 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS5() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_5 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS6() \ + CtreCanNode::recMsg rx = GetRx( \ + STATUS_6 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS7() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_7 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS8() \ + CtreCanNode::recMsg rx = \ + GetRx(STATUS_8 | GetDeviceNumber(), \ + EXPECTED_RESPONSE_TIMEOUT_MS) +#define GET_STATUS9() \ + CtreCanNode::recMsg rx = \ + GetRx( \ + STATUS_9 | GetDeviceNumber(), EXPECTED_RESPONSE_TIMEOUT_MS) + +#define PARAM_REQUEST 0x02041800 +#define PARAM_RESPONSE 0x02041840 +#define PARAM_SET 0x02041880 + +const int kParamArbIdValue = PARAM_RESPONSE; +const int kParamArbIdMask = 0xFFFFFFFF; + +const double FLOAT_TO_FXP_10_22 = (double)0x400000; +const double FXP_TO_FLOAT_10_22 = 0.0000002384185791015625; + +const double FLOAT_TO_FXP_0_8 = (double)0x100; +const double FXP_TO_FLOAT_0_8 = 0.00390625; + +CanTalonSRX::CanTalonSRX(int deviceNumber, int controlPeriodMs, + int enablePeriodMs) + : CtreCanNode(deviceNumber), _can_h(0), _can_stat(0) { + _controlPeriodMs = controlPeriodMs; + _enablePeriodMs = enablePeriodMs; + + /* bound period to be within [1 ms,95 ms] */ + if (_controlPeriodMs < 1) + _controlPeriodMs = 1; + else if (_controlPeriodMs > 95) + _controlPeriodMs = 95; + if (_enablePeriodMs < 1) + _enablePeriodMs = 1; + else if (_enablePeriodMs > 95) + _enablePeriodMs = 95; + + RegisterRx(STATUS_1 | (UINT8)deviceNumber); + RegisterRx(STATUS_2 | (UINT8)deviceNumber); + RegisterRx(STATUS_3 | (UINT8)deviceNumber); + RegisterRx(STATUS_4 | (UINT8)deviceNumber); + RegisterRx(STATUS_5 | (UINT8)deviceNumber); + RegisterRx(STATUS_6 | (UINT8)deviceNumber); + RegisterRx(STATUS_7 | (UINT8)deviceNumber); + /* use the legacy command frame until we have evidence we can use the new + * frame. + */ + RegisterTx(CONTROL_1 | (UINT8)deviceNumber, (UINT8)_controlPeriodMs); + _controlFrameArbId = CONTROL_1; + /* the only default param that is nonzero is limit switch. + * Default to using the flash settings. + */ + SetOverrideLimitSwitchEn(kLimitSwitchOverride_UseDefaultsFromFlash); + /* Check if we can upgrade the control framing */ + UpdateControlId(); +} +/* CanTalonSRX D'tor + */ +CanTalonSRX::~CanTalonSRX() { + if (m_hasBeenMoved) { + /* Another CANTalonSRX still exists, so don't un-register the periodic + * control frame + */ + } else { + /* un-register the control frame so Talon is disabled */ + RegisterTx(CONTROL_1 | (UINT8)GetDeviceNumber(), 0); + RegisterTx(CONTROL_5 | (UINT8)GetDeviceNumber(), 0); + } + /* free the stream we used for SetParam/GetParamResponse */ + if (_can_h) { + FRC_NetworkCommunication_CANSessionMux_closeStreamSession(_can_h); + _can_h = 0; + } +} +/** + * @return true if Talon is reporting that it supports control5, and therefore + * RIO can send control5 to update control params (even when disabled). + */ +bool CanTalonSRX::IsControl5Supported() { + /* only bother to poll status2 if we are looking for cmd5allowed */ + GET_STATUS2(); + if (rx.err != CTR_OKAY) { + /* haven't received it */ + return false; + } else if (0 == rx->Cmd5Allowed) { + /* firmware doesn't support it */ + return false; + } + /* we can use control5, this gives application the ability to set control + * params prior to Talon-enable */ + return true; +} +/** + * Get a copy of the control frame to send. + * @param [out] pointer to eight byte array to fill. + */ +void CanTalonSRX::GetControlFrameCopy(uint8_t *toFill) { + /* get the copy of the control frame in control1 */ + CtreCanNode::txTask task = + GetTx(_controlFrameArbId | + GetDeviceNumber()); + /* control1's payload will move to 5, but update the new sigs in control5 */ + if (task.IsEmpty()) + memset(toFill, 0, 8); + else + memcpy(toFill, task.toSend, 8); + /* zero first two bytes - these are reserved. */ + toFill[0] = 0; + toFill[1] = 0; +} +/** + * 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 CanTalonSRX::UpdateControlId() { + uint8_t work[8]; + uint32_t frameToUse; + /* deduce if we should change IDs. If firm supports the new frame, and + * calling app isn't forcing legacy mode + * use control5.*/ + if (_useControl5ifSupported && IsControl5Supported()) { + frameToUse = CONTROL_5; + } else { + frameToUse = CONTROL_1; + } + /* is there anything to do */ + if (frameToUse == _controlFrameArbId) { + /* nothing to do, we are using the best frame. */ + } else if (frameToUse == CONTROL_5) { + /* get a copy of the control frame */ + GetControlFrameCopy(work); + /* Change control1's DLC to 2. Passing nullptr means all payload bytes are + * zero. */ + RegisterTx(CONTROL_1 | GetDeviceNumber(), _enablePeriodMs, 2, nullptr); + /* reregister the control frame using the new ID */ + RegisterTx(frameToUse | GetDeviceNumber(), _controlPeriodMs, 8, work); + /* save the correct frame ArbID */ + _controlFrameArbId = frameToUse; + } else if (frameToUse == CONTROL_1) { + GetControlFrameCopy(work); + /* stop sending control 5 */ + UnregisterTx(CONTROL_5 | GetDeviceNumber()); + /* reregister the control frame using the new ID */ + RegisterTx(frameToUse | GetDeviceNumber(), _controlPeriodMs, 8, work); + /* save the correct frame ArbID */ + _controlFrameArbId = frameToUse; + } +} +void CanTalonSRX::OpenSessionIfNeedBe() { + _can_stat = 0; + if (_can_h == 0) { + /* bit30 - bit8 must match $000002XX. Top bit is not masked to get remote + * frames */ + FRC_NetworkCommunication_CANSessionMux_openStreamSession( + &_can_h, kParamArbIdValue | GetDeviceNumber(), kParamArbIdMask, + kMsgCapacity, &_can_stat); + if (_can_stat == 0) { + /* success */ + } else { + /* something went wrong, try again later */ + _can_h = 0; + } + } +} +void CanTalonSRX::ProcessStreamMessages() { + if (0 == _can_h) OpenSessionIfNeedBe(); + /* process receive messages */ + uint32_t i; + uint32_t messagesToRead = sizeof(_msgBuff) / sizeof(_msgBuff[0]); + uint32_t messagesRead = 0; + /* read out latest bunch of messages */ + _can_stat = 0; + if (_can_h) { + FRC_NetworkCommunication_CANSessionMux_readStreamSession( + _can_h, _msgBuff, messagesToRead, &messagesRead, &_can_stat); + } + /* loop thru each message of interest */ + for (i = 0; i < messagesRead; ++i) { + tCANStreamMessage *msg = _msgBuff + i; + if (msg->messageID == (PARAM_RESPONSE | GetDeviceNumber())) { + TALON_Param_Response_t *paramResp = (TALON_Param_Response_t *)msg->data; + /* decode value */ + int32_t val = paramResp->ParamValueH; + val <<= 8; + val |= paramResp->ParamValueMH; + val <<= 8; + val |= paramResp->ParamValueML; + val <<= 8; + val |= paramResp->ParamValueL; + /* save latest signal */ + _sigs[paramResp->ParamEnum] = val; + } else { + int brkpthere = 42; + ++brkpthere; + } + } +} +void CanTalonSRX::Set(double value) { + if (value > 1) + value = 1; + else if (value < -1) + value = -1; + SetDemand(1023 * value); /* must be within [-1023,1023] */ +} +/*---------------------setters and getters that use the 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 CanTalonSRX::SetParamRaw(unsigned paramEnum, int rawBits) { + /* caller is using param API. Open session if it hasn'T been done. */ + if (0 == _can_h) OpenSessionIfNeedBe(); + TALON_Param_Response_t frame; + memset(&frame, 0, sizeof(frame)); + frame.ParamEnum = paramEnum; + frame.ParamValueH = rawBits >> 0x18; + frame.ParamValueMH = rawBits >> 0x10; + frame.ParamValueML = rawBits >> 0x08; + frame.ParamValueL = rawBits; + int32_t status = 0; + FRC_NetworkCommunication_CANSessionMux_sendMessage( + PARAM_SET | GetDeviceNumber(), (const uint8_t *)&frame, 5, 0, &status); + /* small hook here if we want the API itself to react to set commands */ + switch (paramEnum) { + case eLegacyControlMode: + if (rawBits != 0) { + /* caller wants to force legacy framing */ + _useControl5ifSupported = false; + } else { + /* caller wants to let the API decide */ + _useControl5ifSupported = true; + } + /* recheck IDs now that flag has changed */ + UpdateControlId(); + break; + } + /* for now have a general failure if we can't transmit */ + if (status) return CTR_TxFailed; + return CTR_OKAY; +} +/** + * Checks cached CAN frames and updating solicited signals. + */ +CTR_Code CanTalonSRX::GetParamResponseRaw(unsigned paramEnum, int &rawBits) { + CTR_Code retval = CTR_OKAY; + /* process received param events. We don't expect many since this API is not + * used often. */ + ProcessStreamMessages(); + /* grab the solicited signal value */ + sigs_t::iterator i = _sigs.find(paramEnum); + if (i == _sigs.end()) { + retval = CTR_SigNotUpdated; + } else { + rawBits = i->second; + } + return retval; +} +/** + * 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 CanTalonSRX::RequestParam(param_t paramEnum) { + /* process received param events. We don't expect many since this API is not + * used often. */ + ProcessStreamMessages(); + TALON_Param_Request_t frame; + memset(&frame, 0, sizeof(frame)); + frame.ParamEnum = paramEnum; + int32_t status = 0; + FRC_NetworkCommunication_CANSessionMux_sendMessage( + PARAM_REQUEST | GetDeviceNumber(), (const uint8_t *)&frame, 1, 0, + &status); + if (status) return CTR_TxFailed; + return CTR_OKAY; +} + +CTR_Code CanTalonSRX::SetParam(param_t paramEnum, double value) { + int32_t rawbits = 0; + switch (paramEnum) { + case eProfileParamSlot0_P: /* unsigned 10.22 fixed pt value */ + case eProfileParamSlot0_I: + case eProfileParamSlot0_D: + case eProfileParamSlot1_P: + case eProfileParamSlot1_I: + case eProfileParamSlot1_D: { + uint32_t urawbits; + value = std::min( + value, 1023.0); /* bounds check doubles that are outside u10.22 */ + value = std::max(value, 0.0); + urawbits = value * FLOAT_TO_FXP_10_22; /* perform unsign arithmetic */ + rawbits = urawbits; /* copy bits over. SetParamRaw just stuffs into CAN + frame with no sense of signedness */ + } break; + case eProfileParamSlot1_F: /* signed 10.22 fixed pt value */ + case eProfileParamSlot0_F: + value = std::min( + value, 512.0); /* bounds check doubles that are outside s10.22 */ + value = std::max(value, -512.0); + rawbits = value * FLOAT_TO_FXP_10_22; + break; + case eProfileParamVcompRate: /* unsigned 0.8 fixed pt value volts per ms */ + /* within [0,1) volts per ms. + Slowest ramp is 1/256 VperMilliSec or 3.072 seconds from 0-to-12V. + Fastest ramp is 255/256 VperMilliSec or 12.1ms from 0-to-12V. + */ + if (value <= 0) { + /* negative or zero (disable), send raw value of zero */ + rawbits = 0; + } else { + /* nonzero ramping */ + rawbits = value * FLOAT_TO_FXP_0_8; + /* since whole part is cleared, cap to just under whole unit */ + if (rawbits > (FLOAT_TO_FXP_0_8 - 1)) rawbits = (FLOAT_TO_FXP_0_8 - 1); + /* since ramping is nonzero, cap to smallest ramp rate possible */ + if (rawbits == 0) { + /* caller is providing a nonzero ramp rate that's too small + to serialize, so cap to smallest possible */ + rawbits = 1; + } + } + break; + default: /* everything else is integral */ + rawbits = (int32_t)value; + break; + } + return SetParamRaw(paramEnum, rawbits); +} +CTR_Code CanTalonSRX::GetParamResponse(param_t paramEnum, double &value) { + int32_t rawbits = 0; + CTR_Code retval = GetParamResponseRaw(paramEnum, rawbits); + switch (paramEnum) { + case eProfileParamSlot0_P: /* 10.22 fixed pt value */ + case eProfileParamSlot0_I: + case eProfileParamSlot0_D: + case eProfileParamSlot0_F: + case eProfileParamSlot1_P: + case eProfileParamSlot1_I: + case eProfileParamSlot1_D: + case eProfileParamSlot1_F: + case eCurrent: + case eTemp: + case eBatteryV: + value = ((double)rawbits) * FXP_TO_FLOAT_10_22; + break; + case eProfileParamVcompRate: + value = ((double)rawbits) * FXP_TO_FLOAT_0_8; + break; + default: /* everything else is integral */ + value = (double)rawbits; + break; + } + return retval; +} +CTR_Code CanTalonSRX::GetParamResponseInt32(param_t paramEnum, int &value) { + double dvalue = 0; + CTR_Code retval = GetParamResponse(paramEnum, dvalue); + value = (int32_t)dvalue; + return retval; +} +/*----- 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 CanTalonSRX::SetPgain(unsigned slotIdx, double gain) { + if (slotIdx == 0) return SetParam(eProfileParamSlot0_P, gain); + return SetParam(eProfileParamSlot1_P, gain); +} +CTR_Code CanTalonSRX::SetIgain(unsigned slotIdx, double gain) { + if (slotIdx == 0) return SetParam(eProfileParamSlot0_I, gain); + return SetParam(eProfileParamSlot1_I, gain); +} +CTR_Code CanTalonSRX::SetDgain(unsigned slotIdx, double gain) { + if (slotIdx == 0) return SetParam(eProfileParamSlot0_D, gain); + return SetParam(eProfileParamSlot1_D, gain); +} +CTR_Code CanTalonSRX::SetFgain(unsigned slotIdx, double gain) { + if (slotIdx == 0) return SetParam(eProfileParamSlot0_F, gain); + return SetParam(eProfileParamSlot1_F, gain); +} +CTR_Code CanTalonSRX::SetIzone(unsigned slotIdx, int zone) { + if (slotIdx == 0) return SetParam(eProfileParamSlot0_IZone, zone); + return SetParam(eProfileParamSlot1_IZone, zone); +} +CTR_Code CanTalonSRX::SetCloseLoopRampRate(unsigned slotIdx, + int closeLoopRampRate) { + if (slotIdx == 0) + return SetParam(eProfileParamSlot0_CloseLoopRampRate, closeLoopRampRate); + return SetParam(eProfileParamSlot1_CloseLoopRampRate, closeLoopRampRate); +} +CTR_Code CanTalonSRX::SetVoltageCompensationRate(double voltagePerMs) { + return SetParam(eProfileParamVcompRate, voltagePerMs); +} +CTR_Code CanTalonSRX::GetPgain(unsigned slotIdx, double &gain) { + if (slotIdx == 0) return GetParamResponse(eProfileParamSlot0_P, gain); + return GetParamResponse(eProfileParamSlot1_P, gain); +} +CTR_Code CanTalonSRX::GetIgain(unsigned slotIdx, double &gain) { + if (slotIdx == 0) return GetParamResponse(eProfileParamSlot0_I, gain); + return GetParamResponse(eProfileParamSlot1_I, gain); +} +CTR_Code CanTalonSRX::GetDgain(unsigned slotIdx, double &gain) { + if (slotIdx == 0) return GetParamResponse(eProfileParamSlot0_D, gain); + return GetParamResponse(eProfileParamSlot1_D, gain); +} +CTR_Code CanTalonSRX::GetFgain(unsigned slotIdx, double &gain) { + if (slotIdx == 0) return GetParamResponse(eProfileParamSlot0_F, gain); + return GetParamResponse(eProfileParamSlot1_F, gain); +} +CTR_Code CanTalonSRX::GetIzone(unsigned slotIdx, int &zone) { + if (slotIdx == 0) + return GetParamResponseInt32(eProfileParamSlot0_IZone, zone); + return GetParamResponseInt32(eProfileParamSlot1_IZone, zone); +} +CTR_Code CanTalonSRX::GetCloseLoopRampRate(unsigned slotIdx, + int &closeLoopRampRate) { + if (slotIdx == 0) + return GetParamResponseInt32(eProfileParamSlot0_CloseLoopRampRate, + closeLoopRampRate); + return GetParamResponseInt32(eProfileParamSlot1_CloseLoopRampRate, + closeLoopRampRate); +} +CTR_Code CanTalonSRX::GetVoltageCompensationRate(double &voltagePerMs) { + return GetParamResponse(eProfileParamVcompRate, voltagePerMs); +} +CTR_Code CanTalonSRX::SetSensorPosition(int pos) { + return SetParam(eSensorPosition, pos); +} +CTR_Code CanTalonSRX::SetForwardSoftLimit(int forwardLimit) { + return SetParam(eProfileParamSoftLimitForThreshold, forwardLimit); +} +CTR_Code CanTalonSRX::SetReverseSoftLimit(int reverseLimit) { + return SetParam(eProfileParamSoftLimitRevThreshold, reverseLimit); +} +CTR_Code CanTalonSRX::SetForwardSoftEnable(int enable) { + return SetParam(eProfileParamSoftLimitForEnable, enable); +} +CTR_Code CanTalonSRX::SetReverseSoftEnable(int enable) { + return SetParam(eProfileParamSoftLimitRevEnable, enable); +} +CTR_Code CanTalonSRX::GetForwardSoftLimit(int &forwardLimit) { + return GetParamResponseInt32(eProfileParamSoftLimitForThreshold, + forwardLimit); +} +CTR_Code CanTalonSRX::GetReverseSoftLimit(int &reverseLimit) { + return GetParamResponseInt32(eProfileParamSoftLimitRevThreshold, + reverseLimit); +} +CTR_Code CanTalonSRX::GetForwardSoftEnable(int &enable) { + return GetParamResponseInt32(eProfileParamSoftLimitForEnable, enable); +} +CTR_Code CanTalonSRX::GetReverseSoftEnable(int &enable) { + return GetParamResponseInt32(eProfileParamSoftLimitRevEnable, enable); +} +/** + * @param param [out] Rise to fall time period in microseconds. + */ +CTR_Code CanTalonSRX::GetPulseWidthRiseToFallUs(int ¶m) { + int temp = 0; + int periodUs = 0; + /* first grab our 12.12 position */ + CTR_Code retval1 = GetPulseWidthPosition(temp); + /* mask off number of turns */ + temp &= 0xFFF; + /* next grab the waveform period. This value + * will be zero if we stop getting pulses **/ + CTR_Code retval2 = GetPulseWidthRiseToRiseUs(periodUs); + /* now we have 0.12 position that is scaled to the waveform period. + Use fixed pt multiply to scale our 0.16 period into us.*/ + param = (temp * periodUs) / BIT12; + /* pass the worst error code to caller. + Assume largest value is the most pressing error code.*/ + return (CTR_Code)std::max((int)retval1, (int)retval2); +} +CTR_Code CanTalonSRX::IsPulseWidthSensorPresent(int ¶m) { + int periodUs = 0; + CTR_Code retval = GetPulseWidthRiseToRiseUs(periodUs); + /* if a nonzero period is present, we are getting good pules. + Otherwise the sensor is not present. */ + if (periodUs != 0) + param = 1; + else + param = 0; + return retval; +} +/** + * @param modeSelect selects which mode. + * @param demand setpt or throttle or masterId to follow. + * @return error code, 0 iff successful. + * This function has the advantage of atomically setting mode and demand. + */ +CTR_Code CanTalonSRX::SetModeSelect(int modeSelect, int demand) { + CtreCanNode::txTask toFill = + GetTx(_controlFrameArbId | + GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->ModeSelect = modeSelect; + toFill->DemandH = demand >> 16; + toFill->DemandM = demand >> 8; + toFill->DemandL = demand >> 0; + FlushTx(toFill); + return CTR_OKAY; +} +/** + * Change the periodMs of a TALON's status frame. See kStatusFrame_* enums for + * what's available. + */ +CTR_Code CanTalonSRX::SetStatusFrameRate(unsigned frameEnum, + unsigned periodMs) { + CTR_Code retval = CTR_OKAY; + int32_t paramEnum = 0; + /* bounds check the period */ + if (periodMs < 1) + periodMs = 1; + else if (periodMs > 255) + periodMs = 255; + uint8_t period = (uint8_t)periodMs; + /* lookup the correct param enum based on what frame to rate-change */ + switch (frameEnum) { + case kStatusFrame_General: + paramEnum = eStatus1FrameRate; + break; + case kStatusFrame_Feedback: + paramEnum = eStatus2FrameRate; + break; + case kStatusFrame_Encoder: + paramEnum = eStatus3FrameRate; + break; + case kStatusFrame_AnalogTempVbat: + paramEnum = eStatus4FrameRate; + break; + case kStatusFrame_PulseWidthMeas: + paramEnum = eStatus8FrameRate; + break; + case kStatusFrame_MotionProfile: + paramEnum = eStatus9FrameRate; + break; + default: + /* caller's request is not support, return an error code */ + retval = CTR_InvalidParamValue; + break; + } + /* if lookup was succesful, send set-request out */ + if (retval == CTR_OKAY) { + /* paramEnum is updated, sent it out */ + retval = SetParamRaw(paramEnum, period); + } + return retval; +} +/** + * Clear all sticky faults in TALON. + */ +CTR_Code CanTalonSRX::ClearStickyFaults() { + int32_t status = 0; + /* build request frame */ + TALON_Control_3_ClearFlags_OneShot_t frame; + memset(&frame, 0, sizeof(frame)); + frame.ClearStickyFaults = 1; + FRC_NetworkCommunication_CANSessionMux_sendMessage( + CONTROL_3 | GetDeviceNumber(), (const uint8_t *)&frame, sizeof(frame), 0, + &status); + if (status) return CTR_TxFailed; + return CTR_OKAY; +} +/** + * @return the tx task that transmits Control6 (motion profile control). + * If it's not scheduled, then schedule it. This is part of firing + * the MotionProf framing only when needed to save bandwidth. + */ +CtreCanNode::txTask +CanTalonSRX::GetControl6() { + CtreCanNode::txTask control6 = + GetTx(CONTROL_6 | + GetDeviceNumber()); + if (control6.IsEmpty()) { + /* control6 never started, arm it now */ + RegisterTx(CONTROL_6 | GetDeviceNumber(), _control6PeriodMs); + control6 = GetTx(CONTROL_6 | + GetDeviceNumber()); + control6->Idx = 0; + _motProfFlowControl = 0; + FlushTx(control6); + } + return control6; +} +/** + * 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 CanTalonSRX::ChangeMotionControlFramePeriod(uint32_t periodMs) { + std::unique_lock lock(_mutMotProf); + /* if message is already registered, it will get updated. + * Otherwise it will error if it hasn't been setup yet, but that's ok + * because the _control6PeriodMs will be used later. + * @see GetControl6 + */ + _control6PeriodMs = periodMs; + ChangeTxPeriod(CONTROL_6 | GetDeviceNumber(), _control6PeriodMs); +} +/** + * Clear the buffered motion profile in both Talon RAM (bottom), and in the API + * (top). + */ +void CanTalonSRX::ClearMotionProfileTrajectories() { + std::unique_lock lock(_mutMotProf); + /* clear the top buffer */ + _motProfTopBuffer.Clear(); + /* send signal to clear bottom buffer */ + auto toFill = CanTalonSRX::GetControl6(); + toFill->Idx = 0; + _motProfFlowControl = 0; /* match the transmitted flow control */ + FlushTx(toFill); +} +/** + * 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 CanTalonSRX::GetMotionProfileTopLevelBufferCount() { + std::unique_lock lock(_mutMotProf); + uint32_t retval = (uint32_t)_motProfTopBuffer.GetNumTrajectories(); + return retval; +} +/** + * 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 CanTalonSRX::IsMotionProfileTopLevelBufferFull() { + std::unique_lock lock(_mutMotProf); + if (_motProfTopBuffer.GetNumTrajectories() >= kMotionProfileTopBufferCapacity) + return true; + return false; +} +/** + * 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 + * never 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 CanTalonSRX::PushMotionProfileTrajectory(int targPos, int targVel, + int profileSlotSelect, + int timeDurMs, int velOnly, + int isLastPoint, + int zeroPos) { + ReactToMotionProfileCall(); + /* create our trajectory point */ + TALON_Control_6_MotProfAddTrajPoint_huff0_t traj; + memset((void *)&traj, 0, sizeof(traj)); + traj.NextPt_ZeroPosition = zeroPos ? 1 : 0; + traj.NextPt_VelOnly = velOnly ? 1 : 0; + traj.NextPt_IsLast = isLastPoint ? 1 : 0; + traj.NextPt_ProfileSlotSelect = (profileSlotSelect > 0) ? 1 : 0; + if (timeDurMs < 0) + timeDurMs = 0; + else if (timeDurMs > 255) + timeDurMs = 255; + traj.NextPt_DurationMs = timeDurMs; + traj.NextPt_VelocityH = targVel >> 0x08; + traj.NextPt_VelocityL = targVel & 0xFF; + traj.NextPt_PositionH = targPos >> 0x10; + traj.NextPt_PositionM = targPos >> 0x08; + traj.NextPt_PositionL = targPos & 0xFF; + + std::unique_lock lock(_mutMotProf); + if (_motProfTopBuffer.GetNumTrajectories() >= kMotionProfileTopBufferCapacity) + return CTR_BufferFull; + _motProfTopBuffer.Push(traj); + return CTR_OKAY; +} +/** + * Increment our flow control to manage streaming to the Talon. + * f(x) = { 1, x = 15, + * x+1, x < 15 + * } + */ +#define MotionProf_IncrementSync(idx) ((idx >= 15) ? 1 : 0) + ((idx + 1) & 0xF) +/** + * 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 CanTalonSRX::CopyTrajPtIntoControl( + TALON_Control_6_MotProfAddTrajPoint_t *control, + const TALON_Control_6_MotProfAddTrajPoint_t *newPt) { + /* Bring over the common signals in the first two bytes */ + control->NextPt_ProfileSlotSelect = newPt->NextPt_ProfileSlotSelect; + control->NextPt_ZeroPosition = newPt->NextPt_ZeroPosition; + control->NextPt_VelOnly = newPt->NextPt_VelOnly; + control->NextPt_IsLast = newPt->NextPt_IsLast; + control->huffCode = newPt->huffCode; + /* the last six bytes are entirely for hold NextPt's values. */ + uint8_t *dest = (uint8_t *)control; + const uint8_t *src = (const uint8_t *)newPt; + dest[2] = src[2]; + dest[3] = src[3]; + dest[4] = src[4]; + dest[5] = src[5]; + dest[6] = src[6]; + dest[7] = src[7]; +} +/** + * 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 CanTalonSRX::ReactToMotionProfileCall() { + if (_motProfFlowControl < 0) { + /* we have not yet armed the periodic frame. We do this lazilly to + * save bus utilization since most Talons on the bus probably are not + * MP'ing. + */ + ClearMotionProfileTrajectories(); /* this moves flow control so only fires + once if ever */ + } +} +/** + * 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 CanTalonSRX::ProcessMotionProfileBuffer() { + ReactToMotionProfileCall(); + /* get the latest status frame */ + GET_STATUS9(); + /* lock */ + std::unique_lock lock(_mutMotProf); + /* calc what we expect to receive */ + if (_motProfFlowControl == rx->NextID) { + /* Talon has completed the last req */ + if (_motProfTopBuffer.IsEmpty()) { + /* nothing to do */ + } else { + /* get the latest control frame */ + auto toFill = GetControl6(); + TALON_Control_6_MotProfAddTrajPoint_t *front = _motProfTopBuffer.Front(); + CopyTrajPtIntoControl(toFill.toSend, front); + _motProfTopBuffer.Pop(); + _motProfFlowControl = MotionProf_IncrementSync(_motProfFlowControl); + toFill->Idx = _motProfFlowControl; + FlushTx(toFill); + } + } else { + /* still waiting on Talon */ + } +} +/** + * 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 CanTalonSRX::GetMotionProfileStatus( + uint32_t &flags, uint32_t &profileSlotSelect, int32_t &targPos, + int32_t &targVel, uint32_t &topBufferRem, uint32_t &topBufferCnt, + uint32_t &btmBufferCnt, uint32_t &outputEnable) { + /* get the latest status frame */ + GET_STATUS9(); + + /* clear signals in case we never received an update, caller should check + * return + */ + flags = 0; + profileSlotSelect = 0; + targPos = 0; + targVel = 0; + btmBufferCnt = 0; + + /* these signals are always available */ + topBufferCnt = _motProfTopBuffer.GetNumTrajectories(); + topBufferRem = + kMotionProfileTopBufferCapacity - _motProfTopBuffer.GetNumTrajectories(); + + /* TODO: make enums or make a better method prototype */ + if (rx->ActTraj_IsValid) flags |= kMotionProfileFlag_ActTraj_IsValid; + if (rx->HasUnderrun) flags |= kMotionProfileFlag_HasUnderrun; + if (rx->IsUnderrun) flags |= kMotionProfileFlag_IsUnderrun; + if (rx->ActTraj_IsLast) flags |= kMotionProfileFlag_ActTraj_IsLast; + if (rx->ActTraj_VelOnly) flags |= kMotionProfileFlag_ActTraj_VelOnly; + + btmBufferCnt = rx->Count; + + targPos = rx->ActTraj_PositionH; + targPos <<= 8; + targPos |= rx->ActTraj_PositionM; + targPos <<= 8; + targPos |= rx->ActTraj_PositionL; + + targVel = rx->ActTraj_VelocityH; + targVel <<= 8; + targVel |= rx->ActTraj_VelocityL; + + profileSlotSelect = rx->ActTraj_ProfileSlotSelect; + + switch (rx->OutputType) { + case kMotionProf_Disabled: + case kMotionProf_Enable: + case kMotionProf_Hold: + outputEnable = rx->OutputType; + break; + default: + /* do now allow invalid values for sake of user-facing enum types */ + outputEnable = kMotionProf_Disabled; + break; + } + return rx.err; +} +//------------------------ 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 CanTalonSRX::GetFault_OverTemp(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_OverTemp; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_UnderVoltage(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_UnderVoltage; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_ForLim(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_ForLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_RevLim(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_RevLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_HardwareFailure(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_HardwareFailure; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_ForSoftLim(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_ForSoftLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetFault_RevSoftLim(int ¶m) +{ + GET_STATUS1(); + param = rx->Fault_RevSoftLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_OverTemp(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_OverTemp; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_UnderVoltage(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_UnderVoltage; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_ForLim(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_ForLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_RevLim(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_RevLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_ForSoftLim(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_ForSoftLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetStckyFault_RevSoftLim(int ¶m) +{ + GET_STATUS2(); + param = rx->StckyFault_RevSoftLim; + return rx.err; +} +CTR_Code CanTalonSRX::GetAppliedThrottle(int ¶m) +{ + GET_STATUS1(); + int32_t raw = 0; + raw |= rx->AppliedThrottle_h3; + raw <<= 8; + raw |= rx->AppliedThrottle_l8; + raw <<= (32-11); /* sign extend */ + raw >>= (32-11); /* sign extend */ + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetCloseLoopErr(int ¶m) +{ + GET_STATUS1(); + int32_t raw = 0; + raw |= rx->CloseLoopErrH; + raw <<= 16 - 8; + raw |= rx->CloseLoopErrM; + raw <<= 8; + raw |= rx->CloseLoopErrL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetFeedbackDeviceSelect(int ¶m) +{ + GET_STATUS1(); + param = rx->FeedbackDeviceSelect; + return rx.err; +} +CTR_Code CanTalonSRX::GetModeSelect(int ¶m) +{ + GET_STATUS1(); + uint32_t raw = 0; + raw |= rx->ModeSelect_h1; + raw <<= 3; + raw |= rx->ModeSelect_b3; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetLimitSwitchEn(int ¶m) +{ + GET_STATUS1(); + param = rx->LimitSwitchEn; + return rx.err; +} +CTR_Code CanTalonSRX::GetLimitSwitchClosedFor(int ¶m) +{ + GET_STATUS1(); + param = rx->LimitSwitchClosedFor; + return rx.err; +} +CTR_Code CanTalonSRX::GetLimitSwitchClosedRev(int ¶m) +{ + GET_STATUS1(); + param = rx->LimitSwitchClosedRev; + return rx.err; +} +CTR_Code CanTalonSRX::GetSensorPosition(int ¶m) +{ + GET_STATUS2(); + int32_t raw = 0; + raw |= rx->SensorPositionH; + raw <<= 16 - 8; + raw |= rx->SensorPositionM; + raw <<= 8; + raw |= rx->SensorPositionL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + if(rx->PosDiv8) + raw *= 8; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetSensorVelocity(int ¶m) +{ + GET_STATUS2(); + int32_t raw = 0; + raw |= rx->SensorVelocityH; + raw <<= 8; + raw |= rx->SensorVelocityL; + raw <<= (32-16); /* sign extend */ + raw >>= (32-16); /* sign extend */ + if(rx->VelDiv4) + raw *= 4; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetCurrent(double ¶m) +{ + GET_STATUS2(); + uint32_t raw = 0; + raw |= rx->Current_h8; + raw <<= 2; + raw |= rx->Current_l2; + param = (double)raw * 0.125 + 0; + return rx.err; +} +CTR_Code CanTalonSRX::GetBrakeIsEnabled(int ¶m) +{ + GET_STATUS2(); + param = rx->BrakeIsEnabled; + return rx.err; +} +CTR_Code CanTalonSRX::GetEncPosition(int ¶m) +{ + GET_STATUS3(); + int32_t raw = 0; + raw |= rx->EncPositionH; + raw <<= 16 - 8; + raw |= rx->EncPositionM; + raw <<= 8; + raw |= rx->EncPositionL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + if(rx->PosDiv8) + raw *= 8; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetEncVel(int ¶m) +{ + GET_STATUS3(); + int32_t raw = 0; + raw |= rx->EncVelH; + raw <<= 8; + raw |= rx->EncVelL; + raw <<= (32-16); /* sign extend */ + raw >>= (32-16); /* sign extend */ + if(rx->VelDiv4) + raw *= 4; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetEncIndexRiseEvents(int ¶m) +{ + GET_STATUS3(); + uint32_t raw = 0; + raw |= rx->EncIndexRiseEventsH; + raw <<= 8; + raw |= rx->EncIndexRiseEventsL; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetQuadApin(int ¶m) +{ + GET_STATUS3(); + param = rx->QuadApin; + return rx.err; +} +CTR_Code CanTalonSRX::GetQuadBpin(int ¶m) +{ + GET_STATUS3(); + param = rx->QuadBpin; + return rx.err; +} +CTR_Code CanTalonSRX::GetQuadIdxpin(int ¶m) +{ + GET_STATUS3(); + param = rx->QuadIdxpin; + return rx.err; +} +CTR_Code CanTalonSRX::GetAnalogInWithOv(int ¶m) +{ + GET_STATUS4(); + int32_t raw = 0; + raw |= rx->AnalogInWithOvH; + raw <<= 16 - 8; + raw |= rx->AnalogInWithOvM; + raw <<= 8; + raw |= rx->AnalogInWithOvL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + if(rx->PosDiv8) + raw *= 8; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetAnalogInVel(int ¶m) +{ + GET_STATUS4(); + int32_t raw = 0; + raw |= rx->AnalogInVelH; + raw <<= 8; + raw |= rx->AnalogInVelL; + raw <<= (32-16); /* sign extend */ + raw >>= (32-16); /* sign extend */ + if(rx->VelDiv4) + raw *= 4; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetTemp(double ¶m) +{ + GET_STATUS4(); + uint32_t raw = rx->Temp; + param = (double)raw * 0.6451612903 + -50; + return rx.err; +} +CTR_Code CanTalonSRX::GetBatteryV(double ¶m) +{ + GET_STATUS4(); + uint32_t raw = rx->BatteryV; + param = (double)raw * 0.05 + 4; + return rx.err; +} +CTR_Code CanTalonSRX::GetResetCount(int ¶m) +{ + GET_STATUS5(); + uint32_t raw = 0; + raw |= rx->ResetCountH; + raw <<= 8; + raw |= rx->ResetCountL; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetResetFlags(int ¶m) +{ + GET_STATUS5(); + uint32_t raw = 0; + raw |= rx->ResetFlagsH; + raw <<= 8; + raw |= rx->ResetFlagsL; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetFirmVers(int ¶m) +{ + GET_STATUS5(); + uint32_t raw = 0; + raw |= rx->FirmVersH; + raw <<= 8; + raw |= rx->FirmVersL; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetPulseWidthPosition(int ¶m) +{ + GET_STATUS8(); + int32_t raw = 0; + raw |= rx->PulseWidPositionH; + raw <<= 16 - 8; + raw |= rx->PulseWidPositionM; + raw <<= 8; + raw |= rx->PulseWidPositionL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + if(rx->PosDiv8) + raw *= 8; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetPulseWidthVelocity(int ¶m) +{ + GET_STATUS8(); + int32_t raw = 0; + raw |= rx->PulseWidVelH; + raw <<= 8; + raw |= rx->PulseWidVelL; + raw <<= (32-16); /* sign extend */ + raw >>= (32-16); /* sign extend */ + if(rx->VelDiv4) + raw *= 4; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetPulseWidthRiseToRiseUs(int ¶m) +{ + GET_STATUS8(); + uint32_t raw = 0; + raw |= rx->PeriodUsM8; + raw <<= 8; + raw |= rx->PeriodUsL8; + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_IsValid(int ¶m) +{ + GET_STATUS9(); + param = rx->ActTraj_IsValid; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_ProfileSlotSelect(int ¶m) +{ + GET_STATUS9(); + param = rx->ActTraj_ProfileSlotSelect; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_VelOnly(int ¶m) +{ + GET_STATUS9(); + param = rx->ActTraj_VelOnly; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_IsLast(int ¶m) +{ + GET_STATUS9(); + param = rx->ActTraj_IsLast; + return rx.err; +} +CTR_Code CanTalonSRX::GetOutputType(int ¶m) +{ + GET_STATUS9(); + param = rx->OutputType; + return rx.err; +} +CTR_Code CanTalonSRX::GetHasUnderrun(int ¶m) +{ + GET_STATUS9(); + param = rx->HasUnderrun; + return rx.err; +} +CTR_Code CanTalonSRX::GetIsUnderrun(int ¶m) +{ + GET_STATUS9(); + param = rx->IsUnderrun; + return rx.err; +} +CTR_Code CanTalonSRX::GetNextID(int ¶m) +{ + GET_STATUS9(); + param = rx->NextID; + return rx.err; +} +CTR_Code CanTalonSRX::GetBufferIsFull(int ¶m) +{ + GET_STATUS9(); + param = rx->BufferIsFull; + return rx.err; +} +CTR_Code CanTalonSRX::GetCount(int ¶m) +{ + GET_STATUS9(); + param = rx->Count; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_Velocity(int ¶m) +{ + GET_STATUS9(); + int32_t raw = 0; + raw |= rx->ActTraj_VelocityH; + raw <<= 8; + raw |= rx->ActTraj_VelocityL; + raw <<= (32-16); /* sign extend */ + raw >>= (32-16); /* sign extend */ + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::GetActTraj_Position(int ¶m) +{ + GET_STATUS9(); + int32_t raw = 0; + raw |= rx->ActTraj_PositionH; + raw <<= 16 - 8; + raw |= rx->ActTraj_PositionM; + raw <<= 8; + raw |= rx->ActTraj_PositionL; + raw <<= (32-24); /* sign extend */ + raw >>= (32-24); /* sign extend */ + param = (int)raw; + return rx.err; +} +CTR_Code CanTalonSRX::SetDemand(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->DemandH = param>>16; + toFill->DemandM = param>>8; + toFill->DemandL = param>>0; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetOverrideLimitSwitchEn(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->OverrideLimitSwitchEn = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetFeedbackDeviceSelect(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->FeedbackDeviceSelect = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetRevMotDuringCloseLoopEn(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->RevMotDuringCloseLoopEn = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetOverrideBrakeType(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->OverrideBrakeType = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetModeSelect(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->ModeSelect = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetProfileSlotSelect(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->ProfileSlotSelect = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetRampThrottle(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->RampThrottle = param; + FlushTx(toFill); + return CTR_OKAY; +} +CTR_Code CanTalonSRX::SetRevFeedbackSensor(int param) +{ + CtreCanNode::txTask toFill = GetTx(_controlFrameArbId | GetDeviceNumber()); + if (toFill.IsEmpty()) return CTR_UnexpectedArbId; + toFill->RevFeedbackSensor = param ? 1 : 0; + FlushTx(toFill); + return CTR_OKAY; +} +//------------------ C interface --------------------------------------------// +extern "C" { +void *c_TalonSRX_Create3(int deviceNumber, int controlPeriodMs, int enablePeriodMs) +{ + return new CanTalonSRX(deviceNumber, controlPeriodMs, enablePeriodMs); +} +void *c_TalonSRX_Create2(int deviceNumber, int controlPeriodMs) +{ + return new CanTalonSRX(deviceNumber, controlPeriodMs); +} +void *c_TalonSRX_Create1(int deviceNumber) +{ + return new CanTalonSRX(deviceNumber); +} +void c_TalonSRX_Destroy(void *handle) +{ + delete (CanTalonSRX*)handle; +} +void c_TalonSRX_Set(void *handle, double value) +{ + return ((CanTalonSRX*)handle)->Set(value); +} +CTR_Code c_TalonSRX_SetParam(void *handle, int paramEnum, double value) +{ + return ((CanTalonSRX*)handle)->SetParam((CanTalonSRX::param_t)paramEnum, value); +} +CTR_Code c_TalonSRX_RequestParam(void *handle, int paramEnum) +{ + return ((CanTalonSRX*)handle)->RequestParam((CanTalonSRX::param_t)paramEnum); +} +CTR_Code c_TalonSRX_GetParamResponse(void *handle, int paramEnum, double *value) +{ + return ((CanTalonSRX*)handle)->GetParamResponse((CanTalonSRX::param_t)paramEnum, *value); +} +CTR_Code c_TalonSRX_GetParamResponseInt32(void *handle, int paramEnum, int *value) +{ + return ((CanTalonSRX*)handle)->GetParamResponseInt32((CanTalonSRX::param_t)paramEnum, *value); +} +CTR_Code c_TalonSRX_SetPgain(void *handle, int slotIdx, double gain) +{ + return ((CanTalonSRX*)handle)->SetPgain((unsigned)slotIdx, gain); +} +CTR_Code c_TalonSRX_SetIgain(void *handle, int slotIdx, double gain) +{ + return ((CanTalonSRX*)handle)->SetIgain((unsigned)slotIdx, gain); +} +CTR_Code c_TalonSRX_SetDgain(void *handle, int slotIdx, double gain) +{ + return ((CanTalonSRX*)handle)->SetDgain((unsigned)slotIdx, gain); +} +CTR_Code c_TalonSRX_SetFgain(void *handle, int slotIdx, double gain) +{ + return ((CanTalonSRX*)handle)->SetFgain((unsigned)slotIdx, gain); +} +CTR_Code c_TalonSRX_SetIzone(void *handle, int slotIdx, int zone) +{ + return ((CanTalonSRX*)handle)->SetIzone((unsigned)slotIdx, zone); +} +CTR_Code c_TalonSRX_SetCloseLoopRampRate(void *handle, int slotIdx, int closeLoopRampRate) +{ + return ((CanTalonSRX*)handle)->SetCloseLoopRampRate((unsigned)slotIdx, closeLoopRampRate); +} +CTR_Code c_TalonSRX_SetVoltageCompensationRate(void *handle, double voltagePerMs) +{ + return ((CanTalonSRX*)handle)->SetVoltageCompensationRate(voltagePerMs); +} +CTR_Code c_TalonSRX_SetSensorPosition(void *handle, int pos) +{ + return ((CanTalonSRX*)handle)->SetSensorPosition(pos); +} +CTR_Code c_TalonSRX_SetForwardSoftLimit(void *handle, int forwardLimit) +{ + return ((CanTalonSRX*)handle)->SetForwardSoftLimit(forwardLimit); +} +CTR_Code c_TalonSRX_SetReverseSoftLimit(void *handle, int reverseLimit) +{ + return ((CanTalonSRX*)handle)->SetReverseSoftLimit(reverseLimit); +} +CTR_Code c_TalonSRX_SetForwardSoftEnable(void *handle, int enable) +{ + return ((CanTalonSRX*)handle)->SetForwardSoftEnable(enable); +} +CTR_Code c_TalonSRX_SetReverseSoftEnable(void *handle, int enable) +{ + return ((CanTalonSRX*)handle)->SetReverseSoftEnable(enable); +} +CTR_Code c_TalonSRX_GetPgain(void *handle, int slotIdx, double *gain) +{ + return ((CanTalonSRX*)handle)->GetPgain((unsigned)slotIdx, *gain); +} +CTR_Code c_TalonSRX_GetIgain(void *handle, int slotIdx, double *gain) +{ + return ((CanTalonSRX*)handle)->GetIgain((unsigned)slotIdx, *gain); +} +CTR_Code c_TalonSRX_GetDgain(void *handle, int slotIdx, double *gain) +{ + return ((CanTalonSRX*)handle)->GetDgain((unsigned)slotIdx, *gain); +} +CTR_Code c_TalonSRX_GetFgain(void *handle, int slotIdx, double *gain) +{ + return ((CanTalonSRX*)handle)->GetFgain((unsigned)slotIdx, *gain); +} +CTR_Code c_TalonSRX_GetIzone(void *handle, int slotIdx, int *zone) +{ + return ((CanTalonSRX*)handle)->GetIzone((unsigned)slotIdx, *zone); +} +CTR_Code c_TalonSRX_GetCloseLoopRampRate(void *handle, int slotIdx, int *closeLoopRampRate) +{ + return ((CanTalonSRX*)handle)->GetCloseLoopRampRate((unsigned)slotIdx, *closeLoopRampRate); +} +CTR_Code c_TalonSRX_GetVoltageCompensationRate(void *handle, double *voltagePerMs) +{ + return ((CanTalonSRX*)handle)->GetVoltageCompensationRate(*voltagePerMs); +} +CTR_Code c_TalonSRX_GetForwardSoftLimit(void *handle, int *forwardLimit) +{ + return ((CanTalonSRX*)handle)->GetForwardSoftLimit(*forwardLimit); +} +CTR_Code c_TalonSRX_GetReverseSoftLimit(void *handle, int *reverseLimit) +{ + return ((CanTalonSRX*)handle)->GetReverseSoftLimit(*reverseLimit); +} +CTR_Code c_TalonSRX_GetForwardSoftEnable(void *handle, int *enable) +{ + return ((CanTalonSRX*)handle)->GetForwardSoftEnable(*enable); +} +CTR_Code c_TalonSRX_GetReverseSoftEnable(void *handle, int *enable) +{ + return ((CanTalonSRX*)handle)->GetReverseSoftEnable(*enable); +} +CTR_Code c_TalonSRX_GetPulseWidthRiseToFallUs(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetPulseWidthRiseToFallUs(*param); +} +CTR_Code c_TalonSRX_IsPulseWidthSensorPresent(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->IsPulseWidthSensorPresent(*param); +} +CTR_Code c_TalonSRX_SetModeSelect2(void *handle, int modeSelect, int demand) +{ + return ((CanTalonSRX*)handle)->SetModeSelect(modeSelect, demand); +} +CTR_Code c_TalonSRX_SetStatusFrameRate(void *handle, int frameEnum, int periodMs) +{ + return ((CanTalonSRX*)handle)->SetStatusFrameRate((unsigned)frameEnum, (unsigned)periodMs); +} +CTR_Code c_TalonSRX_ClearStickyFaults(void *handle) +{ + return ((CanTalonSRX*)handle)->ClearStickyFaults(); +} +void c_TalonSRX_ChangeMotionControlFramePeriod(void *handle, int periodMs) +{ + return ((CanTalonSRX*)handle)->ChangeMotionControlFramePeriod((uint32_t)periodMs); +} +void c_TalonSRX_ClearMotionProfileTrajectories(void *handle) +{ + return ((CanTalonSRX*)handle)->ClearMotionProfileTrajectories(); +} +int c_TalonSRX_GetMotionProfileTopLevelBufferCount(void *handle) +{ + return ((CanTalonSRX*)handle)->GetMotionProfileTopLevelBufferCount(); +} +int c_TalonSRX_IsMotionProfileTopLevelBufferFull(void *handle) +{ + return ((CanTalonSRX*)handle)->IsMotionProfileTopLevelBufferFull(); +} +CTR_Code c_TalonSRX_PushMotionProfileTrajectory(void *handle, int targPos, int targVel, int profileSlotSelect, int timeDurMs, int velOnly, int isLastPoint, int zeroPos) +{ + return ((CanTalonSRX*)handle)->PushMotionProfileTrajectory(targPos, targVel, profileSlotSelect, timeDurMs, velOnly, isLastPoint, zeroPos); +} +void c_TalonSRX_ProcessMotionProfileBuffer(void *handle) +{ + return ((CanTalonSRX*)handle)->ProcessMotionProfileBuffer(); +} +CTR_Code c_TalonSRX_GetMotionProfileStatus(void *handle, int *flags, int *profileSlotSelect, int *targPos, int *targVel, int *topBufferRemaining, int *topBufferCnt, int *btmBufferCnt, int *outputEnable) +{ + uint32_t flags_val; + uint32_t profileSlotSelect_val; + int32_t targPos_val; + int32_t targVel_val; + uint32_t topBufferRemaining_val; + uint32_t topBufferCnt_val; + uint32_t btmBufferCnt_val; + uint32_t outputEnable_val; + CTR_Code retval = ((CanTalonSRX*)handle)->GetMotionProfileStatus(flags_val, profileSlotSelect_val, targPos_val, targVel_val, topBufferRemaining_val, topBufferCnt_val, btmBufferCnt_val, outputEnable_val); + *flags = (int)flags_val; + *profileSlotSelect = (int)profileSlotSelect_val; + *targPos = (int)targPos_val; + *targVel = (int)targVel_val; + *topBufferRemaining = (int)topBufferRemaining_val; + *topBufferCnt = (int)topBufferCnt_val; + *btmBufferCnt = (int)btmBufferCnt_val; + *outputEnable = (int)outputEnable_val; + return retval; +} +CTR_Code c_TalonSRX_GetFault_OverTemp(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_OverTemp(*param); +} +CTR_Code c_TalonSRX_GetFault_UnderVoltage(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_UnderVoltage(*param); +} +CTR_Code c_TalonSRX_GetFault_ForLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_ForLim(*param); +} +CTR_Code c_TalonSRX_GetFault_RevLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_RevLim(*param); +} +CTR_Code c_TalonSRX_GetFault_HardwareFailure(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_HardwareFailure(*param); +} +CTR_Code c_TalonSRX_GetFault_ForSoftLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_ForSoftLim(*param); +} +CTR_Code c_TalonSRX_GetFault_RevSoftLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFault_RevSoftLim(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_OverTemp(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_OverTemp(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_UnderVoltage(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_UnderVoltage(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_ForLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_ForLim(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_RevLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_RevLim(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_ForSoftLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_ForSoftLim(*param); +} +CTR_Code c_TalonSRX_GetStckyFault_RevSoftLim(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetStckyFault_RevSoftLim(*param); +} +CTR_Code c_TalonSRX_GetAppliedThrottle(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetAppliedThrottle(*param); +} +CTR_Code c_TalonSRX_GetCloseLoopErr(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetCloseLoopErr(*param); +} +CTR_Code c_TalonSRX_GetFeedbackDeviceSelect(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFeedbackDeviceSelect(*param); +} +CTR_Code c_TalonSRX_GetModeSelect(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetModeSelect(*param); +} +CTR_Code c_TalonSRX_GetLimitSwitchEn(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetLimitSwitchEn(*param); +} +CTR_Code c_TalonSRX_GetLimitSwitchClosedFor(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetLimitSwitchClosedFor(*param); +} +CTR_Code c_TalonSRX_GetLimitSwitchClosedRev(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetLimitSwitchClosedRev(*param); +} +CTR_Code c_TalonSRX_GetSensorPosition(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetSensorPosition(*param); +} +CTR_Code c_TalonSRX_GetSensorVelocity(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetSensorVelocity(*param); +} +CTR_Code c_TalonSRX_GetCurrent(void *handle, double *param) +{ + return ((CanTalonSRX*)handle)->GetCurrent(*param); +} +CTR_Code c_TalonSRX_GetBrakeIsEnabled(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetBrakeIsEnabled(*param); +} +CTR_Code c_TalonSRX_GetEncPosition(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetEncPosition(*param); +} +CTR_Code c_TalonSRX_GetEncVel(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetEncVel(*param); +} +CTR_Code c_TalonSRX_GetEncIndexRiseEvents(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetEncIndexRiseEvents(*param); +} +CTR_Code c_TalonSRX_GetQuadApin(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetQuadApin(*param); +} +CTR_Code c_TalonSRX_GetQuadBpin(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetQuadBpin(*param); +} +CTR_Code c_TalonSRX_GetQuadIdxpin(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetQuadIdxpin(*param); +} +CTR_Code c_TalonSRX_GetAnalogInWithOv(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetAnalogInWithOv(*param); +} +CTR_Code c_TalonSRX_GetAnalogInVel(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetAnalogInVel(*param); +} +CTR_Code c_TalonSRX_GetTemp(void *handle, double *param) +{ + return ((CanTalonSRX*)handle)->GetTemp(*param); +} +CTR_Code c_TalonSRX_GetBatteryV(void *handle, double *param) +{ + return ((CanTalonSRX*)handle)->GetBatteryV(*param); +} +CTR_Code c_TalonSRX_GetResetCount(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetResetCount(*param); +} +CTR_Code c_TalonSRX_GetResetFlags(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetResetFlags(*param); +} +CTR_Code c_TalonSRX_GetFirmVers(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetFirmVers(*param); +} +CTR_Code c_TalonSRX_GetPulseWidthPosition(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetPulseWidthPosition(*param); +} +CTR_Code c_TalonSRX_GetPulseWidthVelocity(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetPulseWidthVelocity(*param); +} +CTR_Code c_TalonSRX_GetPulseWidthRiseToRiseUs(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetPulseWidthRiseToRiseUs(*param); +} +CTR_Code c_TalonSRX_GetActTraj_IsValid(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_IsValid(*param); +} +CTR_Code c_TalonSRX_GetActTraj_ProfileSlotSelect(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_ProfileSlotSelect(*param); +} +CTR_Code c_TalonSRX_GetActTraj_VelOnly(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_VelOnly(*param); +} +CTR_Code c_TalonSRX_GetActTraj_IsLast(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_IsLast(*param); +} +CTR_Code c_TalonSRX_GetOutputType(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetOutputType(*param); +} +CTR_Code c_TalonSRX_GetHasUnderrun(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetHasUnderrun(*param); +} +CTR_Code c_TalonSRX_GetIsUnderrun(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetIsUnderrun(*param); +} +CTR_Code c_TalonSRX_GetNextID(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetNextID(*param); +} +CTR_Code c_TalonSRX_GetBufferIsFull(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetBufferIsFull(*param); +} +CTR_Code c_TalonSRX_GetCount(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetCount(*param); +} +CTR_Code c_TalonSRX_GetActTraj_Velocity(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_Velocity(*param); +} +CTR_Code c_TalonSRX_GetActTraj_Position(void *handle, int *param) +{ + return ((CanTalonSRX*)handle)->GetActTraj_Position(*param); +} +CTR_Code c_TalonSRX_SetDemand(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetDemand(param); +} +CTR_Code c_TalonSRX_SetOverrideLimitSwitchEn(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetOverrideLimitSwitchEn(param); +} +CTR_Code c_TalonSRX_SetFeedbackDeviceSelect(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetFeedbackDeviceSelect(param); +} +CTR_Code c_TalonSRX_SetRevMotDuringCloseLoopEn(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetRevMotDuringCloseLoopEn(param); +} +CTR_Code c_TalonSRX_SetOverrideBrakeType(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetOverrideBrakeType(param); +} +CTR_Code c_TalonSRX_SetModeSelect(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetModeSelect(param); +} +CTR_Code c_TalonSRX_SetProfileSlotSelect(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetProfileSlotSelect(param); +} +CTR_Code c_TalonSRX_SetRampThrottle(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetRampThrottle(param); +} +CTR_Code c_TalonSRX_SetRevFeedbackSensor(void *handle, int param) +{ + return ((CanTalonSRX*)handle)->SetRevFeedbackSensor(param); +} +} diff --git a/hal/lib/Athena/ctre/CtreCanNode.cpp b/hal/lib/Athena/ctre/CtreCanNode.cpp index 18cd24b8a3..0f190a5670 100644 --- a/hal/lib/Athena/ctre/CtreCanNode.cpp +++ b/hal/lib/Athena/ctre/CtreCanNode.cpp @@ -18,20 +18,57 @@ void CtreCanNode::RegisterRx(uint32_t arbId) { /* no need to do anything, we just use new API to poll last received message */ } -void CtreCanNode::RegisterTx(uint32_t arbId, uint32_t periodMs) +/** + * Schedule a CAN Frame for periodic transmit. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + * @param periodMs Period to transmit CAN frame. Pass 0 for one-shot, which also disables that ArbID's preceding periodic transmit. + * @param dlc Number of bytes to transmit (0 to 8). + * @param initialFrame Ptr to the frame data to schedule for transmitting. Passing null will result + * in defaulting to zero data value. + */ +void CtreCanNode::RegisterTx(uint32_t arbId, uint32_t periodMs, uint32_t dlc, const uint8_t * initialFrame) { int32_t status = 0; - + if(dlc > 8) + dlc = 8; txJob_t job = {0}; job.arbId = arbId; job.periodMs = periodMs; + job.dlc = dlc; + if(initialFrame){ + /* caller wants to specify original data */ + memcpy(job.toSend, initialFrame, dlc); + } _txJobs[arbId] = job; FRC_NetworkCommunication_CANSessionMux_sendMessage( job.arbId, job.toSend, - 8, + job.dlc, job.periodMs, &status); } +/** + * Schedule a CAN Frame for periodic transmit. Assume eight byte DLC and zero value for initial transmission. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + * @param periodMs Period to transmit CAN frame. Pass 0 for one-shot, which also disables that ArbID's preceding periodic transmit. + */ +void CtreCanNode::RegisterTx(uint32_t arbId, uint32_t periodMs) +{ + RegisterTx(arbId,periodMs, 8, 0); +} +/** + * Remove a CAN frame Arbid to stop transmission. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + */ +void CtreCanNode::UnregisterTx(uint32_t arbId) +{ + /* set period to zero */ + ChangeTxPeriod(arbId, 0); + /* look and remove */ + txJobs_t::iterator iter = _txJobs.find(arbId); + if(iter != _txJobs.end()) { + _txJobs.erase(iter); + } +} timespec diff(const timespec & start, const timespec & end) { timespec temp; @@ -94,8 +131,34 @@ void CtreCanNode::FlushTx(uint32_t arbId) if(iter != _txJobs.end()) FRC_NetworkCommunication_CANSessionMux_sendMessage( iter->second.arbId, iter->second.toSend, - 8, + iter->second.dlc, iter->second.periodMs, &status); } +/** + * Change the transmit period of an already scheduled CAN frame. + * This keeps the frame payload contents the same without caller having to perform + * a read-modify-write. + * @param arbId CAN Frame Arbitration ID. Set BIT31 for 11bit ids, otherwise we use 29bit ids. + * @param periodMs Period to transmit CAN frame. Pass 0 for one-shot, which also disables that ArbID's preceding periodic transmit. + * @return true if scheduled job was found and updated, false if there was no preceding job for the specified arbID. + */ +bool CtreCanNode::ChangeTxPeriod(uint32_t arbId, uint32_t periodMs) +{ + int32_t status = 0; + /* lookup the data bytes and period for this message */ + txJobs_t::iterator iter = _txJobs.find(arbId); + if(iter != _txJobs.end()) { + /* modify th periodMs */ + iter->second.periodMs = periodMs; + /* reinsert into scheduler with the same data bytes, only the period changed. */ + FRC_NetworkCommunication_CANSessionMux_sendMessage( iter->second.arbId, + iter->second.toSend, + iter->second.dlc, + iter->second.periodMs, + &status); + return true; + } + return false; +} diff --git a/wpilibc/Athena/include/CANSpeedController.h b/wpilibc/Athena/include/CANSpeedController.h index 73ed379417..5ef8cfa250 100644 --- a/wpilibc/Athena/include/CANSpeedController.h +++ b/wpilibc/Athena/include/CANSpeedController.h @@ -20,7 +20,8 @@ class CANSpeedController : public SpeedController { kSpeed = 2, kPosition = 3, kVoltage = 4, - kFollower = 5 // Not supported in Jaguar. + kFollower = 5, // Not supported in Jaguar. + kMotionProfile = 6, // Not supported in Jaguar. }; // Helper function for the ControlMode enum diff --git a/wpilibc/Athena/include/CANTalon.h b/wpilibc/Athena/include/CANTalon.h index 15ebbe258a..19c3f79907 100644 --- a/wpilibc/Athena/include/CANTalon.h +++ b/wpilibc/Athena/include/CANTalon.h @@ -42,9 +42,9 @@ class CANTalon : public MotorSafety, * 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... + 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, @@ -53,6 +53,151 @@ class CANTalon : public MotorSafety, 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. + */ + unsigned 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. + */ + unsigned 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. + */ + unsigned int topBufferRem; + /** + * The number of points in the top trajectory buffer. + */ + unsigned int topBufferCnt; + /** + * The number of points in the low level Talon buffer. + */ + unsigned 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); @@ -167,9 +312,9 @@ class CANTalon : public MotorSafety, /** * 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. + * @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(uint32_t paramEnum, double value); @@ -193,6 +338,69 @@ class CANTalon : public MotorSafety, 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 value, bool isNew) override; @@ -216,6 +424,7 @@ class CANTalon : public MotorSafety, kPositionMode = 1, kSpeedMode = 2, kCurrentMode = 3, + kMotionProfileMode = 6, kDisabled = 15 }; @@ -255,10 +464,10 @@ class CANTalon : public MotorSafety, static const unsigned 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. + * 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 */ @@ -271,40 +480,40 @@ class CANTalon : public MotorSafety, */ 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 + * @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. */ int32_t 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 + * @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. */ int32_t 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 + * @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, int32_t 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 + * @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, int32_t nativeVel) const; diff --git a/wpilibc/Athena/src/CANJaguar.cpp b/wpilibc/Athena/src/CANJaguar.cpp index fc71e84d65..2b4cd029eb 100644 --- a/wpilibc/Athena/src/CANJaguar.cpp +++ b/wpilibc/Athena/src/CANJaguar.cpp @@ -1010,6 +1010,7 @@ void CANJaguar::SetP(double p) { case kPercentVbus: case kVoltage: case kFollower: + case kMotionProfile: wpi_setWPIErrorWithContext( IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode"); @@ -1045,6 +1046,7 @@ void CANJaguar::SetI(double i) { case kPercentVbus: case kVoltage: case kFollower: + case kMotionProfile: wpi_setWPIErrorWithContext( IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode"); @@ -1080,6 +1082,7 @@ void CANJaguar::SetD(double d) { case kPercentVbus: case kVoltage: case kFollower: + case kMotionProfile: wpi_setWPIErrorWithContext( IncompatibleMode, "PID constants only apply in Speed, Position, and Current mode"); @@ -1516,7 +1519,7 @@ void CANJaguar::SetControlMode(ControlMode controlMode) { // Disable the previous mode DisableControl(); - if (controlMode == kFollower) + if ((controlMode == kFollower) || (controlMode == kMotionProfile)) wpi_setWPIErrorWithContext(IncompatibleMode, "The Jaguar only supports Current, Voltage, " "Position, Speed, and Percent (Throttle) " diff --git a/wpilibc/Athena/src/CANTalon.cpp b/wpilibc/Athena/src/CANTalon.cpp index f9372129d5..765c7c4289 100644 --- a/wpilibc/Athena/src/CANTalon.cpp +++ b/wpilibc/Athena/src/CANTalon.cpp @@ -156,6 +156,9 @@ void CANTalon::Set(float value, uint8_t syncGroup) { double milliamperes = (m_isInverted ? -value : value) * 1000.0; /* mA*/ status = m_impl->SetDemand(milliamperes); } break; + case CANSpeedController::kMotionProfile: { + status = m_impl->SetDemand((int)value); + } break; default: wpi_setWPIErrorWithContext( IncompatibleMode, @@ -1430,6 +1433,9 @@ void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode) { case kFollower: m_sendMode = kFollowerMode; break; + case kMotionProfile: + m_sendMode = kMotionProfileMode; + break; } // Keep the talon disabled until Set() is called. CTR_Code status = m_impl->SetModeSelect((int)kDisabled); @@ -1668,6 +1674,136 @@ void CANTalon::EnableZeroSensorPositionOnIndex(bool enable, bool risingEdge) ConfigSetParameter(CanTalonSRX::eQuadIdxPolarity,risingEdge ? 1 : 0); } } + +/** + * Calling application can opt to speed up the handshaking between the robot API and the Talon to increase the + * download rate of the Talon's Motion Profile. Ideally the period should be no more than half the period + * of a trajectory point. + */ +void CANTalon::ChangeMotionControlFramePeriod(int periodMs) +{ + m_impl->ChangeMotionControlFramePeriod(periodMs); +} + +/** + * Clear the buffered motion profile in both Talon RAM (bottom), and in the API (top). + * Be sure to check GetMotionProfileStatus() to know when the buffer is actually cleared. + */ +void CANTalon::ClearMotionProfileTrajectories() +{ + m_impl->ClearMotionProfileTrajectories(); +} + +/** + * Retrieve just the buffer count for the api-level (top) buffer. + * This routine performs no CAN or data structure lookups, so its fast and ideal + * if caller needs to quickly poll the progress of trajectory points being emptied + * into Talon's RAM. Otherwise just use GetMotionProfileStatus. + * @return number of trajectory points in the top buffer. + */ +int CANTalon::GetMotionProfileTopLevelBufferCount() +{ + return m_impl->GetMotionProfileTopLevelBufferCount(); +} + +/** + * Push another trajectory point into the top level buffer (which is emptied into + * the Talon's bottom buffer as room allows). + * @param 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 CANTalon::PushMotionProfileTrajectory(const TrajectoryPoint & trajPt) +{ + /* convert positiona and velocity to native units */ + int32_t targPos = ScaleRotationsToNativeUnits(m_feedbackDevice, trajPt.position); + int32_t targVel = ScaleVelocityToNativeUnits(m_feedbackDevice, trajPt.velocity); + /* bounds check signals that require it */ + uint32_t profileSlotSelect = (trajPt.profileSlotSelect) ? 1 : 0; + uint8_t timeDurMs = (trajPt.timeDurMs >= 255) ? 255 : trajPt.timeDurMs; /* cap time to 255ms */ + /* send it to the top level buffer */ + CTR_Code status = m_impl->PushMotionProfileTrajectory(targPos, targVel, profileSlotSelect, timeDurMs, trajPt.velocityOnly, trajPt.isLastPoint, trajPt.zeroPos); + return (status == CTR_OKAY) ? true : false; +} +/** + * @return true if api-level (top) buffer is full. + */ +bool CANTalon::IsMotionProfileTopLevelBufferFull() +{ + return m_impl->IsMotionProfileTopLevelBufferFull(); +} + +/** + * This must be called periodically to funnel the trajectory points from the API's top level buffer to + * the Talon's bottom level buffer. Recommendation is to call this twice as fast as the executation rate of the motion profile. + * So if MP is running with 20ms trajectory points, try calling this routine every 10ms. All motion profile functions are thread-safe + * through the use of a mutex, so there is no harm in having the caller utilize threading. + */ +void CANTalon::ProcessMotionProfileBuffer() +{ + m_impl->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 CANTalon::GetMotionProfileStatus(MotionProfileStatus & motionProfileStatus) +{ + uint32_t flags; + uint32_t profileSlotSelect; + int32_t targPos, targVel; + uint32_t topBufferRem, topBufferCnt, btmBufferCnt; + uint32_t outputEnable; + /* retrieve all motion profile signals from status frame */ + CTR_Code status = m_impl->GetMotionProfileStatus(flags, profileSlotSelect, targPos, targVel, topBufferRem, topBufferCnt, btmBufferCnt, outputEnable); + /* completely update the caller's structure */ + motionProfileStatus.topBufferRem = topBufferRem; + motionProfileStatus.topBufferCnt = topBufferCnt; + motionProfileStatus.btmBufferCnt = btmBufferCnt; + motionProfileStatus.hasUnderrun = (flags & CanTalonSRX::kMotionProfileFlag_HasUnderrun) ? true :false; + motionProfileStatus.isUnderrun = (flags & CanTalonSRX::kMotionProfileFlag_IsUnderrun) ? true :false; + motionProfileStatus.activePointValid = (flags & CanTalonSRX::kMotionProfileFlag_ActTraj_IsValid) ? true :false; + motionProfileStatus.activePoint.isLastPoint = (flags & CanTalonSRX::kMotionProfileFlag_ActTraj_IsLast) ? true :false; + motionProfileStatus.activePoint.velocityOnly = (flags & CanTalonSRX::kMotionProfileFlag_ActTraj_VelOnly) ? true :false; + motionProfileStatus.activePoint.position = ScaleNativeUnitsToRotations(m_feedbackDevice, targPos); + motionProfileStatus.activePoint.velocity = ScaleNativeUnitsToRpm(m_feedbackDevice, targVel); + motionProfileStatus.activePoint.profileSlotSelect = profileSlotSelect; + switch(outputEnable){ + case CanTalonSRX::kMotionProf_Disabled: + motionProfileStatus.outputEnable = SetValueMotionProfileDisable; + break; + case CanTalonSRX::kMotionProf_Enable: + motionProfileStatus.outputEnable = SetValueMotionProfileEnable; + break; + case CanTalonSRX::kMotionProf_Hold: + motionProfileStatus.outputEnable = SetValueMotionProfileHold; + break; + default: + motionProfileStatus.outputEnable = SetValueMotionProfileDisable; + break; + } + motionProfileStatus.activePoint.zeroPos = false; /* this signal is only used sending pts to Talon */ + motionProfileStatus.activePoint.timeDurMs = 0; /* this signal is only used sending pts to Talon */ + + if (status != CTR_OKAY) { + wpi_setErrorWithContext(status, getHALErrorMessage(status)); + } +} +/** + * 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 CANTalon::ClearMotionProfileHasUnderrun() +{ + ConfigSetParameter(CanTalonSRX::eMotionProfileHasUnderrunErr, 0); +} /** * Common interface for inverting direction of a speed controller. * Only works in PercentVbus, speed, and Voltage modes. diff --git a/wpilibj/athena.gradle b/wpilibj/athena.gradle index 16a861b8da..d30d3f654a 100644 --- a/wpilibj/athena.gradle +++ b/wpilibj/athena.gradle @@ -136,6 +136,7 @@ task jniHeaders { args 'edu.wpi.first.wpilibj.hal.JNIWrapper' args 'edu.wpi.first.wpilibj.hal.AccelerometerJNI' args 'edu.wpi.first.wpilibj.hal.AnalogJNI' + args 'edu.wpi.first.wpilibj.hal.CanTalonJNI' args 'edu.wpi.first.wpilibj.hal.CounterJNI' args 'edu.wpi.first.wpilibj.hal.DigitalGlitchFilterJNI' args 'edu.wpi.first.wpilibj.hal.DIOJNI' diff --git a/wpilibj/src/athena/cpp/lib/CanTalonJNI.cpp b/wpilibj/src/athena/cpp/lib/CanTalonJNI.cpp new file mode 100644 index 0000000000..1184106f81 --- /dev/null +++ b/wpilibj/src/athena/cpp/lib/CanTalonJNI.cpp @@ -0,0 +1,829 @@ +#include +#include + +#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_OverTemp + (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_UnderVoltage + (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_ForLim + (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_RevLim + (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_HardwareFailure + (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_ForSoftLim + (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_RevSoftLim + (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_OverTemp + (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_UnderVoltage + (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_ForLim + (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_RevLim + (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_ForSoftLim + (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_RevSoftLim + (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_IsValid + (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_ProfileSlotSelect + (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_VelOnly + (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_IsLast + (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_Velocity + (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_Position + (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" diff --git a/wpilibj/src/athena/cpp/lib/CanTalonSRXJNI.cpp b/wpilibj/src/athena/cpp/lib/CanTalonSRXJNI.cpp deleted file mode 100644 index 0acf12db95..0000000000 --- a/wpilibj/src/athena/cpp/lib/CanTalonSRXJNI.cpp +++ /dev/null @@ -1,3941 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.11 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -#define SWIGJAVA - - -#ifdef __cplusplus -/* SwigValueWrapper is described in swig.swg */ -template class SwigValueWrapper { - struct SwigMovePointer { - T *ptr; - SwigMovePointer(T *p) : ptr(p) { } - ~SwigMovePointer() { delete ptr; } - SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } - } pointer; - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); - SwigValueWrapper(const SwigValueWrapper& rhs); -public: - SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } - operator T&() const { return *pointer.ptr; } - T *operator&() { return pointer.ptr; } -}; - -template T SwigValueInit() { - return T(); -} -#endif - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - - - -/* Fix for jlong on some versions of gcc on Windows */ -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) - typedef long long __int64; -#endif - -/* Fix for jlong on 64-bit x86 Solaris */ -#if defined(__x86_64) -# ifdef _LP64 -# undef _LP64 -# endif -#endif - -#include -#include -#include - - -/* Support for throwing Java exceptions */ -typedef enum { - SWIG_JavaOutOfMemoryError = 1, - SWIG_JavaIOException, - SWIG_JavaRuntimeException, - SWIG_JavaIndexOutOfBoundsException, - SWIG_JavaArithmeticException, - SWIG_JavaIllegalArgumentException, - SWIG_JavaNullPointerException, - SWIG_JavaDirectorPureVirtual, - SWIG_JavaUnknownError -} SWIG_JavaExceptionCodes; - -typedef struct { - SWIG_JavaExceptionCodes code; - const char *java_exception; -} SWIG_JavaExceptions_t; - - -static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { - jclass excep; - static const SWIG_JavaExceptions_t java_exceptions[] = { - { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, - { SWIG_JavaIOException, "java/io/IOException" }, - { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, - { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, - { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, - { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, - { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, - { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, - { SWIG_JavaUnknownError, "java/lang/UnknownError" }, - { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } - }; - const SWIG_JavaExceptions_t *except_ptr = java_exceptions; - - while (except_ptr->code != code && except_ptr->code) - except_ptr++; - - jenv->ExceptionClear(); - excep = jenv->FindClass(except_ptr->java_exception); - if (excep) - jenv->ThrowNew(excep, msg); -} - - -/* Contract support */ - -#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else - - -#include "HAL/CanTalonSRX.h" - - -static double *new_doublep() { - return new double(); -} - -static double *copy_doublep(double value) { - return new double(value); -} - -static void delete_doublep(double *obj) { - if (obj) delete obj; -} - -static void doublep_assign(double *obj, double value) { - *obj = value; -} - -static double doublep_value(double *obj) { - return *obj; -} - - -static int *new_intp() { - return new int(); -} - -static int *copy_intp(int value) { - return new int(value); -} - -static void delete_intp(int *obj) { - if (obj) delete obj; -} - -static void intp_assign(int *obj, int value) { - *obj = value; -} - -static int intp_value(int *obj) { - return *obj; -} - - -static uint32_t *new_uint32_tp() { - return new uint32_t(); -} - -static uint32_t *copy_uint32_tp(uint32_t value) { - return new uint32_t(value); -} - -static void delete_uint32_tp(uint32_t *obj) { - if (obj) delete obj; -} - -static void uint32_tp_assign(uint32_t *obj, uint32_t value) { - *obj = value; -} - -static uint32_t uint32_tp_value(uint32_t *obj) { - return *obj; -} - - -static int32_t *new_int32_tp() { - return new int32_t(); -} - -static int32_t *copy_int32_tp(int32_t value) { - return new int32_t(value); -} - -static void delete_int32_tp(int32_t *obj) { - if (obj) delete obj; -} - -static void int32_tp_assign(int32_t *obj, int32_t value) { - *obj = value; -} - -static int32_t int32_tp_value(int32_t *obj) { - return *obj; -} - - -static uint8_t *new_uint8_tp() { - return new uint8_t(); -} - -static uint8_t *copy_uint8_tp(uint8_t value) { - return new uint8_t(value); -} - -static void delete_uint8_tp(uint8_t *obj) { - if (obj) delete obj; -} - -static void uint8_tp_assign(uint8_t *obj, uint8_t value) { - *obj = value; -} - -static uint8_t uint8_tp_value(uint8_t *obj) { - return *obj; -} - - -static CTR_Code *new_CTR_Codep() { - return new CTR_Code(); -} - -static CTR_Code *copy_CTR_Codep(CTR_Code value) { - return new CTR_Code(value); -} - -static void delete_CTR_Codep(CTR_Code *obj) { - if (obj) delete obj; -} - -static void CTR_Codep_assign(CTR_Code *obj, CTR_Code value) { - *obj = value; -} - -static CTR_Code CTR_Codep_value(CTR_Code *obj) { - return *obj; -} - - -static float *new_floatp() { - return new float(); -} - -static float *copy_floatp(float value) { - return new float(value); -} - -static void delete_floatp(float *obj) { - if (obj) delete obj; -} - -static void floatp_assign(float *obj, float value) { - *obj = value; -} - -static float floatp_value(float *obj) { - return *obj; -} - - -#ifdef __cplusplus -extern "C" { -#endif - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1doublep(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - double *result = 0 ; - - (void)jenv; - (void)jcls; - result = (double *)new_doublep(); - *(double **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1doublep(JNIEnv *jenv, jclass jcls, jdouble jarg1) { - jlong jresult = 0 ; - double arg1 ; - double *result = 0 ; - - (void)jenv; - (void)jcls; - arg1 = (double)jarg1; - result = (double *)copy_doublep(arg1); - *(double **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1doublep(JNIEnv *jenv, jclass jcls, jlong jarg1) { - double *arg1 = (double *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(double **)&jarg1; - delete_doublep(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_doublep_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { - double *arg1 = (double *) 0 ; - double arg2 ; - - (void)jenv; - (void)jcls; - arg1 = *(double **)&jarg1; - arg2 = (double)jarg2; - doublep_assign(arg1,arg2); -} - - -SWIGEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_doublep_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jdouble jresult = 0 ; - double *arg1 = (double *) 0 ; - double result; - - (void)jenv; - (void)jcls; - arg1 = *(double **)&jarg1; - result = (double)doublep_value(arg1); - jresult = (jdouble)result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1intp(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - int *result = 0 ; - - (void)jenv; - (void)jcls; - result = (int *)new_intp(); - *(int **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1intp(JNIEnv *jenv, jclass jcls, jint jarg1) { - jlong jresult = 0 ; - int arg1 ; - int *result = 0 ; - - (void)jenv; - (void)jcls; - arg1 = (int)jarg1; - result = (int *)copy_intp(arg1); - *(int **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1intp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - int *arg1 = (int *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(int **)&jarg1; - delete_intp(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_intp_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { - int *arg1 = (int *) 0 ; - int arg2 ; - - (void)jenv; - (void)jcls; - arg1 = *(int **)&jarg1; - arg2 = (int)jarg2; - intp_assign(arg1,arg2); -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_intp_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jint jresult = 0 ; - int *arg1 = (int *) 0 ; - int result; - - (void)jenv; - (void)jcls; - arg1 = *(int **)&jarg1; - result = (int)intp_value(arg1); - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1uint32_1tp(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - uint32_t *result = 0 ; - - (void)jenv; - (void)jcls; - result = (uint32_t *)new_uint32_tp(); - *(uint32_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1uint32_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - uint32_t arg1 ; - uint32_t *argp1 ; - uint32_t *result = 0 ; - - (void)jenv; - (void)jcls; - argp1 = *(uint32_t **)&jarg1; - if (!argp1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint32_t"); - return 0; - } - arg1 = *argp1; - result = (uint32_t *)copy_uint32_tp(arg1); - *(uint32_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1uint32_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - uint32_t *arg1 = (uint32_t *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(uint32_t **)&jarg1; - delete_uint32_tp(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_uint32_1tp_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { - uint32_t *arg1 = (uint32_t *) 0 ; - uint32_t arg2 ; - uint32_t *argp2 ; - - (void)jenv; - (void)jcls; - arg1 = *(uint32_t **)&jarg1; - argp2 = *(uint32_t **)&jarg2; - if (!argp2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint32_t"); - return ; - } - arg2 = *argp2; - uint32_tp_assign(arg1,arg2); -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_uint32_1tp_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - uint32_t *arg1 = (uint32_t *) 0 ; - uint32_t result; - - (void)jenv; - (void)jcls; - arg1 = *(uint32_t **)&jarg1; - result = uint32_tp_value(arg1); - *(uint32_t **)&jresult = new uint32_t((const uint32_t &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1int32_1tp(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - int32_t *result = 0 ; - - (void)jenv; - (void)jcls; - result = (int32_t *)new_int32_tp(); - *(int32_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1int32_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - int32_t arg1 ; - int32_t *argp1 ; - int32_t *result = 0 ; - - (void)jenv; - (void)jcls; - argp1 = *(int32_t **)&jarg1; - if (!argp1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null int32_t"); - return 0; - } - arg1 = *argp1; - result = (int32_t *)copy_int32_tp(arg1); - *(int32_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1int32_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - int32_t *arg1 = (int32_t *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(int32_t **)&jarg1; - delete_int32_tp(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_int32_1tp_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { - int32_t *arg1 = (int32_t *) 0 ; - int32_t arg2 ; - int32_t *argp2 ; - - (void)jenv; - (void)jcls; - arg1 = *(int32_t **)&jarg1; - argp2 = *(int32_t **)&jarg2; - if (!argp2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null int32_t"); - return ; - } - arg2 = *argp2; - int32_tp_assign(arg1,arg2); -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_int32_1tp_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - int32_t *arg1 = (int32_t *) 0 ; - int32_t result; - - (void)jenv; - (void)jcls; - arg1 = *(int32_t **)&jarg1; - result = int32_tp_value(arg1); - *(int32_t **)&jresult = new int32_t((const int32_t &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1uint8_1tp(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - uint8_t *result = 0 ; - - (void)jenv; - (void)jcls; - result = (uint8_t *)new_uint8_tp(); - *(uint8_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1uint8_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - uint8_t arg1 ; - uint8_t *argp1 ; - uint8_t *result = 0 ; - - (void)jenv; - (void)jcls; - argp1 = *(uint8_t **)&jarg1; - if (!argp1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint8_t"); - return 0; - } - arg1 = *argp1; - result = (uint8_t *)copy_uint8_tp(arg1); - *(uint8_t **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1uint8_1tp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - uint8_t *arg1 = (uint8_t *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(uint8_t **)&jarg1; - delete_uint8_tp(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_uint8_1tp_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { - uint8_t *arg1 = (uint8_t *) 0 ; - uint8_t arg2 ; - uint8_t *argp2 ; - - (void)jenv; - (void)jcls; - arg1 = *(uint8_t **)&jarg1; - argp2 = *(uint8_t **)&jarg2; - if (!argp2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null uint8_t"); - return ; - } - arg2 = *argp2; - uint8_tp_assign(arg1,arg2); -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_uint8_1tp_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - uint8_t *arg1 = (uint8_t *) 0 ; - uint8_t result; - - (void)jenv; - (void)jcls; - arg1 = *(uint8_t **)&jarg1; - result = uint8_tp_value(arg1); - *(uint8_t **)&jresult = new uint8_t((const uint8_t &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CTR_1Codep(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - CTR_Code *result = 0 ; - - (void)jenv; - (void)jcls; - result = (CTR_Code *)new_CTR_Codep(); - *(CTR_Code **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1CTR_1Codep(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - CTR_Code arg1 ; - CTR_Code *argp1 ; - CTR_Code *result = 0 ; - - (void)jenv; - (void)jcls; - argp1 = *(CTR_Code **)&jarg1; - if (!argp1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null CTR_Code"); - return 0; - } - arg1 = *argp1; - result = (CTR_Code *)copy_CTR_Codep(arg1); - *(CTR_Code **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1CTR_1Codep(JNIEnv *jenv, jclass jcls, jlong jarg1) { - CTR_Code *arg1 = (CTR_Code *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(CTR_Code **)&jarg1; - delete_CTR_Codep(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CTR_1Codep_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { - CTR_Code *arg1 = (CTR_Code *) 0 ; - CTR_Code arg2 ; - CTR_Code *argp2 ; - - (void)jenv; - (void)jcls; - arg1 = *(CTR_Code **)&jarg1; - argp2 = *(CTR_Code **)&jarg2; - if (!argp2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null CTR_Code"); - return ; - } - arg2 = *argp2; - CTR_Codep_assign(arg1,arg2); -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CTR_1Codep_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - CTR_Code *arg1 = (CTR_Code *) 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - arg1 = *(CTR_Code **)&jarg1; - result = CTR_Codep_value(arg1); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1floatp(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - float *result = 0 ; - - (void)jenv; - (void)jcls; - result = (float *)new_floatp(); - *(float **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_copy_1floatp(JNIEnv *jenv, jclass jcls, jfloat jarg1) { - jlong jresult = 0 ; - float arg1 ; - float *result = 0 ; - - (void)jenv; - (void)jcls; - arg1 = (float)jarg1; - result = (float *)copy_floatp(arg1); - *(float **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1floatp(JNIEnv *jenv, jclass jcls, jlong jarg1) { - float *arg1 = (float *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(float **)&jarg1; - delete_floatp(arg1); -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_floatp_1assign(JNIEnv *jenv, jclass jcls, jlong jarg1, jfloat jarg2) { - float *arg1 = (float *) 0 ; - float arg2 ; - - (void)jenv; - (void)jcls; - arg1 = *(float **)&jarg1; - arg2 = (float)jarg2; - floatp_assign(arg1,arg2); -} - - -SWIGEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_floatp_1value(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jfloat jresult = 0 ; - float *arg1 = (float *) 0 ; - float result; - - (void)jenv; - (void)jcls; - arg1 = *(float **)&jarg1; - result = (float)floatp_value(arg1); - jresult = (jfloat)result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CtreCanNode(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong jresult = 0 ; - UINT8 arg1 ; - UINT8 *argp1 ; - CtreCanNode *result = 0 ; - - (void)jenv; - (void)jcls; - argp1 = *(UINT8 **)&jarg1; - if (!argp1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null UINT8"); - return 0; - } - arg1 = *argp1; - result = (CtreCanNode *)new CtreCanNode(arg1); - *(CtreCanNode **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1CtreCanNode(JNIEnv *jenv, jclass jcls, jlong jarg1) { - CtreCanNode *arg1 = (CtreCanNode *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(CtreCanNode **)&jarg1; - delete arg1; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CtreCanNode_1GetDeviceNumber(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { - jlong jresult = 0 ; - CtreCanNode *arg1 = (CtreCanNode *) 0 ; - UINT8 result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CtreCanNode **)&jarg1; - result = (arg1)->GetDeviceNumber(); - *(UINT8 **)&jresult = new UINT8((const UINT8 &)result); - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kDefaultControlPeriodMs_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kDefaultControlPeriodMs; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2) { - jlong jresult = 0 ; - int arg1 ; - int arg2 ; - CanTalonSRX *result = 0 ; - - (void)jenv; - (void)jcls; - arg1 = (int)jarg1; - arg2 = (int)jarg2; - result = (CanTalonSRX *)new CanTalonSRX(arg1,arg2); - *(CanTalonSRX **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jint jarg1) { - jlong jresult = 0 ; - int arg1 ; - CanTalonSRX *result = 0 ; - - (void)jenv; - (void)jcls; - arg1 = (int)jarg1; - result = (CanTalonSRX *)new CanTalonSRX(arg1); - *(CanTalonSRX **)&jresult = result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_new_1CanTalonSRX_1_1SWIG_12(JNIEnv *jenv, jclass jcls) { - jlong jresult = 0 ; - CanTalonSRX *result = 0 ; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX *)new CanTalonSRX(); - *(CanTalonSRX **)&jresult = result; - return jresult; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_delete_1CanTalonSRX(JNIEnv *jenv, jclass jcls, jlong jarg1) { - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - - (void)jenv; - (void)jcls; - arg1 = *(CanTalonSRX **)&jarg1; - delete arg1; -} - - -SWIGEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1Set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) { - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double arg2 ; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (double)jarg2; - (arg1)->Set(arg2); -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1DutyCycle_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_DutyCycle; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1PositionCloseLoop_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_PositionCloseLoop; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1VelocityCloseLoop_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_VelocityCloseLoop; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1CurrentCloseLoop_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_CurrentCloseLoop; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1VoltCompen_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_VoltCompen; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1SlaveFollower_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_SlaveFollower; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kMode_1NoDrive_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kMode_NoDrive; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kLimitSwitchOverride_1UseDefaultsFromFlash_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kLimitSwitchOverride_UseDefaultsFromFlash; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kLimitSwitchOverride_1DisableFwd_1DisableRev_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kLimitSwitchOverride_DisableFwd_DisableRev; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kLimitSwitchOverride_1DisableFwd_1EnableRev_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kLimitSwitchOverride_DisableFwd_EnableRev; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kLimitSwitchOverride_1EnableFwd_1DisableRev_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kLimitSwitchOverride_EnableFwd_DisableRev; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kLimitSwitchOverride_1EnableFwd_1EnableRev_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kLimitSwitchOverride_EnableFwd_EnableRev; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kBrakeOverride_1UseDefaultsFromFlash_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kBrakeOverride_UseDefaultsFromFlash; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kBrakeOverride_1OverrideCoast_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kBrakeOverride_OverrideCoast; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kBrakeOverride_1OverrideBrake_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kBrakeOverride_OverrideBrake; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1DigitalQuadEnc_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_DigitalQuadEnc; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1AnalogPot_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_AnalogPot; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1AnalogEncoder_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_AnalogEncoder; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1CountEveryRisingEdge_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_CountEveryRisingEdge; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1CountEveryFallingEdge_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_CountEveryFallingEdge; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kFeedbackDev_1PosIsPulseWidth_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kFeedbackDev_PosIsPulseWidth; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kProfileSlotSelect_1Slot0_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kProfileSlotSelect_Slot0; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kProfileSlotSelect_1Slot1_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kProfileSlotSelect_Slot1; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kStatusFrame_1General_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kStatusFrame_General; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kStatusFrame_1Feedback_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kStatusFrame_Feedback; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kStatusFrame_1Encoder_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kStatusFrame_Encoder; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kStatusFrame_1AnalogTempVbat_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kStatusFrame_AnalogTempVbat; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1kStatusFrame_1PulseWidthMeas_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - int result; - - (void)jenv; - (void)jcls; - result = (int)CanTalonSRX::kStatusFrame_PulseWidthMeas; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1P_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_P; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1I_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_I; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1D_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_D; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1F_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_F; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1IZone_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_IZone; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1CloseLoopRampRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_CloseLoopRampRate; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1P_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_P; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1I_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_I; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1D_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_D; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1F_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_F; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1IZone_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_IZone; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1CloseLoopRampRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_CloseLoopRampRate; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSoftLimitForThreshold_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSoftLimitForThreshold; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSoftLimitRevThreshold_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSoftLimitRevThreshold; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSoftLimitForEnable_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSoftLimitForEnable; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSoftLimitRevEnable_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSoftLimitRevEnable; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eOnBoot_1BrakeMode_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eOnBoot_BrakeMode; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eOnBoot_1LimitSwitch_1Forward_1NormallyClosed_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eOnBoot_LimitSwitch_Forward_NormallyClosed; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eOnBoot_1LimitSwitch_1Reverse_1NormallyClosed_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eOnBoot_LimitSwitch_Reverse_NormallyClosed; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eOnBoot_1LimitSwitch_1Forward_1Disable_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eOnBoot_LimitSwitch_Forward_Disable; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eOnBoot_1LimitSwitch_1Reverse_1Disable_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eOnBoot_LimitSwitch_Reverse_Disable; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1OverTemp_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_OverTemp; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1UnderVoltage_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_UnderVoltage; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1ForLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_ForLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1RevLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_RevLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1HardwareFailure_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_HardwareFailure; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1ForSoftLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_ForSoftLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFault_1RevSoftLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFault_RevSoftLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1OverTemp_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_OverTemp; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1UnderVoltage_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_UnderVoltage; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1ForLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_ForLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1RevLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_RevLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1ForSoftLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_ForSoftLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStckyFault_1RevSoftLim_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStckyFault_RevSoftLim; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eAppliedThrottle_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eAppliedThrottle; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eCloseLoopErr_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eCloseLoopErr; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFeedbackDeviceSelect_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFeedbackDeviceSelect; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eRevMotDuringCloseLoopEn_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eRevMotDuringCloseLoopEn; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eModeSelect_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eModeSelect; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileSlotSelect_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileSlotSelect; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eRampThrottle_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eRampThrottle; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eRevFeedbackSensor_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eRevFeedbackSensor; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eLimitSwitchEn_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eLimitSwitchEn; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eLimitSwitchClosedFor_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eLimitSwitchClosedFor; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eLimitSwitchClosedRev_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eLimitSwitchClosedRev; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eSensorPosition_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eSensorPosition; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eSensorVelocity_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eSensorVelocity; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eCurrent_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eCurrent; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eBrakeIsEnabled_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eBrakeIsEnabled; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eEncPosition_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eEncPosition; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eEncVel_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eEncVel; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eEncIndexRiseEvents_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eEncIndexRiseEvents; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eQuadApin_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eQuadApin; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eQuadBpin_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eQuadBpin; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eQuadIdxpin_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eQuadIdxpin; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eAnalogInWithOv_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eAnalogInWithOv; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eAnalogInVel_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eAnalogInVel; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eTemp_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eTemp; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eBatteryV_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eBatteryV; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eResetCount_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eResetCount; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eResetFlags_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eResetFlags; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eFirmVers_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eFirmVers; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eSettingsChanged_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eSettingsChanged; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eQuadFilterEn_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eQuadFilterEn; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1ePidIaccum_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::ePidIaccum; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus1FrameRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus1FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus2FrameRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus2FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus3FrameRate_1get(JNIEnv *jenv, jclass jcls) { - - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus3FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus4FrameRate_1get(JNIEnv *jenv, jclass jcls) { - - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus4FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus6FrameRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus6FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus7FrameRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus7FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eClearPositionOnIdx_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eClearPositionOnIdx; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1ePeakPosOutput_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::ePeakPosOutput; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eNominalPosOutput_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eNominalPosOutput; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1ePeakNegOutput_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::ePeakNegOutput; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eNominalNegOutput_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eNominalNegOutput; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eQuadIdxPolarity_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eQuadIdxPolarity; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eStatus8FrameRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eStatus8FrameRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eAllowPosOverflow_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eAllowPosOverflow; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot0_1AllowableClosedLoopErr_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot0_AllowableClosedLoopErr; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eNumberPotTurns_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eNumberPotTurns; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eNumberEncoderCPR_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eNumberEncoderCPR; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1ePwdPosition_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::ePwdPosition; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eAinPosition_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eAinPosition; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamVcompRate_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamVcompRate; - jresult = (jint)result; - return jresult; -} - -SWIGEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1eProfileParamSlot1_1AllowableClosedLoopErr_1get(JNIEnv *jenv, jclass jcls) { - jint jresult = 0 ; - CanTalonSRX::_param_t result; - - (void)jenv; - (void)jcls; - result = (CanTalonSRX::_param_t)CanTalonSRX::eProfileParamSlot1_AllowableClosedLoopErr; - jresult = (jint)result; - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetParam(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jdouble jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - CanTalonSRX::param_t arg2 ; - double arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (CanTalonSRX::param_t)jarg2; - arg3 = (double)jarg3; - result = (arg1)->SetParam(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1RequestParam(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - CanTalonSRX::param_t arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (CanTalonSRX::param_t)jarg2; - result = (arg1)->RequestParam(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetParamResponse(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - CanTalonSRX::param_t arg2 ; - double *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (CanTalonSRX::param_t)jarg2; - arg3 = *(double **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetParamResponse(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetParamResponseInt32(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - CanTalonSRX::param_t arg2 ; - int *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (CanTalonSRX::param_t)jarg2; - arg3 = *(int **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetParamResponseInt32(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetPgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jdouble jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (double)jarg3; - result = (arg1)->SetPgain(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetIgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jdouble jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (double)jarg3; - result = (arg1)->SetIgain(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetDgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jdouble jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (double)jarg3; - result = (arg1)->SetDgain(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetFgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jdouble jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (double)jarg3; - result = (arg1)->SetFgain(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetIzone(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jint jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - int arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (int)jarg3; - result = (arg1)->SetIzone(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetCloseLoopRampRate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jint jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - int arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (int)jarg3; - result = (arg1)->SetCloseLoopRampRate(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetSensorPosition(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetSensorPosition(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetForwardSoftLimit(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetForwardSoftLimit(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetReverseSoftLimit(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetReverseSoftLimit(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetForwardSoftEnable(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetForwardSoftEnable(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetReverseSoftEnable(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetReverseSoftEnable(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetPgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(double **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetPgain(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetIgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(double **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetIgain(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetDgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(double **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetDgain(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFgain(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - double *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(double **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetFgain(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetIzone(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - int *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(int **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetIzone(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetCloseLoopRampRate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - int *arg3 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = *(int **)&jarg3; - if (!arg3) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetCloseLoopRampRate(arg2,*arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetVoltageCompensationRate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(double **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetVoltageCompensationRate(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetForwardSoftLimit(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetForwardSoftLimit(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetReverseSoftLimit(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetReverseSoftLimit(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetForwardSoftEnable(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetForwardSoftEnable(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetReverseSoftEnable(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetReverseSoftEnable(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetStatusFrameRate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jlong jarg3) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - unsigned int arg2 ; - unsigned int arg3 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (unsigned int)jarg2; - arg3 = (unsigned int)jarg3; - result = (arg1)->SetStatusFrameRate(arg2,arg3); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1ClearStickyFaults(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - result = (arg1)->ClearStickyFaults(); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1OverTemp(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_OverTemp(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1UnderVoltage(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_UnderVoltage(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1ForLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_ForLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1RevLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_RevLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1HardwareFailure(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_HardwareFailure(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1ForSoftLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_ForSoftLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFault_1RevSoftLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFault_RevSoftLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1OverTemp(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_OverTemp(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1UnderVoltage(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_UnderVoltage(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1ForLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_ForLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1RevLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_RevLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1ForSoftLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_ForSoftLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetStckyFault_1RevSoftLim(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetStckyFault_RevSoftLim(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetAppliedThrottle(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetAppliedThrottle(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetCloseLoopErr(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetCloseLoopErr(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFeedbackDeviceSelect(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFeedbackDeviceSelect(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetModeSelect(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetModeSelect(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetLimitSwitchEn(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetLimitSwitchEn(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetLimitSwitchClosedFor(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetLimitSwitchClosedFor(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetLimitSwitchClosedRev(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetLimitSwitchClosedRev(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetSensorPosition(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetSensorPosition(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetSensorVelocity(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetSensorVelocity(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetCurrent(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(double **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetCurrent(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetBrakeIsEnabled(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetBrakeIsEnabled(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetEncPosition(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetEncPosition(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetEncVel(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetEncVel(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetEncIndexRiseEvents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetEncIndexRiseEvents(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetQuadApin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetQuadApin(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetQuadBpin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetQuadBpin(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetQuadIdxpin(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetQuadIdxpin(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetAnalogInWithOv(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetAnalogInWithOv(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetAnalogInVel(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetAnalogInVel(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetTemp(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(double **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetTemp(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetBatteryV(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(double **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "double & reference is null"); - return 0; - } - result = (arg1)->GetBatteryV(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetResetCount(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetResetCount(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetResetFlags(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetResetFlags(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetFirmVers(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetFirmVers(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetDemand(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetDemand(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetOverrideLimitSwitchEn(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetOverrideLimitSwitchEn(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetFeedbackDeviceSelect(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetFeedbackDeviceSelect(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetRevMotDuringCloseLoopEn(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetRevMotDuringCloseLoopEn(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetOverrideBrakeType(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetOverrideBrakeType(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetModeSelect(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetModeSelect(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetProfileSlotSelect(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetProfileSlotSelect(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetRampThrottle(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetRampThrottle(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetVoltageCompensationRate(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - double arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (double)jarg2; - result = (arg1)->SetVoltageCompensationRate(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SetRevFeedbackSensor(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int arg2 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = (int)jarg2; - result = (arg1)->SetRevFeedbackSensor(arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetPulseWidthPosition(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetPulseWidthPosition(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetPulseWidthVelocity(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetPulseWidthVelocity(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetPulseWidthRiseToFallUs(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetPulseWidthRiseToFallUs(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1GetPulseWidthRiseToRiseUs(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->GetPulseWidthRiseToRiseUs(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1IsPulseWidthSensorPresent(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { - jlong jresult = 0 ; - CanTalonSRX *arg1 = (CanTalonSRX *) 0 ; - int *arg2 = 0 ; - CTR_Code result; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(CanTalonSRX **)&jarg1; - arg2 = *(int **)&jarg2; - if (!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "int & reference is null"); - return 0; - } - result = (arg1)->IsPulseWidthSensorPresent(*arg2); - *(CTR_Code **)&jresult = new CTR_Code((const CTR_Code &)result); - return jresult; -} - - -SWIGEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_CanTalonJNI_CanTalonSRX_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { - jlong baseptr = 0; - (void)jenv; - (void)jcls; - *(CtreCanNode **)&baseptr = *(CanTalonSRX **)&jarg1; - return baseptr; -} - -#ifdef __cplusplus -} -#endif - diff --git a/wpilibj/src/athena/cpp/swigTalon/CanTalonSRX.i b/wpilibj/src/athena/cpp/swigTalon/CanTalonSRX.i deleted file mode 100644 index 8d8f0da8da..0000000000 --- a/wpilibj/src/athena/cpp/swigTalon/CanTalonSRX.i +++ /dev/null @@ -1,15 +0,0 @@ -%module CanTalon -%{ -#include "ctre/CanTalonSRX.h" -%} - -%include "cpointer.i" -%pointer_functions(double, doublep); -%pointer_functions(int, intp); -%pointer_functions(uint32_t, uint32_tp); -%pointer_functions(int32_t, int32_tp); -%pointer_functions(uint8_t, uint8_tp); -%pointer_functions(CTR_Code, CTR_Codep); -%pointer_functions(float, floatp); -%include "CtreCanNode.h" -%include "CanTalonSRX.h" diff --git a/wpilibj/src/athena/cpp/swigTalon/README b/wpilibj/src/athena/cpp/swigTalon/README deleted file mode 100644 index 52b1ea9d73..0000000000 --- a/wpilibj/src/athena/cpp/swigTalon/README +++ /dev/null @@ -1,10 +0,0 @@ -The generateJNI.sh script explains how to use it to generate the JNI bindings -for the CAN Talon stuff using swig. This whole directory is a temporary measure -until I (James Kuszmaul--11/18/2014) or someone else figures out how to -integrate the swig stuff into the build system. For now, all the generated JNI -bindings are checked into git, so that it should work until someone goes and updates ctre/CanTalonSRX.* - -In order for this to work, I had to change the CanTalonSRX constructor to take a int deviceNumber instead of a uint8_t. - -Also, in all the SWIGTYPE* files, you must change protected methods to public functions. -Because the SWIGTYPE* files don't generally change, you can jsut do a git checkout -- SWIGTYPE* in wpilibJavaDevices/....../wpilibj/ diff --git a/wpilibj/src/athena/cpp/swigTalon/generateJNI.sh b/wpilibj/src/athena/cpp/swigTalon/generateJNI.sh deleted file mode 100644 index 26a67a455a..0000000000 --- a/wpilibj/src/athena/cpp/swigTalon/generateJNI.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -#This script should be able to generate the JNI -# bindings for the CANTalon using swig.At some point, -# it should be integrated into the build system, -# but I[james 18 November 2014] don't know how to do that. -# Assumes running from allwpilib/wpilibj/wpilibJavaJNI/swigTalon -# Get files that we node to generate from. -cp ../../../hal/lib/Athena/ctre/CanTalonSRX.cpp ./ -cp ../../../wpilibc/wpilibC++Devices/include/ctre/* ./ -# Clean up from previous run. -rm *.java -# Run SWIG. -swig -c++ -package edu.wpi.first.wpilibj.hal -java CanTalonSRX.i -# Stick generated files into appropriate places. -cp CanTalonSRX_wrap.cxx ../lib/CanTalonSRXJNI.cpp -mv CanTalonJNI.java ../../wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/ -rm CanTalon.java # useless file. -cp *.java ../../wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/ diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CANTalon.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CANTalon.java index 2a5b230e86..50a69e9352 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CANTalon.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CANTalon.java @@ -1,12 +1,8 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.hal.CanTalonSRX; import edu.wpi.first.wpilibj.hal.CanTalonJNI; import edu.wpi.first.wpilibj.communication.UsageReporting; import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; -import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_double; -import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_int; -import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_CTR_Code; import edu.wpi.first.wpilibj.tables.ITable; import edu.wpi.first.wpilibj.tables.ITableListener; @@ -31,7 +27,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont private final double kMinutesPer100msUnit = 1.0/600.0; public enum TalonControlMode implements CANSpeedController.ControlMode { - PercentVbus(0), Position(1), Speed(2), Current(3), Voltage(4), Follower(5), Disabled(15); + PercentVbus(0), Position(1), Speed(2), Current(3), Voltage(4), Follower(5), MotionProfile(6), Disabled(15); public final int value; @@ -114,9 +110,165 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont this.value = value; } } + /** + * Enumerated types for Motion Control Set Values. + * When in Motion Profile control mode, these constants are paseed + * into set() to manipulate the motion profile executer. + * When changing modes, be sure to read the value back using getMotionProfileStatus() + * to ensure changes in output take effect before performing buffering actions. + * Disable will signal Talon to put motor output into neutral drive. + * Talon will stop processing motion profile points. This means the buffer is + * effectively disconnected from the executer, allowing the robot to gracefully + * clear and push new traj points. isUnderrun will get cleared. + * The active trajectory is also cleared. + * Enable will signal Talon to pop a trajectory point from it's buffer and process it. + * If the active trajectory is empty, Talon will shift in the next point. + * If the active traj is empty, and so is the buffer, the motor drive is neutral and + * isUnderrun is set. When active traj times out, and buffer has at least one point, + * Talon shifts in next one, and isUnderrun is cleared. When active traj times out, + * and buffer is empty, Talon keeps processing active traj and sets IsUnderrun. + * Hold will signal Talon keep processing the active trajectory indefinitely. + * If the active traj is cleared, Talon will neutral motor drive. Otherwise + * Talon will keep processing the active traj but it will not shift in + * points from the buffer. This means the buffer is effectively disconnected + * from the executer, allowing the robot to gracefully clear and push + * new traj points. + * isUnderrun is set if active traj is empty, otherwise it is cleared. + * isLast signal is also cleared. + * + * Typical workflow: + * set(Disable), + * Confirm Disable takes effect, + * clear buffer and push buffer points, + * set(Enable) when enough points have been pushed to ensure no underruns, + * wait for MP to finish or decide abort, + * If MP finished gracefully set(Hold) to hold position servo and disconnect buffer, + * If MP is being aborted set(Disable) to neutral the motor and disconnect buffer, + * Confirm mode takes effect, + * clear buffer and push buffer points, and rinse-repeat. + */ + public enum SetValueMotionProfile { + Disable(0), Enable(1), Hold(2); + public int value; + public static SetValueMotionProfile valueOf(int value) { + for (SetValueMotionProfile mode : values()) { + if (mode.value == value) { + return mode; + } + } + return null; + } - private CanTalonSRX m_impl; + private SetValueMotionProfile(int value) { + this.value = value; + } + } + /** + * Motion Profile Trajectory Point + * This is simply a data transer object. + */ + public static class TrajectoryPoint { + public double position; //!< The position to servo to. + public double velocity; //!< The velocity to feed-forward. + /** + * Time in milliseconds to process this point. + * Value should be between 1ms and 255ms. If value is zero + * then Talon will default to 1ms. If value exceeds 255ms API will cap it. + */ + public int timeDurMs; + /** + * Which slot to get PIDF gains. + * PID is used for position servo. + * F is used as the Kv constant for velocity feed-forward. + * Typically this is hardcoded to the a particular slot, but you are free + * gain schedule if need be. + */ + public int profileSlotSelect; + /** + * Set to true to only perform the velocity feed-forward and not perform + * position servo. This is useful when learning how the position servo + * changes the motor response. The same could be accomplish by clearing the + * PID gains, however this is synchronous the streaming, and doesn't require restoing + * gains when finished. + * + * Additionaly setting this basically gives you direct control of the motor output + * since motor output = targetVelocity X Kv, where Kv is our Fgain. + * This means you can also scheduling straight-throttle curves without relying on + * a sensor. + */ + public boolean velocityOnly; + /** + * Set to true to signal Talon that this is the final point, so do not + * attempt to pop another trajectory point from out of the Talon buffer. + * Instead continue processing this way point. Typically the velocity + * member variable should be zero so that the motor doesn't spin indefinitely. + */ + public boolean isLastPoint; + /** + * Set to true to signal Talon to zero the selected sensor. + * When generating MPs, one simple method is to make the first target position zero, + * and the final target position the target distance from the current position. + * Then when you fire the MP, the current position gets set to zero. + * If this is the intent, you can set zeroPos on the first trajectory point. + * + * Otherwise you can leave this false for all points, and offset the positions + * of all trajectory points so they are correct. + */ + public boolean zeroPos; + } + /** + * Motion Profile Status + * This is simply a data transer object. + */ + public static class MotionProfileStatus { + /** + * The available empty slots in the trajectory buffer. + * + * The robot API holds a "top buffer" of trajectory points, so your applicaion + * can dump several points at once. The API will then stream them into the Talon's + * low-level buffer, allowing the Talon to act on them. + */ + public int topBufferRem; + /** + * The number of points in the top trajectory buffer. + */ + public int topBufferCnt; + /** + * The number of points in the low level Talon buffer. + */ + public int btmBufferCnt; + /** + * Set if isUnderrun ever gets set. + * Only is cleared by clearMotionProfileHasUnderrun() to ensure + * robot logic can react or instrument it. + * @see clearMotionProfileHasUnderrun() + */ + public boolean hasUnderrun; + /** + * This is set if Talon needs to shift a point from its buffer into + * the active trajectory point however the buffer is empty. This gets cleared + * automatically when is resolved. + */ + public boolean isUnderrun; + /** + * True if the active trajectory point has not empty, false otherwise. + * The members in activePoint are only valid if this signal is set. + */ + public boolean activePointValid; + /** + * The number of points in the low level Talon buffer. + */ + public TrajectoryPoint activePoint = new TrajectoryPoint(); + /** + * The current output mode of the motion profile executer (disabled, enabled, or hold). + * When changing the set() value in MP mode, it's important to check this signal to + * confirm the change takes effect before interacting with the top buffer. + */ + public SetValueMotionProfile outputEnable; + } + + private long m_handle; private TalonControlMode m_controlMode; private static double kDelayForSolicitedSignals = 0.004; private double m_minimumInput; @@ -148,10 +300,13 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * for scaling into rotations and RPM. */ FeedbackDevice m_feedbackDevice; - + /** + * Constructor for the CANTalon device. + * @param deviceNumber The CAN ID of the Talon SRX + */ public CANTalon(int deviceNumber) { m_deviceNumber = deviceNumber; - m_impl = new CanTalonSRX(deviceNumber); + m_handle = CanTalonJNI.new_CanTalonSRX(deviceNumber); m_safetyHelper = new MotorSafetyHelper(this); m_controlEnabled = true; m_profile = 0; @@ -162,14 +317,39 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont setProfile(m_profile); applyControlMode(TalonControlMode.PercentVbus); } - + /** + * Constructor for the CANTalon device. + * @param deviceNumber The CAN ID of the Talon SRX + * @param controlPeriodMs The period in ms to send the CAN control frame. + * Period is bounded to [1ms,95ms]. + */ public CANTalon(int deviceNumber, int controlPeriodMs) { m_deviceNumber = deviceNumber; - m_impl = new CanTalonSRX(deviceNumber, controlPeriodMs); /* - * bound period to - * be within [1 - * ms,95 ms] - */ + /* bound period to be within [1 ms,95 ms] */ + m_handle = CanTalonJNI.new_CanTalonSRX(deviceNumber, controlPeriodMs); + m_safetyHelper = new MotorSafetyHelper(this); + m_controlEnabled = true; + m_profile = 0; + m_setPoint = 0; + m_codesPerRev = 0; + m_numPotTurns = 0; + m_feedbackDevice = FeedbackDevice.QuadEncoder; + setProfile(m_profile); + applyControlMode(TalonControlMode.PercentVbus); + } + /** + * Constructor for the CANTalon device. + * @param deviceNumber The CAN ID of the Talon SRX + * @param controlPeriodMs The period in ms to send the CAN control frame. + * Period is bounded to [1ms,95ms]. + * @param enablePeriodMs The period in ms to send the enable control frame. + * Period is bounded to [1ms,95ms]. This typically is not + * required to specify, however this could be used to minimize the + * time between robot-enable and talon-motor-drive. + */ + public CANTalon(int deviceNumber, int controlPeriodMs, int enablePeriodMs) { + m_deviceNumber = deviceNumber; + m_handle = CanTalonJNI.new_CanTalonSRX(deviceNumber, controlPeriodMs, enablePeriodMs); m_safetyHelper = new MotorSafetyHelper(this); m_controlEnabled = true; m_profile = 0; @@ -211,7 +391,10 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont public void delete() { disable(); - m_impl.delete(); + if (m_handle != 0) { + CanTalonJNI.delete_CanTalonSRX(m_handle); + m_handle = 0; + } } /** @@ -233,30 +416,33 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont m_setPoint = outputValue; /* cache set point for getSetpoint() */ switch (m_controlMode) { case PercentVbus: - m_impl.Set(isInverted ? -outputValue : outputValue); + CanTalonJNI.Set(m_handle, isInverted ? -outputValue : outputValue); break; case Follower: - m_impl.SetDemand((int) outputValue); + CanTalonJNI.SetDemand(m_handle, (int) outputValue); break; case Voltage: // Voltage is an 8.8 fixed point number. int volts = (int) ((isInverted ? -outputValue : outputValue) * 256); - m_impl.SetDemand(volts); + CanTalonJNI.SetDemand(m_handle, volts); break; case Speed: - m_impl.SetDemand(ScaleVelocityToNativeUnits(m_feedbackDevice,(isInverted ? -outputValue : outputValue))); + CanTalonJNI.SetDemand(m_handle, ScaleVelocityToNativeUnits(m_feedbackDevice,(isInverted ? -outputValue : outputValue))); break; case Position: - m_impl.SetDemand(ScaleRotationsToNativeUnits(m_feedbackDevice,outputValue)); + CanTalonJNI.SetDemand(m_handle, ScaleRotationsToNativeUnits(m_feedbackDevice,outputValue)); break; case Current: double milliamperes = (isInverted ? -outputValue : outputValue) * 1000.0; /* mA*/ - m_impl.SetDemand((int)milliamperes); + CanTalonJNI.SetDemand(m_handle, (int)milliamperes); + break; + case MotionProfile: + CanTalonJNI.SetDemand(m_handle, (int) outputValue); break; default: break; } - m_impl.SetModeSelect(m_controlMode.value); + CanTalonJNI.SetModeSelect(m_handle, m_controlMode.value); } } @@ -343,7 +529,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @param flip True if sensor input should be flipped; False if not. */ public void reverseSensor(boolean flip) { - m_impl.SetRevFeedbackSensor(flip ? 1 : 0); + CanTalonJNI.SetRevFeedbackSensor(m_handle, flip ? 1 : 0); } /** @@ -353,7 +539,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @param flip True if motor output should be flipped; False if not. */ public void reverseOutput(boolean flip) { - m_impl.SetRevMotDuringCloseLoopEn(flip ? 1 : 0); + CanTalonJNI.SetRevMotDuringCloseLoopEn(m_handle, flip ? 1 : 0); } /** @@ -366,31 +552,19 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return The current sensor value of the Talon. */ public double get() { - double retval = 0; - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); switch (m_controlMode) { case Voltage: - retval = getOutputVoltage(); - break; + return getOutputVoltage(); case Current: - retval = getOutputCurrent(); - break; + return getOutputCurrent(); case Speed: - m_impl.GetSensorVelocity(swigp); - retval = ScaleNativeUnitsToRpm(m_feedbackDevice,CanTalonJNI.intp_value(valuep)); - break; + return ScaleNativeUnitsToRpm(m_feedbackDevice,CanTalonJNI.GetSensorVelocity(m_handle)); case Position: - m_impl.GetSensorPosition(swigp); - retval = ScaleNativeUnitsToRotations(m_feedbackDevice,CanTalonJNI.intp_value(valuep)); - break; + return ScaleNativeUnitsToRotations(m_feedbackDevice,CanTalonJNI.GetSensorPosition(m_handle)); case PercentVbus: default: - m_impl.GetAppliedThrottle(swigp); - retval = (double) CanTalonJNI.intp_value(valuep) / 1023.0; - break; + return (double) CanTalonJNI.GetAppliedThrottle(m_handle) / 1023.0; } - return retval; } /** @@ -400,14 +574,11 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return The current position of the encoder. */ public int getEncPosition() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetEncPosition(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetEncPosition(m_handle); } public void setEncPosition(int newPosition) { - setParameter(CanTalonSRX.param_t.eEncPosition, newPosition); + setParameter(CanTalonJNI.param_t.eEncPosition, newPosition); } /** @@ -417,37 +588,22 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return The current speed of the encoder. */ public int getEncVelocity() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetEncVel(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetEncVel(m_handle); } public int getPulseWidthPosition() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetPulseWidthPosition(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetPulseWidthPosition(m_handle); } public void setPulseWidthPosition(int newPosition) { - setParameter(CanTalonSRX.param_t.ePwdPosition, newPosition); + setParameter(CanTalonJNI.param_t.ePwdPosition, newPosition); } public int getPulseWidthVelocity() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetPulseWidthVelocity(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetPulseWidthVelocity(m_handle); } public int getPulseWidthRiseToFallUs() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetPulseWidthRiseToFallUs(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetPulseWidthRiseToFallUs(m_handle); } public int getPulseWidthRiseToRiseUs() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetPulseWidthRiseToRiseUs(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetPulseWidthRiseToRiseUs(m_handle); } /** * @param feedbackDevice which feedback sensor to check it if is connected. @@ -469,11 +625,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont case CtreMagEncoder_Relative: case CtreMagEncoder_Absolute: /* all of these require pulse width signal to be present. */ - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - SWIGTYPE_p_CTR_Code status = m_impl.IsPulseWidthSensorPresent(swigp); - /* TODO: add a check for CanTalonJNI.CTR_Codep_value(status) */ - if( CanTalonJNI.intp_value(valuep) == 0 ){ + if( CanTalonJNI.IsPulseWidthSensorPresent(m_handle) == 0 ){ /* Talon not getting a signal */ retval = FeedbackDeviceStatus.FeedbackStatusNotPresent; }else{ @@ -490,44 +642,32 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return number of rising edges on idx pin. */ public int getNumberOfQuadIdxRises() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetEncIndexRiseEvents(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetEncIndexRiseEvents(m_handle); } /** * @return IO level of QUADA pin. */ public int getPinStateQuadA() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetQuadApin(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetQuadApin(m_handle); } /** * @return IO level of QUADB pin. */ public int getPinStateQuadB() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetQuadBpin(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetQuadBpin(m_handle); } /** * @return IO level of QUAD Index pin. */ public int getPinStateQuadIdx() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetQuadIdxpin(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetQuadIdxpin(m_handle); } public void setAnalogPosition(int newPosition){ - setParameter(CanTalonSRX.param_t.eAinPosition, (double)newPosition); + setParameter(CanTalonJNI.param_t.eAinPosition, (double)newPosition); } /** * Get the current analog in position, regardless of whether it is the current @@ -538,10 +678,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * overflows and underflows (continuous sensor). */ public int getAnalogInPosition() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetAnalogInWithOv(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetAnalogInWithOv(m_handle); } /** @@ -561,10 +698,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return The current speed of the analog in device. */ public int getAnalogInVelocity() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetAnalogInVel(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetAnalogInVel(m_handle); } /** @@ -573,49 +707,37 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @return The error, in whatever units are appropriate. */ public int getClosedLoopError() { - long valuep = CanTalonJNI.new_intp(); /* retrieve the closed loop error in native units */ - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetCloseLoopErr(swigp); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetCloseLoopErr(m_handle); } /** * Set the allowable closed loop error. * @param allowableCloseLoopError allowable closed loop error for selected profile. - * mA for Curent closed loop. - * Talon Native Units for position and velocity. + * mA for Curent closed loop. + * Talon Native Units for position and velocity. */ public void setAllowableClosedLoopErr(int allowableCloseLoopError) { if(m_profile == 0){ - setParameter(CanTalonSRX.param_t.eProfileParamSlot0_AllowableClosedLoopErr, (double)allowableCloseLoopError); + setParameter(CanTalonJNI.param_t.eProfileParamSlot0_AllowableClosedLoopErr, (double)allowableCloseLoopError); }else{ - setParameter(CanTalonSRX.param_t.eProfileParamSlot1_AllowableClosedLoopErr, (double)allowableCloseLoopError); + setParameter(CanTalonJNI.param_t.eProfileParamSlot1_AllowableClosedLoopErr, (double)allowableCloseLoopError); } } // Returns true if limit switch is closed. false if open. public boolean isFwdLimitSwitchClosed() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetLimitSwitchClosedFor(swigp); - return (CanTalonJNI.intp_value(valuep) == 0) ? true : false; + return (CanTalonJNI.GetLimitSwitchClosedFor(m_handle) == 0) ? true : false; } // Returns true if limit switch is closed. false if open. public boolean isRevLimitSwitchClosed() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetLimitSwitchClosedRev(swigp); - return (CanTalonJNI.intp_value(valuep) == 0) ? true : false; + return (CanTalonJNI.GetLimitSwitchClosedRev(m_handle) == 0) ? true : false; } // Returns true if break is enabled during neutral. false if coast. public boolean getBrakeEnableDuringNeutral() { - long valuep = CanTalonJNI.new_intp(); - SWIGTYPE_p_int swigp = new SWIGTYPE_p_int(valuep, true); - m_impl.GetBrakeIsEnabled(swigp); - return (CanTalonJNI.intp_value(valuep) == 0) ? false : true; + return (CanTalonJNI.GetBrakeIsEnabled(m_handle) == 0) ? false : true; } /** @@ -629,7 +751,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont /* next send the scalar to the Talon over CAN. This is so that the Talon can report it to whoever needs it, like the webdash. Don't bother checking the return, this is only for instrumentation and is not necessary for Talon functionality. */ - setParameter(CanTalonSRX.param_t.eNumberEncoderCPR, m_codesPerRev); + setParameter(CanTalonJNI.param_t.eNumberEncoderCPR, m_codesPerRev); } /** * Configure the number of turns on the potentiometer. @@ -642,50 +764,34 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont /* next send the scalar to the Talon over CAN. This is so that the Talon can report it to whoever needs it, like the webdash. Don't bother checking the return, this is only for instrumentation and is not necessary for Talon functionality. */ - setParameter(CanTalonSRX.param_t.eNumberPotTurns, m_numPotTurns); + setParameter(CanTalonJNI.param_t.eNumberPotTurns, m_numPotTurns); } /** * Returns temperature of Talon, in degrees Celsius. */ public double getTemperature() { - long tempp = CanTalonJNI.new_doublep(); // Create a new swig pointer. - m_impl.GetTemp(new SWIGTYPE_p_double(tempp, true)); - return CanTalonJNI.doublep_value(tempp); + return CanTalonJNI.GetTemp(m_handle); } /** * Returns the current going through the Talon, in Amperes. */ public double getOutputCurrent() { - long curp = CanTalonJNI.new_doublep(); // Create a new swig pointer. - m_impl.GetCurrent(new SWIGTYPE_p_double(curp, true)); - return CanTalonJNI.doublep_value(curp); + return CanTalonJNI.GetCurrent(m_handle); } /** * @return The voltage being output by the Talon, in Volts. */ public double getOutputVoltage() { - long throttlep = CanTalonJNI.new_intp(); - m_impl.GetAppliedThrottle(new SWIGTYPE_p_int(throttlep, true)); - double voltage = getBusVoltage() * (double) CanTalonJNI.intp_value(throttlep) / 1023.0; - return voltage; + return getBusVoltage() * (double) CanTalonJNI.GetAppliedThrottle(m_handle) / 1023.0; } /** * @return The voltage at the battery terminals of the Talon, in Volts. */ public double getBusVoltage() { - long voltagep = CanTalonJNI.new_doublep(); - SWIGTYPE_p_CTR_Code status = m_impl.GetBatteryV(new SWIGTYPE_p_double(voltagep, true)); - /* - * Note: This section needs the JNI bindings regenerated with - * pointer_functions for CTR_Code included in order to be able to catch - * notice and throw errors. if (CanTalonJNI.CTR_Codep_value(status) != 0) { - * // TODO throw an error. } - */ - - return CanTalonJNI.doublep_value(voltagep); + return CanTalonJNI.GetBatteryV(m_handle); } /** @@ -698,14 +804,12 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * quadrature, each unit is a quadrature edge (4X) mode. */ public double getPosition() { - long positionp = CanTalonJNI.new_intp(); - m_impl.GetSensorPosition(new SWIGTYPE_p_int(positionp, true)); - return ScaleNativeUnitsToRotations(m_feedbackDevice,CanTalonJNI.intp_value(positionp)); + return ScaleNativeUnitsToRotations(m_feedbackDevice,CanTalonJNI.GetSensorPosition(m_handle)); } public void setPosition(double pos) { int nativePos = ScaleRotationsToNativeUnits(m_feedbackDevice,pos); - m_impl.SetSensorPosition(nativePos); + CanTalonJNI.SetSensorPosition(m_handle, nativePos); } /** @@ -724,9 +828,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * rotation per 100ms, or 10 rotations per second. */ public double getSpeed() { - long speedp = CanTalonJNI.new_intp(); - m_impl.GetSensorVelocity(new SWIGTYPE_p_int(speedp, true)); - return ScaleNativeUnitsToRpm(m_feedbackDevice,CanTalonJNI.intp_value(speedp)); + return ScaleNativeUnitsToRpm(m_feedbackDevice,CanTalonJNI.GetSensorVelocity(m_handle)); } public TalonControlMode getControlMode() { @@ -751,7 +853,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont if (controlMode == TalonControlMode.Disabled) m_controlEnabled = false; // Disable until set() is called. - m_impl.SetModeSelect(TalonControlMode.Disabled.value); + CanTalonJNI.SetModeSelect(m_handle, TalonControlMode.Disabled.value); UsageReporting.report(tResourceType.kResourceType_CANTalonSRX, m_deviceNumber + 1, controlMode.value); @@ -769,11 +871,11 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont /* save the selection so that future setters/getters know which scalars to apply */ m_feedbackDevice = device; /* pass feedback to actual CAN frame */ - m_impl.SetFeedbackDeviceSelect(device.value); + CanTalonJNI.SetFeedbackDeviceSelect(m_handle, device.value); } public void setStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs) { - m_impl.SetStatusFrameRate(stateFrame.value, periodMs); + CanTalonJNI.SetStatusFrameRate(m_handle, stateFrame.value, periodMs); } public void enableControl() { @@ -786,7 +888,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont } public void disableControl() { - m_impl.SetModeSelect(TalonControlMode.Disabled.value); + CanTalonJNI.SetModeSelect(m_handle, TalonControlMode.Disabled.value); m_controlEnabled = false; } @@ -808,16 +910,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_P); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_P.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_P); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_P.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long pp = CanTalonJNI.new_doublep(); - m_impl.GetPgain(m_profile, new SWIGTYPE_p_double(pp, true)); - return CanTalonJNI.doublep_value(pp); + return CanTalonJNI.GetPgain(m_handle, m_profile); } public double getI() { @@ -829,16 +929,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_I); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_I.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_I); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_I.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long ip = CanTalonJNI.new_doublep(); - m_impl.GetIgain(m_profile, new SWIGTYPE_p_double(ip, true)); - return CanTalonJNI.doublep_value(ip); + return CanTalonJNI.GetIgain(m_handle, m_profile); } public double getD() { @@ -850,16 +948,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_D); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_D.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_D); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_D.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long dp = CanTalonJNI.new_doublep(); - m_impl.GetDgain(m_profile, new SWIGTYPE_p_double(dp, true)); - return CanTalonJNI.doublep_value(dp); + return CanTalonJNI.GetDgain(m_handle, m_profile); } public double getF() { @@ -871,16 +967,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_F); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_F.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_F); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_F.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long fp = CanTalonJNI.new_doublep(); - m_impl.GetFgain(m_profile, new SWIGTYPE_p_double(fp, true)); - return CanTalonJNI.doublep_value(fp); + return CanTalonJNI.GetFgain(m_handle, m_profile); } public double getIZone() { @@ -892,16 +986,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_IZone); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_IZone.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_IZone); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_IZone.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long fp = CanTalonJNI.new_intp(); - m_impl.GetIzone(m_profile, new SWIGTYPE_p_int(fp, true)); - return CanTalonJNI.intp_value(fp); + return CanTalonJNI.GetIzone(m_handle, m_profile); } /** @@ -922,16 +1014,14 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // Update the information that we have. if (m_profile == 0) - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot0_CloseLoopRampRate); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot0_CloseLoopRampRate.value); else - m_impl.RequestParam(CanTalonSRX.param_t.eProfileParamSlot1_CloseLoopRampRate); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eProfileParamSlot1_CloseLoopRampRate.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long fp = CanTalonJNI.new_intp(); - m_impl.GetCloseLoopRampRate(m_profile, new SWIGTYPE_p_int(fp, true)); - double throttlePerMs = CanTalonJNI.intp_value(fp); + double throttlePerMs = CanTalonJNI.GetCloseLoopRampRate(m_handle, m_profile); return throttlePerMs / 1023.0 * 12.0 * 1000.0; } @@ -941,27 +1031,23 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont public long GetFirmwareVersion() { // Update the information that we have. - m_impl.RequestParam(CanTalonSRX.param_t.eFirmVers); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.eFirmVers.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long fp = CanTalonJNI.new_intp(); - m_impl.GetParamResponseInt32(CanTalonSRX.param_t.eFirmVers, new SWIGTYPE_p_int(fp, true)); - return CanTalonJNI.intp_value(fp); + return CanTalonJNI.GetParamResponseInt32(m_handle, CanTalonJNI.param_t.eFirmVers.value); } public long GetIaccum() { // Update the information that we have. - m_impl.RequestParam(CanTalonSRX.param_t.ePidIaccum); + CanTalonJNI.RequestParam(m_handle, CanTalonJNI.param_t.ePidIaccum.value); // Briefly wait for new values from the Talon. Timer.delay(kDelayForSolicitedSignals); - long fp = CanTalonJNI.new_intp(); - m_impl.GetParamResponseInt32(CanTalonSRX.param_t.ePidIaccum, new SWIGTYPE_p_int(fp, true)); - return CanTalonJNI.intp_value(fp); + return CanTalonJNI.GetParamResponseInt32(m_handle, CanTalonJNI.param_t.ePidIaccum.value); } /** @@ -971,7 +1057,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setP(double p) { - m_impl.SetPgain(m_profile, p); + CanTalonJNI.SetPgain(m_handle, m_profile, p); } /** @@ -981,7 +1067,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setI(double i) { - m_impl.SetIgain(m_profile, i); + CanTalonJNI.SetIgain(m_handle, m_profile, i); } /** @@ -991,7 +1077,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setD(double d) { - m_impl.SetDgain(m_profile, d); + CanTalonJNI.SetDgain(m_handle, m_profile, d); } /** @@ -1001,7 +1087,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setF(double f) { - m_impl.SetFgain(m_profile, f); + CanTalonJNI.SetFgain(m_handle, m_profile, f); } /** @@ -1016,7 +1102,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setIZone(int izone) { - m_impl.SetIzone(m_profile, izone); + CanTalonJNI.SetIzone(m_handle, m_profile, izone); } /** @@ -1029,9 +1115,9 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @see #setProfile For selecting a certain profile. */ public void setCloseLoopRampRate(double rampRate) { - // CanTalonSRX takes units of Throttle (0 - 1023) / 1ms. + // CanTalonJNI takes units of Throttle (0 - 1023) / 1ms. int rate = (int) (rampRate * 1023.0 / 12.0 / 1000.0); - m_impl.SetCloseLoopRampRate(m_profile, rate); + CanTalonJNI.SetCloseLoopRampRate(m_handle, m_profile, rate); } /** @@ -1042,19 +1128,19 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @param rampRate Maximum change in voltage, in volts / sec. */ public void setVoltageRampRate(double rampRate) { - // CanTalonSRX takes units of Throttle (0 - 1023) / 10ms. + // CanTalonJNI takes units of Throttle (0 - 1023) / 10ms. int rate = (int) (rampRate * 1023.0 / 12.0 / 100.0); - m_impl.SetRampThrottle(rate); + CanTalonJNI.SetRampThrottle(m_handle, rate); } public void setVoltageCompensationRampRate(double rampRate) { - m_impl.SetVoltageCompensationRate(rampRate / 1000); + CanTalonJNI.SetVoltageCompensationRate(m_handle, rampRate / 1000); } /** * Clear the accumulator for I gain. */ public void ClearIaccum() { - SWIGTYPE_p_CTR_Code status = m_impl.SetParam(CanTalonSRX.param_t.ePidIaccum, 0); + CanTalonJNI.SetParam(m_handle, CanTalonJNI.param_t.ePidIaccum.value, 0); } /** @@ -1106,7 +1192,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont if (profile != 0 && profile != 1) throw new IllegalArgumentException("Talon PID profile must be 0 or 1."); m_profile = profile; - m_impl.SetProfileSlotSelect(m_profile); + CanTalonJNI.SetProfileSlotSelect(m_handle, m_profile); } /** @@ -1131,49 +1217,41 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont // TODO: Documentation for all these accessors/setters for misc. stuff. public void clearIAccum() { - SWIGTYPE_p_CTR_Code status = m_impl.SetParam(CanTalonSRX.param_t.ePidIaccum, 0); + CanTalonJNI.SetParam(m_handle, CanTalonJNI.param_t.ePidIaccum.value, 0); } public void setForwardSoftLimit(double forwardLimit) { int nativeLimitPos = ScaleRotationsToNativeUnits(m_feedbackDevice,forwardLimit); - m_impl.SetForwardSoftLimit(nativeLimitPos); + CanTalonJNI.SetForwardSoftLimit(m_handle, nativeLimitPos); } public int getForwardSoftLimit() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetForwardSoftLimit(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetForwardSoftLimit(m_handle); } public void enableForwardSoftLimit(boolean enable) { - m_impl.SetForwardSoftEnable(enable ? 1 : 0); + CanTalonJNI.SetForwardSoftEnable(m_handle, enable ? 1 : 0); } public boolean isForwardSoftLimitEnabled() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetForwardSoftEnable(new SWIGTYPE_p_int(valuep, true)); - return (CanTalonJNI.intp_value(valuep) == 0) ? false : true; + return (CanTalonJNI.GetForwardSoftEnable(m_handle) == 0) ? false : true; } public void setReverseSoftLimit(double reverseLimit) { int nativeLimitPos = ScaleRotationsToNativeUnits(m_feedbackDevice,reverseLimit); - m_impl.SetReverseSoftLimit(nativeLimitPos); + CanTalonJNI.SetReverseSoftLimit(m_handle, nativeLimitPos); } public int getReverseSoftLimit() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetReverseSoftLimit(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetReverseSoftLimit(m_handle); } public void enableReverseSoftLimit(boolean enable) { - m_impl.SetReverseSoftEnable(enable ? 1 : 0); + CanTalonJNI.SetReverseSoftEnable(m_handle, enable ? 1 : 0); } public boolean isReverseSoftLimitEnabled() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetReverseSoftEnable(new SWIGTYPE_p_int(valuep, true)); - return (CanTalonJNI.intp_value(valuep) == 0) ? false : true; + return (CanTalonJNI.GetReverseSoftEnable(m_handle) == 0) ? false : true; } /** * Configure the maximum voltage that the Jaguar will ever output. @@ -1185,67 +1263,63 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont */ public void configMaxOutputVoltage(double voltage) { /* config peak throttle when in closed-loop mode in the fwd and rev direction. */ - configPeakOutputVoltage(voltage, -voltage); + configPeakOutputVoltage(voltage, -voltage); } public void configPeakOutputVoltage(double forwardVoltage,double reverseVoltage) { /* bounds checking */ if(forwardVoltage > 12) - forwardVoltage = 12; + forwardVoltage = 12; else if(forwardVoltage < 0) forwardVoltage = 0; if(reverseVoltage > 0) - reverseVoltage = 0; + reverseVoltage = 0; else if(reverseVoltage < -12) reverseVoltage = -12; /* config calls */ - setParameter(CanTalonSRX.param_t.ePeakPosOutput,1023*forwardVoltage/12.0); - setParameter(CanTalonSRX.param_t.ePeakNegOutput,1023*reverseVoltage/12.0); + setParameter(CanTalonJNI.param_t.ePeakPosOutput,1023*forwardVoltage/12.0); + setParameter(CanTalonJNI.param_t.ePeakNegOutput,1023*reverseVoltage/12.0); } public void configNominalOutputVoltage(double forwardVoltage,double reverseVoltage) { /* bounds checking */ if(forwardVoltage > 12) - forwardVoltage = 12; + forwardVoltage = 12; else if(forwardVoltage < 0) forwardVoltage = 0; if(reverseVoltage > 0) - reverseVoltage = 0; + reverseVoltage = 0; else if(reverseVoltage < -12) reverseVoltage = -12; /* config calls */ - setParameter(CanTalonSRX.param_t.eNominalPosOutput,1023*forwardVoltage/12.0); - setParameter(CanTalonSRX.param_t.eNominalNegOutput,1023*reverseVoltage/12.0); + setParameter(CanTalonJNI.param_t.eNominalPosOutput,1023*forwardVoltage/12.0); + setParameter(CanTalonJNI.param_t.eNominalNegOutput,1023*reverseVoltage/12.0); } /** * General set frame. Since the parameter is a general integral type, this can * be used for testing future features. */ - public void setParameter(CanTalonSRX.param_t paramEnum, double value){ - SWIGTYPE_p_CTR_Code status = m_impl.SetParam(paramEnum,value); - /* TODO: error report to driver station */ + public void setParameter(CanTalonJNI.param_t paramEnum, double value){ + CanTalonJNI.SetParam(m_handle,paramEnum.value,value); } /** * General get frame. Since the parameter is a general integral type, this can * be used for testing future features. */ - public double getParameter(CanTalonSRX.param_t paramEnum) { - /* transmit a request for this param */ - m_impl.RequestParam(paramEnum); + public double getParameter(CanTalonJNI.param_t paramEnum) { + /* transmit a request for this param */ + CanTalonJNI.RequestParam(m_handle, paramEnum.value); /* Briefly wait for new values from the Talon. */ Timer.delay(kDelayForSolicitedSignals); - /* poll out latest response value */ - long pp = CanTalonJNI.new_doublep(); - SWIGTYPE_p_CTR_Code status = m_impl.GetParamResponse(paramEnum, new SWIGTYPE_p_double(pp, true)); - /* pass latest value back to caller */ - return CanTalonJNI.doublep_value(pp); + /* poll out latest response value */ + return CanTalonJNI.GetParamResponse(m_handle, paramEnum.value); } public void clearStickyFaults() { - m_impl.ClearStickyFaults(); + CanTalonJNI.ClearStickyFaults(m_handle); } public void enableLimitSwitch(boolean forward, boolean reverse) { int mask = 4 + (forward ? 1 : 0) * 2 + (reverse ? 1 : 0); - m_impl.SetOverrideLimitSwitchEn(mask); + CanTalonJNI.SetOverrideLimitSwitchEn(m_handle, mask); } /** @@ -1259,8 +1333,7 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @param normallyOpen true for normally open. false for normally closed. */ public void ConfigFwdLimitSwitchNormallyOpen(boolean normallyOpen) { - SWIGTYPE_p_CTR_Code status = - m_impl.SetParam(CanTalonSRX.param_t.eOnBoot_LimitSwitch_Forward_NormallyClosed, + CanTalonJNI.SetParam(m_handle, CanTalonJNI.param_t.eOnBoot_LimitSwitch_Forward_NormallyClosed.value, normallyOpen ? 0 : 1); } @@ -1275,271 +1348,365 @@ public class CANTalon implements MotorSafety, PIDOutput, PIDSource, CANSpeedCont * @param normallyOpen true for normally open. false for normally closed. */ public void ConfigRevLimitSwitchNormallyOpen(boolean normallyOpen) { - SWIGTYPE_p_CTR_Code status = - m_impl.SetParam(CanTalonSRX.param_t.eOnBoot_LimitSwitch_Reverse_NormallyClosed, + CanTalonJNI.SetParam(m_handle, CanTalonJNI.param_t.eOnBoot_LimitSwitch_Reverse_NormallyClosed.value, normallyOpen ? 0 : 1); } public void enableBrakeMode(boolean brake) { - m_impl.SetOverrideBrakeType(brake ? 2 : 1); + CanTalonJNI.SetOverrideBrakeType(m_handle, brake ? 2 : 1); } public int getFaultOverTemp() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_OverTemp(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_OverTemp(m_handle); } public int getFaultUnderVoltage() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_UnderVoltage(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_UnderVoltage(m_handle); } public int getFaultForLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_ForLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_ForLim(m_handle); } public int getFaultRevLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_RevLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_RevLim(m_handle); } public int getFaultHardwareFailure() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_HardwareFailure(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_HardwareFailure(m_handle); } public int getFaultForSoftLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_ForSoftLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_ForSoftLim(m_handle); } public int getFaultRevSoftLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetFault_RevSoftLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetFault_RevSoftLim(m_handle); } public int getStickyFaultOverTemp() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_OverTemp(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_OverTemp(m_handle); } public int getStickyFaultUnderVoltage() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_UnderVoltage(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_UnderVoltage(m_handle); } public int getStickyFaultForLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_ForLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_ForLim(m_handle); } public int getStickyFaultRevLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_RevLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_RevLim(m_handle); } public int getStickyFaultForSoftLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_ForSoftLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_ForSoftLim(m_handle); } public int getStickyFaultRevSoftLim() { - long valuep = CanTalonJNI.new_intp(); - m_impl.GetStckyFault_RevSoftLim(new SWIGTYPE_p_int(valuep, true)); - return CanTalonJNI.intp_value(valuep); + return CanTalonJNI.GetStckyFault_RevSoftLim(m_handle); } /** * @return Number of native units per rotation if scaling info is available. - * Zero if scaling information is not available. + * Zero if scaling information is not available. */ double GetNativeUnitsPerRotationScalar(FeedbackDevice devToLookup) { - double retval = 0; - boolean scalingAvail = false; - switch(devToLookup){ - case QuadEncoder: - { /* When caller wants to lookup Quadrature, the QEI may be in 1x if the selected feedback is edge counter. - * Additionally if the quadrature source is the CTRE Mag encoder, then the CPR is known. - * This is nice in that the calling app does not require knowing the CPR at all. - * So do both checks here. - */ - int qeiPulsePerCount = 4; /* default to 4x */ - switch(m_feedbackDevice){ - case CtreMagEncoder_Relative: - case CtreMagEncoder_Absolute: - /* we assume the quadrature signal comes from the MagEnc, - of which we know the CPR already */ - retval = kNativePwdUnitsPerRotation; - scalingAvail = true; - break; - case EncRising: /* Talon's QEI is setup for 1x, so perform 1x math */ - case EncFalling: - qeiPulsePerCount = 1; - break; - case QuadEncoder: /* Talon's QEI is 4x */ - default: /* pulse width and everything else, assume its regular quad use. */ - break; - } - if(scalingAvail){ - /* already deduced the scalar above, we're done. */ - }else{ - /* we couldn't deduce the scalar just based on the selection */ - if(0 == m_codesPerRev){ - /* caller has never set the CPR. Most likely caller - is just using engineering units so fall to the - bottom of this func.*/ - }else{ - /* Talon expects PPR units */ - retval = 4 * m_codesPerRev; - scalingAvail = true; - } - } - } break; - case EncRising: - case EncFalling: - if(0 == m_codesPerRev){ - /* caller has never set the CPR. Most likely caller - is just using engineering units so fall to the - bottom of this func.*/ - }else{ - /* Talon expects PPR units */ - retval = 1 * m_codesPerRev; - scalingAvail = true; - } - break; - case AnalogPot: - case AnalogEncoder: - if(0 == m_numPotTurns){ - /* caller has never set the CPR. Most likely caller - is just using engineering units so fall to the - bottom of this func.*/ - }else { - retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns; - scalingAvail = true; - } - break; - case CtreMagEncoder_Relative: - case CtreMagEncoder_Absolute: - case PulseWidth: - retval = kNativePwdUnitsPerRotation; - scalingAvail = true; - break; - } - /* if scaling info is not available give caller zero */ - if(false == scalingAvail) - return 0; - return retval; + double retval = 0; + boolean scalingAvail = false; + switch(devToLookup){ + case QuadEncoder: + { /* When caller wants to lookup Quadrature, the QEI may be in 1x if the selected feedback is edge counter. + * Additionally if the quadrature source is the CTRE Mag encoder, then the CPR is known. + * This is nice in that the calling app does not require knowing the CPR at all. + * So do both checks here. + */ + int qeiPulsePerCount = 4; /* default to 4x */ + switch(m_feedbackDevice){ + case CtreMagEncoder_Relative: + case CtreMagEncoder_Absolute: + /* we assume the quadrature signal comes from the MagEnc, + of which we know the CPR already */ + retval = kNativePwdUnitsPerRotation; + scalingAvail = true; + break; + case EncRising: /* Talon's QEI is setup for 1x, so perform 1x math */ + case EncFalling: + qeiPulsePerCount = 1; + break; + case QuadEncoder: /* Talon's QEI is 4x */ + default: /* pulse width and everything else, assume its regular quad use. */ + break; + } + if(scalingAvail){ + /* already deduced the scalar above, we're done. */ + }else{ + /* we couldn't deduce the scalar just based on the selection */ + if(0 == m_codesPerRev){ + /* caller has never set the CPR. Most likely caller + is just using engineering units so fall to the + bottom of this func.*/ + }else{ + /* Talon expects PPR units */ + retval = 4 * m_codesPerRev; + scalingAvail = true; + } + } + } break; + case EncRising: + case EncFalling: + if(0 == m_codesPerRev){ + /* caller has never set the CPR. Most likely caller + is just using engineering units so fall to the + bottom of this func.*/ + }else{ + /* Talon expects PPR units */ + retval = 1 * m_codesPerRev; + scalingAvail = true; + } + break; + case AnalogPot: + case AnalogEncoder: + if(0 == m_numPotTurns){ + /* caller has never set the CPR. Most likely caller + is just using engineering units so fall to the + bottom of this func.*/ + }else { + retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns; + scalingAvail = true; + } + break; + case CtreMagEncoder_Relative: + case CtreMagEncoder_Absolute: + case PulseWidth: + retval = kNativePwdUnitsPerRotation; + scalingAvail = true; + break; + } + /* if scaling info is not available give caller zero */ + if(false == scalingAvail) + return 0; + return retval; } /** - * @param fullRotations double precision value representing number of rotations of selected feedback sensor. - * If user has never called the config routine for the selected sensor, then the caller - * is likely passing rotations in engineering units already, in which case it is returned - * as is. - * @see configPotentiometerTurns - * @see configEncoderCodesPerRev + * @param fullRotations double precision value representing number of rotations of selected feedback sensor. + * If user has never called the config routine for the selected sensor, then the caller + * is likely passing rotations in engineering units already, in which case it is returned + * as is. + * @see configPotentiometerTurns + * @see configEncoderCodesPerRev * @return fullRotations in native engineering units of the Talon SRX firmware. */ int ScaleRotationsToNativeUnits(FeedbackDevice devToLookup, double fullRotations) { - /* first assume we don't have config info, prep the default return */ - int retval = (int)fullRotations; - /* retrieve scaling info */ - double scalar = GetNativeUnitsPerRotationScalar(devToLookup); - /* apply scalar if its available */ - if(scalar > 0) - retval = (int)(fullRotations*scalar); - return retval; + /* first assume we don't have config info, prep the default return */ + int retval = (int)fullRotations; + /* retrieve scaling info */ + double scalar = GetNativeUnitsPerRotationScalar(devToLookup); + /* apply scalar if its available */ + if(scalar > 0) + retval = (int)(fullRotations*scalar); + return retval; } /** - * @param rpm double precision value representing number of rotations per minute of selected feedback sensor. - * If user has never called the config routine for the selected sensor, then the caller - * is likely passing rotations in engineering units already, in which case it is returned - * as is. - * @see configPotentiometerTurns - * @see configEncoderCodesPerRev + * @param rpm double precision value representing number of rotations per minute of selected feedback sensor. + * If user has never called the config routine for the selected sensor, then the caller + * is likely passing rotations in engineering units already, in which case it is returned + * as is. + * @see configPotentiometerTurns + * @see configEncoderCodesPerRev * @return sensor velocity in native engineering units of the Talon SRX firmware. */ int ScaleVelocityToNativeUnits(FeedbackDevice devToLookup, double rpm) { - /* first assume we don't have config info, prep the default return */ - int retval = (int)rpm; - /* retrieve scaling info */ - double scalar = GetNativeUnitsPerRotationScalar(devToLookup); - /* apply scalar if its available */ - if(scalar > 0) - retval = (int)(rpm * kMinutesPer100msUnit * scalar); - return retval; + /* first assume we don't have config info, prep the default return */ + int retval = (int)rpm; + /* retrieve scaling info */ + double scalar = GetNativeUnitsPerRotationScalar(devToLookup); + /* apply scalar if its available */ + if(scalar > 0) + retval = (int)(rpm * kMinutesPer100msUnit * scalar); + return retval; } /** - * @param nativePos integral position of the feedback sensor in native Talon SRX units. - * If user has never called the config routine for the selected sensor, then the return - * will be in TALON SRX units as well to match the behavior in the 2015 season. - * @see configPotentiometerTurns - * @see configEncoderCodesPerRev + * @param nativePos integral position of the feedback sensor in native Talon SRX units. + * If user has never called the config routine for the selected sensor, then the return + * will be in TALON SRX units as well to match the behavior in the 2015 season. + * @see configPotentiometerTurns + * @see configEncoderCodesPerRev * @return double precision number of rotations, unless config was never performed. */ double ScaleNativeUnitsToRotations(FeedbackDevice devToLookup, int nativePos) { - /* first assume we don't have config info, prep the default return */ - double retval = (double)nativePos; - /* retrieve scaling info */ - double scalar = GetNativeUnitsPerRotationScalar(devToLookup); - /* apply scalar if its available */ - if(scalar > 0) - retval = ((double)nativePos) / scalar; - return retval; + /* first assume we don't have config info, prep the default return */ + double retval = (double)nativePos; + /* retrieve scaling info */ + double scalar = GetNativeUnitsPerRotationScalar(devToLookup); + /* apply scalar if its available */ + if(scalar > 0) + retval = ((double)nativePos) / scalar; + return retval; } /** - * @param nativeVel integral velocity of the feedback sensor in native Talon SRX units. - * If user has never called the config routine for the selected sensor, then the return - * will be in TALON SRX units as well to match the behavior in the 2015 season. - * @see configPotentiometerTurns - * @see configEncoderCodesPerRev + * @param nativeVel integral velocity of the feedback sensor in native Talon SRX units. + * If user has never called the config routine for the selected sensor, then the return + * will be in TALON SRX units as well to match the behavior in the 2015 season. + * @see configPotentiometerTurns + * @see configEncoderCodesPerRev * @return double precision of sensor velocity in RPM, unless config was never performed. */ double ScaleNativeUnitsToRpm(FeedbackDevice devToLookup, long nativeVel) { /* first assume we don't have config info, prep the default return */ - double retval = (double)nativeVel; - /* retrieve scaling info */ - double scalar = GetNativeUnitsPerRotationScalar(devToLookup); - /* apply scalar if its available */ - if(scalar > 0) - retval = (double)(nativeVel) / (scalar*kMinutesPer100msUnit); - return retval; + double retval = (double)nativeVel; + /* retrieve scaling info */ + double scalar = GetNativeUnitsPerRotationScalar(devToLookup); + /* apply scalar if its available */ + if(scalar > 0) + retval = (double)(nativeVel) / (scalar*kMinutesPer100msUnit); + return retval; } - /** * Enables Talon SRX to automatically zero the Sensor Position whenever an - * edge is detected on the index signal. - * @param enable boolean input, pass true to enable feature or false to disable. - * @param risingEdge boolean input, pass true to clear the position on rising edge, - * pass false to clear the position on falling edge. + * edge is detected on the index signal. + * @param enable boolean input, pass true to enable feature or false to disable. + * @param risingEdge boolean input, pass true to clear the position on rising edge, + * pass false to clear the position on falling edge. */ public void enableZeroSensorPositionOnIndex(boolean enable, boolean risingEdge) { if(enable){ - /* enable the feature, update the edge polarity first to ensure - it is correct before the feature is enabled. */ - setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0); - setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,1); - }else{ - /* disable the feature first, then update the edge polarity. */ - setParameter(CanTalonSRX.param_t.eClearPositionOnIdx,0); - setParameter(CanTalonSRX.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0); - } + /* enable the feature, update the edge polarity first to ensure + it is correct before the feature is enabled. */ + setParameter(CanTalonJNI.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0); + setParameter(CanTalonJNI.param_t.eClearPositionOnIdx,1); + }else{ + /* disable the feature first, then update the edge polarity. */ + setParameter(CanTalonJNI.param_t.eClearPositionOnIdx,0); + setParameter(CanTalonJNI.param_t.eQuadIdxPolarity,risingEdge ? 1 : 0); + } + } + /** + * Calling application can opt to speed up the handshaking between the robot API and the Talon to increase the + * download rate of the Talon's Motion Profile. Ideally the period should be no more than half the period + * of a trajectory point. + */ + public void changeMotionControlFramePeriod(int periodMs) { + CanTalonJNI.ChangeMotionControlFramePeriod(m_handle, periodMs); + } + + /** + * Clear the buffered motion profile in both Talon RAM (bottom), and in the API (top). + * Be sure to check getMotionProfileStatus() to know when the buffer is actually cleared. + */ + public void clearMotionProfileTrajectories() { + CanTalonJNI.ClearMotionProfileTrajectories(m_handle); + } + /** + * Retrieve just the buffer count for the api-level (top) buffer. + * This routine performs no CAN or data structure lookups, so its fast and ideal + * if caller needs to quickly poll the progress of trajectory points being emptied + * into Talon's RAM. Otherwise just use GetMotionProfileStatus. + * @return number of trajectory points in the top buffer. + */ + public int getMotionProfileTopLevelBufferCount() { + return CanTalonJNI.GetMotionProfileTopLevelBufferCount(m_handle); + } + /** + * Push another trajectory point into the top level buffer (which is emptied into + * the Talon's bottom buffer as room allows). + * @param targPos servo position in native Talon units (sensor units). + * @param targVel velocity to feed-forward in native Talon units (sensor units per 100ms). + * @param profileSlotSelect which slot to pull PIDF gains from. Currently supports 0 or 1. + * @param timeDurMs time in milliseconds of how long to apply this point. + * @param velOnly set to nonzero to signal Talon that only the feed-foward velocity should be + * used, i.e. do not perform PID on position. This is equivalent to setting + * PID gains to zero, but much more efficient and synchronized to MP. + * @param isLastPoint set to nonzero to signal Talon to keep processing this trajectory point, + * instead of jumping to the next one when timeDurMs expires. Otherwise + * MP executer will eventuall see an empty buffer after the last point expires, + * causing it to assert the IsUnderRun flag. However this may be desired + * if calling application nevers wants to terminate the MP. + * @param zeroPos set to nonzero to signal Talon to "zero" the selected position sensor before executing + * this trajectory point. Typically the first point should have this set only thus allowing + * the remainder of the MP positions to be relative to zero. + * @return CTR_OKAY if trajectory point push ok. CTR_BufferFull if buffer is full due to kMotionProfileTopBufferCapacity. + */ + public boolean pushMotionProfileTrajectory(TrajectoryPoint trajPt) { + /* check if there is room */ + if(isMotionProfileTopLevelBufferFull()) + return false; + /* convert position and velocity to native units */ + int targPos = ScaleRotationsToNativeUnits(m_feedbackDevice, trajPt.position); + int targVel = ScaleVelocityToNativeUnits(m_feedbackDevice, trajPt.velocity); + /* bounds check signals that require it */ + int profileSlotSelect = (trajPt.profileSlotSelect > 0) ? 1 : 0; + int timeDurMs = trajPt.timeDurMs; + /* cap time to [0ms, 255ms], 0 and 1 are both interpreted as 1ms. */ + if(timeDurMs > 255) + timeDurMs = 255; + if(timeDurMs < 0) + timeDurMs = 0; + /* send it to the top level buffer */ + CanTalonJNI.PushMotionProfileTrajectory(m_handle, targPos, targVel, profileSlotSelect, timeDurMs, trajPt.velocityOnly ? 1 : 0, trajPt.isLastPoint ? 1 : 0, trajPt.zeroPos ? 1 : 0); + return true; + } + /** + * @return true if api-level (top) buffer is full. + */ + public boolean isMotionProfileTopLevelBufferFull() { + return CanTalonJNI.IsMotionProfileTopLevelBufferFull(m_handle); + } + /** + * This must be called periodically to funnel the trajectory points from the API's top level buffer to + * the Talon's bottom level buffer. Recommendation is to call this twice as fast as the executation rate of the motion profile. + * So if MP is running with 20ms trajectory points, try calling this routine every 10ms. All motion profile functions are thread-safe + * through the use of a mutex, so there is no harm in having the caller utilize threading. + */ + public void processMotionProfileBuffer() { + CanTalonJNI.ProcessMotionProfileBuffer(m_handle); + } + /** + * Retrieve all Motion Profile status information. + * Since this all comes from one CAN frame, its ideal to have one routine to retrieve the frame once and decode everything. + * @param [out] motionProfileStatus contains all progress information on the currently running MP. Caller should + * must instantiate the motionProfileStatus object first then pass into this routine to be filled. + */ + public void getMotionProfileStatus(MotionProfileStatus motionProfileStatus) { + CanTalonJNI.GetMotionProfileStatus(m_handle, this, motionProfileStatus); + } + + /** + * Internal method to set the contents. + */ + protected void setMotionProfileStatusFromJNI(MotionProfileStatus motionProfileStatus, int flags, int profileSlotSelect, int targPos, int targVel, int topBufferRem, int topBufferCnt, int btmBufferCnt, int outputEnable) { + motionProfileStatus.topBufferRem = topBufferRem; + motionProfileStatus.topBufferCnt = topBufferCnt; + motionProfileStatus.btmBufferCnt = btmBufferCnt; + motionProfileStatus.hasUnderrun = ((flags & CanTalonJNI.kMotionProfileFlag_HasUnderrun)>0) ? true :false; + motionProfileStatus.isUnderrun = ((flags & CanTalonJNI.kMotionProfileFlag_IsUnderrun)>0) ? true :false; + motionProfileStatus.activePointValid = ((flags & CanTalonJNI.kMotionProfileFlag_ActTraj_IsValid)>0) ? true :false; + motionProfileStatus.activePoint.isLastPoint = ((flags & CanTalonJNI.kMotionProfileFlag_ActTraj_IsLast)>0) ? true :false; + motionProfileStatus.activePoint.velocityOnly = ((flags & CanTalonJNI.kMotionProfileFlag_ActTraj_VelOnly)>0) ? true :false; + motionProfileStatus.activePoint.position = ScaleNativeUnitsToRotations(m_feedbackDevice, targPos); + motionProfileStatus.activePoint.velocity = ScaleNativeUnitsToRpm(m_feedbackDevice, targVel); + motionProfileStatus.activePoint.profileSlotSelect = profileSlotSelect; + motionProfileStatus.outputEnable = SetValueMotionProfile.valueOf(outputEnable); + motionProfileStatus.activePoint.zeroPos = false; // this signal is only used sending pts to Talon + motionProfileStatus.activePoint.timeDurMs = 0; // this signal is only used sending pts to Talon + } + + /** + * Clear the hasUnderrun flag in Talon's Motion Profile Executer when MPE is ready for another point, + * but the low level buffer is empty. + * + * Once the Motion Profile Executer sets the hasUnderrun flag, it stays set until + * Robot Application clears it with this routine, which ensures Robot Application + * gets a chance to instrument or react. Caller could also check the isUnderrun flag + * which automatically clears when fault condition is removed. + */ + public void clearMotionProfileHasUnderrun() { + setParameter(CanTalonJNI.param_t.eMotionProfileHasUnderrunErr, 0); } @Override public void setExpiration(double timeout) { diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CanTalonSRX.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CanTalonSRX.java deleted file mode 100644 index 078d0d17f9..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CanTalonSRX.java +++ /dev/null @@ -1,745 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class CanTalonSRX extends CtreCanNode { - private long swigCPtr; - - protected CanTalonSRX(long cPtr, boolean cMemoryOwn) { - super(CanTalonJNI.CanTalonSRX_SWIGUpcast(cPtr), cMemoryOwn); - swigCPtr = cPtr; - } - - protected static long getCPtr(CanTalonSRX obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - CanTalonJNI.delete_CanTalonSRX(swigCPtr); - } - swigCPtr = 0; - } - super.delete(); - } - - public CanTalonSRX(int deviceNumber, int controlPeriodMs) { - this(CanTalonJNI.new_CanTalonSRX__SWIG_0(deviceNumber, controlPeriodMs), true); - } - - public CanTalonSRX(int deviceNumber) { - this(CanTalonJNI.new_CanTalonSRX__SWIG_1(deviceNumber), true); - } - - public CanTalonSRX() { - this(CanTalonJNI.new_CanTalonSRX__SWIG_2(), true); - } - - public void Set(double value) { - CanTalonJNI.CanTalonSRX_Set(swigCPtr, this, value); - } - - public SWIGTYPE_p_CTR_Code SetParam(CanTalonSRX.param_t paramEnum, double value) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetParam(swigCPtr, this, - paramEnum.swigValue(), value), true); - } - - public SWIGTYPE_p_CTR_Code RequestParam(CanTalonSRX.param_t paramEnum) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_RequestParam(swigCPtr, this, - paramEnum.swigValue()), true); - } - - public SWIGTYPE_p_CTR_Code GetParamResponse(CanTalonSRX.param_t paramEnum, SWIGTYPE_p_double value) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetParamResponse(swigCPtr, this, - paramEnum.swigValue(), SWIGTYPE_p_double.getCPtr(value)), true); - } - - public SWIGTYPE_p_CTR_Code GetParamResponseInt32(CanTalonSRX.param_t paramEnum, - SWIGTYPE_p_int value) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetParamResponseInt32(swigCPtr, this, - paramEnum.swigValue(), SWIGTYPE_p_int.getCPtr(value)), true); - } - - public SWIGTYPE_p_CTR_Code SetPgain(long slotIdx, double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetPgain(swigCPtr, this, slotIdx, gain), - true); - } - - public SWIGTYPE_p_CTR_Code SetIgain(long slotIdx, double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetIgain(swigCPtr, this, slotIdx, gain), - true); - } - - public SWIGTYPE_p_CTR_Code SetDgain(long slotIdx, double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetDgain(swigCPtr, this, slotIdx, gain), - true); - } - - public SWIGTYPE_p_CTR_Code SetFgain(long slotIdx, double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetFgain(swigCPtr, this, slotIdx, gain), - true); - } - - public SWIGTYPE_p_CTR_Code SetIzone(long slotIdx, int zone) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetIzone(swigCPtr, this, slotIdx, zone), - true); - } - - public SWIGTYPE_p_CTR_Code SetCloseLoopRampRate(long slotIdx, int closeLoopRampRate) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetCloseLoopRampRate(swigCPtr, this, - slotIdx, closeLoopRampRate), true); - } - - public SWIGTYPE_p_CTR_Code SetVoltageCompensationRate(double vpers) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetVoltageCompensationRate(swigCPtr, this,vpers), true); - } - - public SWIGTYPE_p_CTR_Code SetSensorPosition(int pos) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetSensorPosition(swigCPtr, this, pos),true); - } - - public SWIGTYPE_p_CTR_Code SetForwardSoftLimit(int forwardLimit) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetForwardSoftLimit(swigCPtr, this, - forwardLimit), true); - } - - public SWIGTYPE_p_CTR_Code SetReverseSoftLimit(int reverseLimit) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetReverseSoftLimit(swigCPtr, this, - reverseLimit), true); - } - - public SWIGTYPE_p_CTR_Code SetForwardSoftEnable(int enable) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetForwardSoftEnable(swigCPtr, this, - enable), true); - } - - public SWIGTYPE_p_CTR_Code SetReverseSoftEnable(int enable) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetReverseSoftEnable(swigCPtr, this, - enable), true); - } - - public SWIGTYPE_p_CTR_Code GetPgain(long slotIdx, SWIGTYPE_p_double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetPgain(swigCPtr, this, slotIdx, - SWIGTYPE_p_double.getCPtr(gain)), true); - } - - public SWIGTYPE_p_CTR_Code GetIgain(long slotIdx, SWIGTYPE_p_double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetIgain(swigCPtr, this, slotIdx, - SWIGTYPE_p_double.getCPtr(gain)), true); - } - - public SWIGTYPE_p_CTR_Code GetDgain(long slotIdx, SWIGTYPE_p_double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetDgain(swigCPtr, this, slotIdx, - SWIGTYPE_p_double.getCPtr(gain)), true); - } - - public SWIGTYPE_p_CTR_Code GetFgain(long slotIdx, SWIGTYPE_p_double gain) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFgain(swigCPtr, this, slotIdx, - SWIGTYPE_p_double.getCPtr(gain)), true); - } - - public SWIGTYPE_p_CTR_Code GetIzone(long slotIdx, SWIGTYPE_p_int zone) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetIzone(swigCPtr, this, slotIdx, - SWIGTYPE_p_int.getCPtr(zone)), true); - } - - public SWIGTYPE_p_CTR_Code GetCloseLoopRampRate(long slotIdx, SWIGTYPE_p_int closeLoopRampRate) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetCloseLoopRampRate(swigCPtr, this, - slotIdx, SWIGTYPE_p_int.getCPtr(closeLoopRampRate)), true); - } - - public SWIGTYPE_p_CTR_Code GetVoltageCompensationRate(SWIGTYPE_p_double vpers) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetVoltageCompensationRate(swigCPtr, this, - SWIGTYPE_p_double.getCPtr(vpers)), true); - } - - public SWIGTYPE_p_CTR_Code GetForwardSoftLimit(SWIGTYPE_p_int forwardLimit) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetForwardSoftLimit(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(forwardLimit)), true); - } - - public SWIGTYPE_p_CTR_Code GetReverseSoftLimit(SWIGTYPE_p_int reverseLimit) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetReverseSoftLimit(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(reverseLimit)), true); - } - - public SWIGTYPE_p_CTR_Code GetForwardSoftEnable(SWIGTYPE_p_int enable) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetForwardSoftEnable(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(enable)), true); - } - - public SWIGTYPE_p_CTR_Code GetReverseSoftEnable(SWIGTYPE_p_int enable) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetReverseSoftEnable(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(enable)), true); - } - - public SWIGTYPE_p_CTR_Code SetStatusFrameRate(long frameEnum, long periodMs) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetStatusFrameRate(swigCPtr, this, - frameEnum, periodMs), true); - } - - public SWIGTYPE_p_CTR_Code ClearStickyFaults() { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_ClearStickyFaults(swigCPtr, this), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_OverTemp(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_OverTemp(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_UnderVoltage(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_UnderVoltage(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_ForLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_ForLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_RevLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_RevLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_HardwareFailure(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_HardwareFailure(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_ForSoftLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_ForSoftLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFault_RevSoftLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFault_RevSoftLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_OverTemp(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_OverTemp(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_UnderVoltage(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_UnderVoltage(swigCPtr, - this, SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_ForLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_ForLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_RevLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_RevLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_ForSoftLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_ForSoftLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetStckyFault_RevSoftLim(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetStckyFault_RevSoftLim(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetAppliedThrottle(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetAppliedThrottle(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetCloseLoopErr(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetCloseLoopErr(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFeedbackDeviceSelect(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFeedbackDeviceSelect(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetModeSelect(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetModeSelect(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetLimitSwitchEn(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetLimitSwitchEn(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetLimitSwitchClosedFor(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetLimitSwitchClosedFor(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetLimitSwitchClosedRev(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetLimitSwitchClosedRev(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetSensorPosition(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetSensorPosition(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetSensorVelocity(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetSensorVelocity(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetCurrent(SWIGTYPE_p_double param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetCurrent(swigCPtr, this, - SWIGTYPE_p_double.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetBrakeIsEnabled(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetBrakeIsEnabled(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetEncPosition(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetEncPosition(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetEncVel(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetEncVel(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetEncIndexRiseEvents(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetEncIndexRiseEvents(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetQuadApin(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetQuadApin(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetQuadBpin(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetQuadBpin(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetQuadIdxpin(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetQuadIdxpin(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetAnalogInWithOv(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetAnalogInWithOv(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetAnalogInVel(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetAnalogInVel(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetTemp(SWIGTYPE_p_double param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetTemp(swigCPtr, this, - SWIGTYPE_p_double.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetBatteryV(SWIGTYPE_p_double param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetBatteryV(swigCPtr, this, - SWIGTYPE_p_double.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetResetCount(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetResetCount(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetResetFlags(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetResetFlags(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code GetFirmVers(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetFirmVers(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public SWIGTYPE_p_CTR_Code SetDemand(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetDemand(swigCPtr, this, param), true); - } - - public SWIGTYPE_p_CTR_Code SetOverrideLimitSwitchEn(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetOverrideLimitSwitchEn(swigCPtr, this, - param), true); - } - - public SWIGTYPE_p_CTR_Code SetFeedbackDeviceSelect(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetFeedbackDeviceSelect(swigCPtr, this, - param), true); - } - - public SWIGTYPE_p_CTR_Code SetRevMotDuringCloseLoopEn(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetRevMotDuringCloseLoopEn(swigCPtr, - this, param), true); - } - - public SWIGTYPE_p_CTR_Code SetOverrideBrakeType(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetOverrideBrakeType(swigCPtr, this, - param), true); - } - - public SWIGTYPE_p_CTR_Code SetModeSelect(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetModeSelect(swigCPtr, this, param), - true); - } - - public SWIGTYPE_p_CTR_Code SetProfileSlotSelect(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetProfileSlotSelect(swigCPtr, this, - param), true); - } - - public SWIGTYPE_p_CTR_Code SetRampThrottle(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetRampThrottle(swigCPtr, this, param), - true); - } - - public SWIGTYPE_p_CTR_Code SetRevFeedbackSensor(int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_SetRevFeedbackSensor(swigCPtr, this, - param), true); - } - - public SWIGTYPE_p_CTR_Code GetPulseWidthPosition(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetPulseWidthPosition(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - public SWIGTYPE_p_CTR_Code GetPulseWidthVelocity(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetPulseWidthVelocity(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - public SWIGTYPE_p_CTR_Code GetPulseWidthRiseToFallUs(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetPulseWidthRiseToFallUs(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - public SWIGTYPE_p_CTR_Code GetPulseWidthRiseToRiseUs(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_GetPulseWidthRiseToRiseUs(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - public SWIGTYPE_p_CTR_Code IsPulseWidthSensorPresent(SWIGTYPE_p_int param) { - return new SWIGTYPE_p_CTR_Code(CanTalonJNI.CanTalonSRX_IsPulseWidthSensorPresent(swigCPtr, this, - SWIGTYPE_p_int.getCPtr(param)), true); - } - - public final static int kDefaultControlPeriodMs = CanTalonJNI - .CanTalonSRX_kDefaultControlPeriodMs_get(); - public final static int kMode_DutyCycle = CanTalonJNI.CanTalonSRX_kMode_DutyCycle_get(); - public final static int kMode_PositionCloseLoop = CanTalonJNI - .CanTalonSRX_kMode_PositionCloseLoop_get(); - public final static int kMode_VelocityCloseLoop = CanTalonJNI - .CanTalonSRX_kMode_VelocityCloseLoop_get(); - public final static int kMode_CurrentCloseLoop = CanTalonJNI - .CanTalonSRX_kMode_CurrentCloseLoop_get(); - public final static int kMode_VoltCompen = CanTalonJNI.CanTalonSRX_kMode_VoltCompen_get(); - public final static int kMode_SlaveFollower = CanTalonJNI.CanTalonSRX_kMode_SlaveFollower_get(); - public final static int kMode_NoDrive = CanTalonJNI.CanTalonSRX_kMode_NoDrive_get(); - public final static int kLimitSwitchOverride_UseDefaultsFromFlash = CanTalonJNI - .CanTalonSRX_kLimitSwitchOverride_UseDefaultsFromFlash_get(); - public final static int kLimitSwitchOverride_DisableFwd_DisableRev = CanTalonJNI - .CanTalonSRX_kLimitSwitchOverride_DisableFwd_DisableRev_get(); - public final static int kLimitSwitchOverride_DisableFwd_EnableRev = CanTalonJNI - .CanTalonSRX_kLimitSwitchOverride_DisableFwd_EnableRev_get(); - public final static int kLimitSwitchOverride_EnableFwd_DisableRev = CanTalonJNI - .CanTalonSRX_kLimitSwitchOverride_EnableFwd_DisableRev_get(); - public final static int kLimitSwitchOverride_EnableFwd_EnableRev = CanTalonJNI - .CanTalonSRX_kLimitSwitchOverride_EnableFwd_EnableRev_get(); - public final static int kBrakeOverride_UseDefaultsFromFlash = CanTalonJNI - .CanTalonSRX_kBrakeOverride_UseDefaultsFromFlash_get(); - public final static int kBrakeOverride_OverrideCoast = CanTalonJNI - .CanTalonSRX_kBrakeOverride_OverrideCoast_get(); - public final static int kBrakeOverride_OverrideBrake = CanTalonJNI - .CanTalonSRX_kBrakeOverride_OverrideBrake_get(); - public final static int kFeedbackDev_DigitalQuadEnc = CanTalonJNI - .CanTalonSRX_kFeedbackDev_DigitalQuadEnc_get(); - public final static int kFeedbackDev_AnalogPot = CanTalonJNI - .CanTalonSRX_kFeedbackDev_AnalogPot_get(); - public final static int kFeedbackDev_AnalogEncoder = CanTalonJNI - .CanTalonSRX_kFeedbackDev_AnalogEncoder_get(); - public final static int kFeedbackDev_CountEveryRisingEdge = CanTalonJNI - .CanTalonSRX_kFeedbackDev_CountEveryRisingEdge_get(); - public final static int kFeedbackDev_CountEveryFallingEdge = CanTalonJNI - .CanTalonSRX_kFeedbackDev_CountEveryFallingEdge_get(); - public final static int kFeedbackDev_PosIsPulseWidth = CanTalonJNI - .CanTalonSRX_kFeedbackDev_PosIsPulseWidth_get(); - public final static int kProfileSlotSelect_Slot0 = CanTalonJNI - .CanTalonSRX_kProfileSlotSelect_Slot0_get(); - public final static int kProfileSlotSelect_Slot1 = CanTalonJNI - .CanTalonSRX_kProfileSlotSelect_Slot1_get(); - public final static int kStatusFrame_General = CanTalonJNI.CanTalonSRX_kStatusFrame_General_get(); - public final static int kStatusFrame_Feedback = CanTalonJNI - .CanTalonSRX_kStatusFrame_Feedback_get(); - public final static int kStatusFrame_Encoder = CanTalonJNI.CanTalonSRX_kStatusFrame_Encoder_get(); - public final static int kStatusFrame_AnalogTempVbat = CanTalonJNI - .CanTalonSRX_kStatusFrame_AnalogTempVbat_get(); - public final static int kStatusFrame_PulseWidthMeas = CanTalonJNI - .CanTalonSRX_kStatusFrame_PulseWidthMeas_get(); - - public final static class param_t { - public final static CanTalonSRX.param_t eProfileParamSlot0_P = new CanTalonSRX.param_t( - "eProfileParamSlot0_P", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_P_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_I = new CanTalonSRX.param_t( - "eProfileParamSlot0_I", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_I_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_D = new CanTalonSRX.param_t( - "eProfileParamSlot0_D", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_D_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_F = new CanTalonSRX.param_t( - "eProfileParamSlot0_F", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_F_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_IZone = new CanTalonSRX.param_t( - "eProfileParamSlot0_IZone", CanTalonJNI.CanTalonSRX_eProfileParamSlot0_IZone_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_CloseLoopRampRate = - new CanTalonSRX.param_t("eProfileParamSlot0_CloseLoopRampRate", - CanTalonJNI.CanTalonSRX_eProfileParamSlot0_CloseLoopRampRate_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_P = new CanTalonSRX.param_t( - "eProfileParamSlot1_P", CanTalonJNI.CanTalonSRX_eProfileParamSlot1_P_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_I = new CanTalonSRX.param_t( - "eProfileParamSlot1_I", CanTalonJNI.CanTalonSRX_eProfileParamSlot1_I_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_D = new CanTalonSRX.param_t( - "eProfileParamSlot1_D", CanTalonJNI.CanTalonSRX_eProfileParamSlot1_D_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_F = new CanTalonSRX.param_t( - "eProfileParamSlot1_F", CanTalonJNI.CanTalonSRX_eProfileParamSlot1_F_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_IZone = new CanTalonSRX.param_t( - "eProfileParamSlot1_IZone", CanTalonJNI.CanTalonSRX_eProfileParamSlot1_IZone_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_CloseLoopRampRate = - new CanTalonSRX.param_t("eProfileParamSlot1_CloseLoopRampRate", - CanTalonJNI.CanTalonSRX_eProfileParamSlot1_CloseLoopRampRate_get()); - public final static CanTalonSRX.param_t eProfileParamSoftLimitForThreshold = - new CanTalonSRX.param_t("eProfileParamSoftLimitForThreshold", - CanTalonJNI.CanTalonSRX_eProfileParamSoftLimitForThreshold_get()); - public final static CanTalonSRX.param_t eProfileParamSoftLimitRevThreshold = - new CanTalonSRX.param_t("eProfileParamSoftLimitRevThreshold", - CanTalonJNI.CanTalonSRX_eProfileParamSoftLimitRevThreshold_get()); - public final static CanTalonSRX.param_t eProfileParamSoftLimitForEnable = - new CanTalonSRX.param_t("eProfileParamSoftLimitForEnable", - CanTalonJNI.CanTalonSRX_eProfileParamSoftLimitForEnable_get()); - public final static CanTalonSRX.param_t eProfileParamSoftLimitRevEnable = - new CanTalonSRX.param_t("eProfileParamSoftLimitRevEnable", - CanTalonJNI.CanTalonSRX_eProfileParamSoftLimitRevEnable_get()); - public final static CanTalonSRX.param_t eOnBoot_BrakeMode = new CanTalonSRX.param_t( - "eOnBoot_BrakeMode", CanTalonJNI.CanTalonSRX_eOnBoot_BrakeMode_get()); - public final static CanTalonSRX.param_t eOnBoot_LimitSwitch_Forward_NormallyClosed = - new CanTalonSRX.param_t("eOnBoot_LimitSwitch_Forward_NormallyClosed", - CanTalonJNI.CanTalonSRX_eOnBoot_LimitSwitch_Forward_NormallyClosed_get()); - public final static CanTalonSRX.param_t eOnBoot_LimitSwitch_Reverse_NormallyClosed = - new CanTalonSRX.param_t("eOnBoot_LimitSwitch_Reverse_NormallyClosed", - CanTalonJNI.CanTalonSRX_eOnBoot_LimitSwitch_Reverse_NormallyClosed_get()); - public final static CanTalonSRX.param_t eOnBoot_LimitSwitch_Forward_Disable = - new CanTalonSRX.param_t("eOnBoot_LimitSwitch_Forward_Disable", - CanTalonJNI.CanTalonSRX_eOnBoot_LimitSwitch_Forward_Disable_get()); - public final static CanTalonSRX.param_t eOnBoot_LimitSwitch_Reverse_Disable = - new CanTalonSRX.param_t("eOnBoot_LimitSwitch_Reverse_Disable", - CanTalonJNI.CanTalonSRX_eOnBoot_LimitSwitch_Reverse_Disable_get()); - public final static CanTalonSRX.param_t eFault_OverTemp = new CanTalonSRX.param_t( - "eFault_OverTemp", CanTalonJNI.CanTalonSRX_eFault_OverTemp_get()); - public final static CanTalonSRX.param_t eFault_UnderVoltage = new CanTalonSRX.param_t( - "eFault_UnderVoltage", CanTalonJNI.CanTalonSRX_eFault_UnderVoltage_get()); - public final static CanTalonSRX.param_t eFault_ForLim = new CanTalonSRX.param_t( - "eFault_ForLim", CanTalonJNI.CanTalonSRX_eFault_ForLim_get()); - public final static CanTalonSRX.param_t eFault_RevLim = new CanTalonSRX.param_t( - "eFault_RevLim", CanTalonJNI.CanTalonSRX_eFault_RevLim_get()); - public final static CanTalonSRX.param_t eFault_HardwareFailure = new CanTalonSRX.param_t( - "eFault_HardwareFailure", CanTalonJNI.CanTalonSRX_eFault_HardwareFailure_get()); - public final static CanTalonSRX.param_t eFault_ForSoftLim = new CanTalonSRX.param_t( - "eFault_ForSoftLim", CanTalonJNI.CanTalonSRX_eFault_ForSoftLim_get()); - public final static CanTalonSRX.param_t eFault_RevSoftLim = new CanTalonSRX.param_t( - "eFault_RevSoftLim", CanTalonJNI.CanTalonSRX_eFault_RevSoftLim_get()); - public final static CanTalonSRX.param_t eStckyFault_OverTemp = new CanTalonSRX.param_t( - "eStckyFault_OverTemp", CanTalonJNI.CanTalonSRX_eStckyFault_OverTemp_get()); - public final static CanTalonSRX.param_t eStckyFault_UnderVoltage = new CanTalonSRX.param_t( - "eStckyFault_UnderVoltage", CanTalonJNI.CanTalonSRX_eStckyFault_UnderVoltage_get()); - public final static CanTalonSRX.param_t eStckyFault_ForLim = new CanTalonSRX.param_t( - "eStckyFault_ForLim", CanTalonJNI.CanTalonSRX_eStckyFault_ForLim_get()); - public final static CanTalonSRX.param_t eStckyFault_RevLim = new CanTalonSRX.param_t( - "eStckyFault_RevLim", CanTalonJNI.CanTalonSRX_eStckyFault_RevLim_get()); - public final static CanTalonSRX.param_t eStckyFault_ForSoftLim = new CanTalonSRX.param_t( - "eStckyFault_ForSoftLim", CanTalonJNI.CanTalonSRX_eStckyFault_ForSoftLim_get()); - public final static CanTalonSRX.param_t eStckyFault_RevSoftLim = new CanTalonSRX.param_t( - "eStckyFault_RevSoftLim", CanTalonJNI.CanTalonSRX_eStckyFault_RevSoftLim_get()); - public final static CanTalonSRX.param_t eAppliedThrottle = new CanTalonSRX.param_t( - "eAppliedThrottle", CanTalonJNI.CanTalonSRX_eAppliedThrottle_get()); - public final static CanTalonSRX.param_t eCloseLoopErr = new CanTalonSRX.param_t( - "eCloseLoopErr", CanTalonJNI.CanTalonSRX_eCloseLoopErr_get()); - public final static CanTalonSRX.param_t eFeedbackDeviceSelect = new CanTalonSRX.param_t( - "eFeedbackDeviceSelect", CanTalonJNI.CanTalonSRX_eFeedbackDeviceSelect_get()); - public final static CanTalonSRX.param_t eRevMotDuringCloseLoopEn = new CanTalonSRX.param_t( - "eRevMotDuringCloseLoopEn", CanTalonJNI.CanTalonSRX_eRevMotDuringCloseLoopEn_get()); - public final static CanTalonSRX.param_t eModeSelect = new CanTalonSRX.param_t("eModeSelect", - CanTalonJNI.CanTalonSRX_eModeSelect_get()); - public final static CanTalonSRX.param_t eProfileSlotSelect = new CanTalonSRX.param_t( - "eProfileSlotSelect", CanTalonJNI.CanTalonSRX_eProfileSlotSelect_get()); - public final static CanTalonSRX.param_t eRampThrottle = new CanTalonSRX.param_t( - "eRampThrottle", CanTalonJNI.CanTalonSRX_eRampThrottle_get()); - public final static CanTalonSRX.param_t eRevFeedbackSensor = new CanTalonSRX.param_t( - "eRevFeedbackSensor", CanTalonJNI.CanTalonSRX_eRevFeedbackSensor_get()); - public final static CanTalonSRX.param_t eLimitSwitchEn = new CanTalonSRX.param_t( - "eLimitSwitchEn", CanTalonJNI.CanTalonSRX_eLimitSwitchEn_get()); - public final static CanTalonSRX.param_t eLimitSwitchClosedFor = new CanTalonSRX.param_t( - "eLimitSwitchClosedFor", CanTalonJNI.CanTalonSRX_eLimitSwitchClosedFor_get()); - public final static CanTalonSRX.param_t eLimitSwitchClosedRev = new CanTalonSRX.param_t( - "eLimitSwitchClosedRev", CanTalonJNI.CanTalonSRX_eLimitSwitchClosedRev_get()); - public final static CanTalonSRX.param_t eSensorPosition = new CanTalonSRX.param_t( - "eSensorPosition", CanTalonJNI.CanTalonSRX_eSensorPosition_get()); - public final static CanTalonSRX.param_t eSensorVelocity = new CanTalonSRX.param_t( - "eSensorVelocity", CanTalonJNI.CanTalonSRX_eSensorVelocity_get()); - public final static CanTalonSRX.param_t eCurrent = new CanTalonSRX.param_t("eCurrent", - CanTalonJNI.CanTalonSRX_eCurrent_get()); - public final static CanTalonSRX.param_t eBrakeIsEnabled = new CanTalonSRX.param_t( - "eBrakeIsEnabled", CanTalonJNI.CanTalonSRX_eBrakeIsEnabled_get()); - public final static CanTalonSRX.param_t eEncPosition = new CanTalonSRX.param_t("eEncPosition", - CanTalonJNI.CanTalonSRX_eEncPosition_get()); - public final static CanTalonSRX.param_t eEncVel = new CanTalonSRX.param_t("eEncVel", - CanTalonJNI.CanTalonSRX_eEncVel_get()); - public final static CanTalonSRX.param_t eEncIndexRiseEvents = new CanTalonSRX.param_t( - "eEncIndexRiseEvents", CanTalonJNI.CanTalonSRX_eEncIndexRiseEvents_get()); - public final static CanTalonSRX.param_t eQuadApin = new CanTalonSRX.param_t("eQuadApin", - CanTalonJNI.CanTalonSRX_eQuadApin_get()); - public final static CanTalonSRX.param_t eQuadBpin = new CanTalonSRX.param_t("eQuadBpin", - CanTalonJNI.CanTalonSRX_eQuadBpin_get()); - public final static CanTalonSRX.param_t eQuadIdxpin = new CanTalonSRX.param_t("eQuadIdxpin", - CanTalonJNI.CanTalonSRX_eQuadIdxpin_get()); - public final static CanTalonSRX.param_t eAnalogInWithOv = new CanTalonSRX.param_t( - "eAnalogInWithOv", CanTalonJNI.CanTalonSRX_eAnalogInWithOv_get()); - public final static CanTalonSRX.param_t eAnalogInVel = new CanTalonSRX.param_t("eAnalogInVel", - CanTalonJNI.CanTalonSRX_eAnalogInVel_get()); - public final static CanTalonSRX.param_t eTemp = new CanTalonSRX.param_t("eTemp", - CanTalonJNI.CanTalonSRX_eTemp_get()); - public final static CanTalonSRX.param_t eBatteryV = new CanTalonSRX.param_t("eBatteryV", - CanTalonJNI.CanTalonSRX_eBatteryV_get()); - public final static CanTalonSRX.param_t eResetCount = new CanTalonSRX.param_t("eResetCount", - CanTalonJNI.CanTalonSRX_eResetCount_get()); - public final static CanTalonSRX.param_t eResetFlags = new CanTalonSRX.param_t("eResetFlags", - CanTalonJNI.CanTalonSRX_eResetFlags_get()); - public final static CanTalonSRX.param_t eFirmVers = new CanTalonSRX.param_t("eFirmVers", - CanTalonJNI.CanTalonSRX_eFirmVers_get()); - public final static CanTalonSRX.param_t eSettingsChanged = new CanTalonSRX.param_t( - "eSettingsChanged", CanTalonJNI.CanTalonSRX_eSettingsChanged_get()); - public final static CanTalonSRX.param_t eQuadFilterEn = new CanTalonSRX.param_t( - "eQuadFilterEn", CanTalonJNI.CanTalonSRX_eQuadFilterEn_get()); - public final static CanTalonSRX.param_t ePidIaccum = new CanTalonSRX.param_t("ePidIaccum", - CanTalonJNI.CanTalonSRX_ePidIaccum_get()); - - public final static CanTalonSRX.param_t eStatus1FrameRate = new CanTalonSRX.param_t("eStatus1FrameRate", - CanTalonJNI.CanTalonSRX_eStatus1FrameRate_get()); - public final static CanTalonSRX.param_t eStatus2FrameRate = new CanTalonSRX.param_t("eStatus2FrameRate", - CanTalonJNI.CanTalonSRX_eStatus2FrameRate_get()); - public final static CanTalonSRX.param_t eStatus3FrameRate = new CanTalonSRX.param_t("eStatus3FrameRate", - CanTalonJNI.CanTalonSRX_eStatus3FrameRate_get()); - public final static CanTalonSRX.param_t eStatus4FrameRate = new CanTalonSRX.param_t("eStatus4FrameRate", - CanTalonJNI.CanTalonSRX_eStatus4FrameRate_get()); - public final static CanTalonSRX.param_t eStatus6FrameRate = new CanTalonSRX.param_t("eStatus6FrameRate", - CanTalonJNI.CanTalonSRX_eStatus6FrameRate_get()); - public final static CanTalonSRX.param_t eStatus7FrameRate = new CanTalonSRX.param_t("eStatus7FrameRate", - CanTalonJNI.CanTalonSRX_eStatus7FrameRate_get()); - public final static CanTalonSRX.param_t eClearPositionOnIdx = new CanTalonSRX.param_t("eClearPositionOnIdx", - CanTalonJNI.CanTalonSRX_eClearPositionOnIdx_get()); - public final static CanTalonSRX.param_t ePeakPosOutput = new CanTalonSRX.param_t("ePeakPosOutput", - CanTalonJNI.CanTalonSRX_ePeakPosOutput_get()); - public final static CanTalonSRX.param_t eNominalPosOutput = new CanTalonSRX.param_t("eNominalPosOutput", - CanTalonJNI.CanTalonSRX_eNominalPosOutput_get()); - public final static CanTalonSRX.param_t ePeakNegOutput = new CanTalonSRX.param_t("ePeakNegOutput", - CanTalonJNI.CanTalonSRX_ePeakNegOutput_get()); - public final static CanTalonSRX.param_t eNominalNegOutput = new CanTalonSRX.param_t("eNominalNegOutput", - CanTalonJNI.CanTalonSRX_eNominalNegOutput_get()); - public final static CanTalonSRX.param_t eQuadIdxPolarity = new CanTalonSRX.param_t("eQuadIdxPolarity", - CanTalonJNI.CanTalonSRX_eQuadIdxPolarity_get()); - public final static CanTalonSRX.param_t eStatus8FrameRate = new CanTalonSRX.param_t("eStatus8FrameRate", - CanTalonJNI.CanTalonSRX_eStatus8FrameRate_get()); - public final static CanTalonSRX.param_t eAllowPosOverflow = new CanTalonSRX.param_t("eAllowPosOverflow", - CanTalonJNI.CanTalonSRX_eAllowPosOverflow_get()); - public final static CanTalonSRX.param_t eProfileParamSlot0_AllowableClosedLoopErr = new CanTalonSRX.param_t("eProfileParamSlot0_AllowableClosedLoopErr", - CanTalonJNI.CanTalonSRX_eProfileParamSlot0_AllowableClosedLoopErr_get()); - public final static CanTalonSRX.param_t eNumberPotTurns = new CanTalonSRX.param_t("eNumberPotTurns", - CanTalonJNI.CanTalonSRX_eNumberPotTurns_get()); - public final static CanTalonSRX.param_t eNumberEncoderCPR = new CanTalonSRX.param_t("eNumberEncoderCPR", - CanTalonJNI.CanTalonSRX_eNumberEncoderCPR_get()); - public final static CanTalonSRX.param_t ePwdPosition = new CanTalonSRX.param_t("ePwdPosition", - CanTalonJNI.CanTalonSRX_ePwdPosition_get()); - public final static CanTalonSRX.param_t eAinPosition = new CanTalonSRX.param_t("eAinPosition", - CanTalonJNI.CanTalonSRX_eAinPosition_get()); - public final static CanTalonSRX.param_t eProfileParamVcompRate = new CanTalonSRX.param_t("eProfileParamVcompRate", - CanTalonJNI.CanTalonSRX_eProfileParamVcompRate_get()); - public final static CanTalonSRX.param_t eProfileParamSlot1_AllowableClosedLoopErr = new CanTalonSRX.param_t("eProfileParamSlot1_AllowableClosedLoopErr", - CanTalonJNI.CanTalonSRX_eProfileParamSlot1_AllowableClosedLoopErr_get()); - - public final int swigValue() { - return swigValue; - } - - public String toString() { - return swigName; - } - - public static param_t swigToEnum(int swigValue) { - if (swigValue < swigValues.length && swigValue >= 0 - && swigValues[swigValue].swigValue == swigValue) - return swigValues[swigValue]; - for (int i = 0; i < swigValues.length; i++) - if (swigValues[i].swigValue == swigValue) - return swigValues[i]; - throw new IllegalArgumentException("No enum " + param_t.class + " with value " + swigValue); - } - - private param_t(String swigName) { - this.swigName = swigName; - this.swigValue = swigNext++; - } - - private param_t(String swigName, int swigValue) { - this.swigName = swigName; - this.swigValue = swigValue; - swigNext = swigValue + 1; - } - - private param_t(String swigName, param_t swigEnum) { - this.swigName = swigName; - this.swigValue = swigEnum.swigValue; - swigNext = this.swigValue + 1; - } - - private static param_t[] swigValues = {eProfileParamSlot0_P, eProfileParamSlot0_I, - eProfileParamSlot0_D, eProfileParamSlot0_F, eProfileParamSlot0_IZone, - eProfileParamSlot0_CloseLoopRampRate, eProfileParamSlot1_P, eProfileParamSlot1_I, - eProfileParamSlot1_D, eProfileParamSlot1_F, eProfileParamSlot1_IZone, - eProfileParamSlot1_CloseLoopRampRate, eProfileParamSoftLimitForThreshold, - eProfileParamSoftLimitRevThreshold, eProfileParamSoftLimitForEnable, - eProfileParamSoftLimitRevEnable, eOnBoot_BrakeMode, - eOnBoot_LimitSwitch_Forward_NormallyClosed, eOnBoot_LimitSwitch_Reverse_NormallyClosed, - eOnBoot_LimitSwitch_Forward_Disable, eOnBoot_LimitSwitch_Reverse_Disable, eFault_OverTemp, - eFault_UnderVoltage, eFault_ForLim, eFault_RevLim, eFault_HardwareFailure, - eFault_ForSoftLim, eFault_RevSoftLim, eStckyFault_OverTemp, eStckyFault_UnderVoltage, - eStckyFault_ForLim, eStckyFault_RevLim, eStckyFault_ForSoftLim, eStckyFault_RevSoftLim, - eAppliedThrottle, eCloseLoopErr, eFeedbackDeviceSelect, eRevMotDuringCloseLoopEn, - eModeSelect, eProfileSlotSelect, eRampThrottle, eRevFeedbackSensor, eLimitSwitchEn, - eLimitSwitchClosedFor, eLimitSwitchClosedRev, eSensorPosition, eSensorVelocity, eCurrent, - eBrakeIsEnabled, eEncPosition, eEncVel, eEncIndexRiseEvents, eQuadApin, eQuadBpin, - eQuadIdxpin, eAnalogInWithOv, eAnalogInVel, eTemp, eBatteryV, eResetCount, eResetFlags, - eFirmVers, eSettingsChanged, eQuadFilterEn, ePidIaccum}; - private static int swigNext = 0; - private final int swigValue; - private final String swigName; - } - -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CtreCanNode.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CtreCanNode.java deleted file mode 100644 index 421f96a826..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/CtreCanNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class CtreCanNode { - private long swigCPtr; - protected boolean swigCMemOwn; - - protected CtreCanNode(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(CtreCanNode obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - CanTalonJNI.delete_CtreCanNode(swigCPtr); - } - swigCPtr = 0; - } - } - - public CtreCanNode(SWIGTYPE_p_UINT8 deviceNumber) { - this(CanTalonJNI.new_CtreCanNode(SWIGTYPE_p_UINT8.getCPtr(deviceNumber)), true); - } - - public SWIGTYPE_p_UINT8 GetDeviceNumber() { - return new SWIGTYPE_p_UINT8(CanTalonJNI.CtreCanNode_GetDeviceNumber(swigCPtr, this), true); - } - -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_CTR_Code.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_CTR_Code.java deleted file mode 100644 index 70711b851c..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_CTR_Code.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_CTR_Code { - private long swigCPtr; - - public SWIGTYPE_p_CTR_Code(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_CTR_Code() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_CTR_Code obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_UINT8.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_UINT8.java deleted file mode 100644 index 901c94246d..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_UINT8.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_UINT8 { - private long swigCPtr; - - public SWIGTYPE_p_UINT8(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_UINT8() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_UINT8 obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_double.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_double.java deleted file mode 100644 index 1e73770369..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_double.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_double { - private long swigCPtr; - - public SWIGTYPE_p_double(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_double() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_double obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_float.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_float.java deleted file mode 100644 index 9ab264667f..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_float.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_float { - private long swigCPtr; - - public SWIGTYPE_p_float(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_float() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_float obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int.java deleted file mode 100644 index 58f0cdee6c..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_int { - private long swigCPtr; - - public SWIGTYPE_p_int(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_int() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_int obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int32_t.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int32_t.java deleted file mode 100644 index a34855f336..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_int32_t.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_int32_t { - private long swigCPtr; - - public SWIGTYPE_p_int32_t(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_int32_t() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_int32_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint32_t.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint32_t.java deleted file mode 100644 index dc1718486a..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint32_t.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_uint32_t { - private long swigCPtr; - - public SWIGTYPE_p_uint32_t(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_uint32_t() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_uint32_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint8_t.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint8_t.java deleted file mode 100644 index 9ed0e324b2..0000000000 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SWIGTYPE_p_uint8_t.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - -package edu.wpi.first.wpilibj.hal; - -public class SWIGTYPE_p_uint8_t { - private long swigCPtr; - - public SWIGTYPE_p_uint8_t(long cPtr, boolean futureUse) { - swigCPtr = cPtr; - } - - public SWIGTYPE_p_uint8_t() { - swigCPtr = 0; - } - - public static long getCPtr(SWIGTYPE_p_uint8_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CanTalonJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CanTalonJNI.java index b194cf6579..a02dcec2df 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CanTalonJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CanTalonJNI.java @@ -1,556 +1,225 @@ -/* - * ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). Version - * 2.0.11 - *$ - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- - */ - package edu.wpi.first.wpilibj.hal; -public class CanTalonJNI { - public final static native long new_doublep(); - - public final static native long copy_doublep(double jarg1); - - public final static native void delete_doublep(long jarg1); - - public final static native void doublep_assign(long jarg1, double jarg2); - - public final static native double doublep_value(long jarg1); - - public final static native long new_intp(); - - public final static native long copy_intp(int jarg1); - - public final static native void delete_intp(long jarg1); - - public final static native void intp_assign(long jarg1, int jarg2); - - public final static native int intp_value(long jarg1); - - public final static native long new_uint32_tp(); - - public final static native long copy_uint32_tp(long jarg1); - - public final static native void delete_uint32_tp(long jarg1); - - public final static native void uint32_tp_assign(long jarg1, long jarg2); - - public final static native long uint32_tp_value(long jarg1); - - public final static native long new_int32_tp(); - - public final static native long copy_int32_tp(long jarg1); - - public final static native void delete_int32_tp(long jarg1); - - public final static native void int32_tp_assign(long jarg1, long jarg2); - - public final static native long int32_tp_value(long jarg1); - - public final static native long new_uint8_tp(); - - public final static native long copy_uint8_tp(long jarg1); - - public final static native void delete_uint8_tp(long jarg1); - - public final static native void uint8_tp_assign(long jarg1, long jarg2); - - public final static native long uint8_tp_value(long jarg1); - - public final static native long new_CTR_Codep(); - - public final static native long copy_CTR_Codep(long jarg1); - - public final static native void delete_CTR_Codep(long jarg1); - - public final static native void CTR_Codep_assign(long jarg1, long jarg2); - - public final static native long CTR_Codep_value(long jarg1); - - public final static native long new_floatp(); - - public final static native long copy_floatp(float jarg1); - - public final static native void delete_floatp(long jarg1); - - public final static native void floatp_assign(long jarg1, float jarg2); - - public final static native float floatp_value(long jarg1); - - public final static native long new_CtreCanNode(long jarg1); - - public final static native void delete_CtreCanNode(long jarg1); - - public final static native long CtreCanNode_GetDeviceNumber(long jarg1, CtreCanNode jarg1_); - - public final static native int CanTalonSRX_kDefaultControlPeriodMs_get(); - - public final static native long new_CanTalonSRX__SWIG_0(int jarg1, int jarg2); - - public final static native long new_CanTalonSRX__SWIG_1(int jarg1); - - public final static native long new_CanTalonSRX__SWIG_2(); - - public final static native void delete_CanTalonSRX(long jarg1); - - public final static native void CanTalonSRX_Set(long jarg1, CanTalonSRX jarg1_, double jarg2); - - public final static native int CanTalonSRX_kMode_DutyCycle_get(); - - public final static native int CanTalonSRX_kMode_PositionCloseLoop_get(); - - public final static native int CanTalonSRX_kMode_VelocityCloseLoop_get(); - - public final static native int CanTalonSRX_kMode_CurrentCloseLoop_get(); - - public final static native int CanTalonSRX_kMode_VoltCompen_get(); - - public final static native int CanTalonSRX_kMode_SlaveFollower_get(); - - public final static native int CanTalonSRX_kMode_NoDrive_get(); - - public final static native int CanTalonSRX_kLimitSwitchOverride_UseDefaultsFromFlash_get(); - - public final static native int CanTalonSRX_kLimitSwitchOverride_DisableFwd_DisableRev_get(); - - public final static native int CanTalonSRX_kLimitSwitchOverride_DisableFwd_EnableRev_get(); - - public final static native int CanTalonSRX_kLimitSwitchOverride_EnableFwd_DisableRev_get(); - - public final static native int CanTalonSRX_kLimitSwitchOverride_EnableFwd_EnableRev_get(); - - public final static native int CanTalonSRX_kBrakeOverride_UseDefaultsFromFlash_get(); - - public final static native int CanTalonSRX_kBrakeOverride_OverrideCoast_get(); - - public final static native int CanTalonSRX_kBrakeOverride_OverrideBrake_get(); - - public final static native int CanTalonSRX_kFeedbackDev_DigitalQuadEnc_get(); - - public final static native int CanTalonSRX_kFeedbackDev_AnalogPot_get(); - - public final static native int CanTalonSRX_kFeedbackDev_AnalogEncoder_get(); - - public final static native int CanTalonSRX_kFeedbackDev_CountEveryRisingEdge_get(); - - public final static native int CanTalonSRX_kFeedbackDev_CountEveryFallingEdge_get(); - - public final static native int CanTalonSRX_kFeedbackDev_PosIsPulseWidth_get(); - - public final static native int CanTalonSRX_kProfileSlotSelect_Slot0_get(); - - public final static native int CanTalonSRX_kProfileSlotSelect_Slot1_get(); - - public final static native int CanTalonSRX_kStatusFrame_General_get(); - - public final static native int CanTalonSRX_kStatusFrame_Feedback_get(); - - public final static native int CanTalonSRX_kStatusFrame_Encoder_get(); - - public final static native int CanTalonSRX_kStatusFrame_AnalogTempVbat_get(); - - public final static native int CanTalonSRX_kStatusFrame_PulseWidthMeas_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_P_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_I_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_D_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_F_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_IZone_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_CloseLoopRampRate_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_P_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_I_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_D_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_F_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_IZone_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_CloseLoopRampRate_get(); - - public final static native int CanTalonSRX_eProfileParamSoftLimitForThreshold_get(); - - public final static native int CanTalonSRX_eProfileParamSoftLimitRevThreshold_get(); - - public final static native int CanTalonSRX_eProfileParamSoftLimitForEnable_get(); - - public final static native int CanTalonSRX_eProfileParamSoftLimitRevEnable_get(); - - public final static native int CanTalonSRX_eOnBoot_BrakeMode_get(); - - public final static native int CanTalonSRX_eOnBoot_LimitSwitch_Forward_NormallyClosed_get(); - - public final static native int CanTalonSRX_eOnBoot_LimitSwitch_Reverse_NormallyClosed_get(); - - public final static native int CanTalonSRX_eOnBoot_LimitSwitch_Forward_Disable_get(); - - public final static native int CanTalonSRX_eOnBoot_LimitSwitch_Reverse_Disable_get(); - - public final static native int CanTalonSRX_eFault_OverTemp_get(); - - public final static native int CanTalonSRX_eFault_UnderVoltage_get(); - - public final static native int CanTalonSRX_eFault_ForLim_get(); - - public final static native int CanTalonSRX_eFault_RevLim_get(); - - public final static native int CanTalonSRX_eFault_HardwareFailure_get(); - - public final static native int CanTalonSRX_eFault_ForSoftLim_get(); - - public final static native int CanTalonSRX_eFault_RevSoftLim_get(); - - public final static native int CanTalonSRX_eStckyFault_OverTemp_get(); - - public final static native int CanTalonSRX_eStckyFault_UnderVoltage_get(); - - public final static native int CanTalonSRX_eStckyFault_ForLim_get(); - - public final static native int CanTalonSRX_eStckyFault_RevLim_get(); - - public final static native int CanTalonSRX_eStckyFault_ForSoftLim_get(); - - public final static native int CanTalonSRX_eStckyFault_RevSoftLim_get(); - - public final static native int CanTalonSRX_eAppliedThrottle_get(); - - public final static native int CanTalonSRX_eCloseLoopErr_get(); - - public final static native int CanTalonSRX_eFeedbackDeviceSelect_get(); - - public final static native int CanTalonSRX_eRevMotDuringCloseLoopEn_get(); - - public final static native int CanTalonSRX_eModeSelect_get(); - - public final static native int CanTalonSRX_eProfileSlotSelect_get(); - - public final static native int CanTalonSRX_eRampThrottle_get(); - - public final static native int CanTalonSRX_eRevFeedbackSensor_get(); - - public final static native int CanTalonSRX_eLimitSwitchEn_get(); - - public final static native int CanTalonSRX_eLimitSwitchClosedFor_get(); - - public final static native int CanTalonSRX_eLimitSwitchClosedRev_get(); - - public final static native int CanTalonSRX_eSensorPosition_get(); - - public final static native int CanTalonSRX_eSensorVelocity_get(); - - public final static native int CanTalonSRX_eCurrent_get(); - - public final static native int CanTalonSRX_eBrakeIsEnabled_get(); - - public final static native int CanTalonSRX_eEncPosition_get(); - - public final static native int CanTalonSRX_eEncVel_get(); - - public final static native int CanTalonSRX_eEncIndexRiseEvents_get(); - - public final static native int CanTalonSRX_eQuadApin_get(); - - public final static native int CanTalonSRX_eQuadBpin_get(); - - public final static native int CanTalonSRX_eQuadIdxpin_get(); - - public final static native int CanTalonSRX_eAnalogInWithOv_get(); - - public final static native int CanTalonSRX_eAnalogInVel_get(); - - public final static native int CanTalonSRX_eTemp_get(); - - public final static native int CanTalonSRX_eBatteryV_get(); - - public final static native int CanTalonSRX_eResetCount_get(); - - public final static native int CanTalonSRX_eResetFlags_get(); - - public final static native int CanTalonSRX_eFirmVers_get(); - - public final static native int CanTalonSRX_eSettingsChanged_get(); - - public final static native int CanTalonSRX_eQuadFilterEn_get(); - - public final static native int CanTalonSRX_ePidIaccum_get(); - - public final static native int CanTalonSRX_eStatus1FrameRate_get(); - - public final static native int CanTalonSRX_eStatus2FrameRate_get(); - - public final static native int CanTalonSRX_eStatus3FrameRate_get(); - - public final static native int CanTalonSRX_eStatus4FrameRate_get(); - - public final static native int CanTalonSRX_eStatus6FrameRate_get(); - - public final static native int CanTalonSRX_eStatus7FrameRate_get(); - - public final static native int CanTalonSRX_eClearPositionOnIdx_get(); - - public final static native int CanTalonSRX_ePeakPosOutput_get(); - - public final static native int CanTalonSRX_eNominalPosOutput_get(); - - public final static native int CanTalonSRX_ePeakNegOutput_get(); - - public final static native int CanTalonSRX_eNominalNegOutput_get(); - - public final static native int CanTalonSRX_eQuadIdxPolarity_get(); - - public final static native int CanTalonSRX_eStatus8FrameRate_get(); - - public final static native int CanTalonSRX_eAllowPosOverflow_get(); - - public final static native int CanTalonSRX_eProfileParamSlot0_AllowableClosedLoopErr_get(); - - public final static native int CanTalonSRX_eNumberPotTurns_get(); - - public final static native int CanTalonSRX_eNumberEncoderCPR_get(); - - public final static native int CanTalonSRX_ePwdPosition_get(); - - public final static native int CanTalonSRX_eAinPosition_get(); - - public final static native int CanTalonSRX_eProfileParamVcompRate_get(); - - public final static native int CanTalonSRX_eProfileParamSlot1_AllowableClosedLoopErr_get(); - - public final static native long CanTalonSRX_SetParam(long jarg1, CanTalonSRX jarg1_, int jarg2, - double jarg3); - - public final static native long CanTalonSRX_RequestParam(long jarg1, CanTalonSRX jarg1_, int jarg2); - - public final static native long CanTalonSRX_GetParamResponse(long jarg1, CanTalonSRX jarg1_, - int jarg2, long jarg3); - - public final static native long CanTalonSRX_GetParamResponseInt32(long jarg1, CanTalonSRX jarg1_, - int jarg2, long jarg3); - - public final static native long CanTalonSRX_SetPgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - double jarg3); - - public final static native long CanTalonSRX_SetIgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - double jarg3); - - public final static native long CanTalonSRX_SetDgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - double jarg3); - - public final static native long CanTalonSRX_SetFgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - double jarg3); - - public final static native long CanTalonSRX_SetIzone(long jarg1, CanTalonSRX jarg1_, long jarg2, - int jarg3); - - public final static native long CanTalonSRX_SetCloseLoopRampRate(long jarg1, CanTalonSRX jarg1_, - long jarg2, int jarg3); - - public final static native long CanTalonSRX_SetSensorPosition(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetForwardSoftLimit(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetReverseSoftLimit(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetForwardSoftEnable(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetReverseSoftEnable(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_GetPgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - long jarg3); - - public final static native long CanTalonSRX_GetIgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - long jarg3); - - public final static native long CanTalonSRX_GetDgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - long jarg3); - - public final static native long CanTalonSRX_GetFgain(long jarg1, CanTalonSRX jarg1_, long jarg2, - long jarg3); - - public final static native long CanTalonSRX_GetIzone(long jarg1, CanTalonSRX jarg1_, long jarg2, - long jarg3); - - public final static native long CanTalonSRX_GetCloseLoopRampRate(long jarg1, CanTalonSRX jarg1_, - long jarg2, long jarg3); - - public final static native long CanTalonSRX_GetVoltageCompensationRate(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetForwardSoftLimit(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetReverseSoftLimit(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetForwardSoftEnable(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetReverseSoftEnable(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_SetStatusFrameRate(long jarg1, CanTalonSRX jarg1_, - long jarg2, long jarg3); - - public final static native long CanTalonSRX_ClearStickyFaults(long jarg1, CanTalonSRX jarg1_); - - public final static native long CanTalonSRX_GetFault_OverTemp(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFault_UnderVoltage(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFault_ForLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFault_RevLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFault_HardwareFailure(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetFault_ForSoftLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFault_RevSoftLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_OverTemp(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_UnderVoltage(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_ForLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_RevLim(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_ForSoftLim(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetStckyFault_RevSoftLim(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetAppliedThrottle(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetCloseLoopErr(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFeedbackDeviceSelect(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetModeSelect(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetLimitSwitchEn(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetLimitSwitchClosedFor(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetLimitSwitchClosedRev(long jarg1, - CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetSensorPosition(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetSensorVelocity(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetCurrent(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetBrakeIsEnabled(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetEncPosition(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetEncVel(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetEncIndexRiseEvents(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetQuadApin(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetQuadBpin(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetQuadIdxpin(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetAnalogInWithOv(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetAnalogInVel(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetTemp(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetBatteryV(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetResetCount(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetResetFlags(long jarg1, CanTalonSRX jarg1_, - long jarg2); - - public final static native long CanTalonSRX_GetFirmVers(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_SetDemand(long jarg1, CanTalonSRX jarg1_, int jarg2); - - public final static native long CanTalonSRX_SetOverrideLimitSwitchEn(long jarg1, - CanTalonSRX jarg1_, int jarg2); - - public final static native long CanTalonSRX_SetFeedbackDeviceSelect(long jarg1, - CanTalonSRX jarg1_, int jarg2); - - public final static native long CanTalonSRX_SetRevMotDuringCloseLoopEn(long jarg1, - CanTalonSRX jarg1_, int jarg2); - - public final static native long CanTalonSRX_SetOverrideBrakeType(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetModeSelect(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetProfileSlotSelect(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetRampThrottle(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_SetVoltageCompensationRate(long jarg1, CanTalonSRX jarg1_, - double jarg2); - - public final static native long CanTalonSRX_SetRevFeedbackSensor(long jarg1, CanTalonSRX jarg1_, - int jarg2); - - public final static native long CanTalonSRX_GetPulseWidthPosition(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetPulseWidthVelocity(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetPulseWidthRiseToFallUs(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_GetPulseWidthRiseToRiseUs(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_IsPulseWidthSensorPresent(long jarg1, CanTalonSRX jarg1_, long jarg2); - - public final static native long CanTalonSRX_SWIGUpcast(long jarg1); +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. + */ + 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); + + public final int value; + private 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); } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CANTalonTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CANTalonTest.java index bc14f4bbc7..4b333713e3 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CANTalonTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CANTalonTest.java @@ -18,9 +18,7 @@ import org.junit.Test; import edu.wpi.first.wpilibj.fixtures.SampleFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; -import edu.wpi.first.wpilibj.hal.CanTalonSRX; import edu.wpi.first.wpilibj.hal.CanTalonJNI; -import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_double; /** * Basic test (borrowed straight from SampleTest) for running the CAN TalonSRX. diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java index a37ccc3e15..78ca301b4f 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java @@ -18,8 +18,7 @@ import org.junit.Test; import edu.wpi.first.wpilibj.fixtures.SampleFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; -import edu.wpi.first.wpilibj.hal.CanTalonSRX; -import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_UINT8; +import edu.wpi.first.wpilibj.CANTalon; /** * Sample test for a sample PID controller. This demonstrates the general @@ -63,10 +62,10 @@ public class SampleTest extends AbstractComsSetup { */ @Test public void test() { - CanTalonSRX cantalon = new CanTalonSRX(); - cantalon.Set(0.5); + CANTalon cantalon = new CANTalon(0); + cantalon.set(0.5); Timer.delay(0.5); - cantalon.Set(0.0); + cantalon.set(0.0); assertTrue(true); }