//I think this is where the magic happens and the motors move private static void processInboundData(ArrayList setpointDataList, ArrayList talons) { //For each setpointData, for the talon that matches it set each mode and setpoint based on the list information for (int i = 0; i < setpointDataList.Count; i++) { try { SetpointData setpointData = (SetpointData)setpointDataList[i]; float setpointVal = (float)(setpointData.getSetpoint()); CTRE.TalonSrx talon = (CTRE.TalonSrx)talons[i]; if (talon.GetControlMode() != setpointData.getMode()) { talon.SetControlMode(setpointData.getMode()); //Debug.Print(setpointData.getMode().ToString()); } if (talon.GetSetpoint() != setpointVal) { talon.Set(setpointVal); Debug.Print("Setting it to value = " + setpointVal.ToString()); //Debug.Print(setpointVal.ToString()); } } catch (ArgumentOutOfRangeException ex) { Debug.Print(ex.ToString()); } } }
//reads the talons and updates the data public void updateStatusData() { talonCurrent = (talon.GetOutputCurrent()); talonTemperature = (talon.GetTemperature()); talonVoltage = (talon.GetOutputVoltage()); talonSpeed = (talon.GetSpeed()); talonPosition = (talon.GetPosition()); talonSetpoint = (talon.GetSetpoint()); talonForwardLimitReached = talon.IsFwdLimitSwitchClosed() ? 1 : 0; talonReverseLimitReached = talon.IsRevLimitSwitchClosed() ? 1 : 0; controlMode = talon.GetControlMode(); }
private static void processInboundData(ArrayList setpointDataList, ArrayList talons) { for (int i = 0; i < setpointDataList.Count; i++) { SetpointData setpointData = (SetpointData)setpointDataList[i]; float setpointVal = (float)(setpointData.getSetpoint()); CTRE.TalonSrx talon = (CTRE.TalonSrx)talons[i]; if (talon.GetControlMode() != setpointData.getMode()) { talon.SetControlMode(setpointData.getMode()); Debug.Print(setpointData.getMode().ToString()); } if (talon.GetSetpoint() != setpointVal) { talon.Set(setpointVal); Debug.Print(setpointVal.ToString()); } } }