public void WriteMotorInfo(ref ArrayList talonInfoList) { //Write the motor NUC_serialPort.WriteByte(KEY0); NUC_serialPort.WriteByte(KEY1); NUC_serialPort.WriteByte(KEY2); byte[] motorInfoPacket = new byte[Constants.PacketSize[Constants.PacketType.MOTOR_INFO_OUT]]; NUC_serialPort.WriteByte(Constants.PacketType.MOTOR_INFO_OUT); int idx = 0; foreach (Object o in talonInfoList) { TalonInfo talonInfo = (TalonInfo)o; talonInfo.GetDataAsByteArray().CopyTo(motorInfoPacket, TalonInfo.NUM_BYTES * idx); idx++; } NUC_serialPort.Write(motorInfoPacket, 0, motorInfoPacket.Length); }
public TalonInfo(TalonInfo info) { this.CAN_ID = info.CAN_ID; this.currentDraw = info.currentDraw; this.encoderPosition = info.encoderPosition; this.encoderVelocity = info.encoderVelocity; this.percentOutput = info.percentOutput; }
public ArrayList GetTalonInfo() { ArrayList talonInfoList = new ArrayList(); TalonSRX t; TalonInfo info = new TalonInfo(); t = leftActuator; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); t = rightActuator; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); t = augerRotator; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); info.CAN_ID = (short)CAN_IDs.EXCAVATION.AUGER_EXTENDER; info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * augerExtender.GetDirectionAsVBUS())); info.currentDraw = -1; int encoderPos = 0; if (reverseLimitSwitch.IsPressed()) { encoderPos = -1; } else if (forwardLimitSwitch.IsPressed()) { encoderPos = 1; } info.encoderPosition = encoderPos * 100; info.encoderVelocity = info.percentOutput; talonInfoList.Add(new TalonInfo(info)); return(talonInfoList); }
public ArrayList GetTalonInfo() { ArrayList talonInfoList = new ArrayList(); TalonSRX t; TalonInfo info = new TalonInfo(); t = FrontLeft; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); t = FrontRight; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); t = BackLeft; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); t = BackRight; info.CAN_ID = (short)t.GetDeviceID(); info.percentOutput = TalonInfo.ConvertPercentOutputToByte((int)(100 * t.GetMotorOutputPercent())); info.currentDraw = TalonInfo.ConvertCurrentToShort(t.GetOutputCurrent()); info.encoderPosition = TalonInfo.ConvertEncoderPositionToShort(t.GetSelectedSensorPosition()); info.encoderVelocity = (short)t.GetSelectedSensorVelocity(); talonInfoList.Add(new TalonInfo(info)); return(talonInfoList); }