public DifferentialControlLoopCoefficients getDifferentialControlLoopCoefficients(int motor) { m57a(motor); DifferentialControlLoopCoefficients differentialControlLoopCoefficients = new DifferentialControlLoopCoefficients(); byte[] read = read( ADDRESS_MAX_DIFFERENTIAL_CONTROL_LOOP_COEFFICIENT_MAP[motor], CHANNEL_MODE_MASK_SELECTION); differentialControlLoopCoefficients.p = (double) read[0]; differentialControlLoopCoefficients.i = (double) read[MIN_MOTOR]; differentialControlLoopCoefficients.d = (double) read[MAX_MOTOR]; return differentialControlLoopCoefficients; }
public void setDifferentialControlLoopCoefficients( int motor, DifferentialControlLoopCoefficients pid) { m57a(motor); if (pid.p > 255.0d) { pid.p = 255.0d; } if (pid.i > 255.0d) { pid.i = 255.0d; } if (pid.d > 255.0d) { pid.d = 255.0d; } int i = ADDRESS_MAX_DIFFERENTIAL_CONTROL_LOOP_COEFFICIENT_MAP[motor]; byte[] bArr = new byte[CHANNEL_MODE_MASK_SELECTION]; bArr[0] = (byte) ((int) pid.p); bArr[MIN_MOTOR] = (byte) ((int) pid.i); bArr[MAX_MOTOR] = (byte) ((int) pid.d); write(i, bArr); }