How can i have the robot arm move according to a set angle?

hello everyone. we are currently having issues with how to make our robot arm move according to angles it calculates on its own. we use 2 cim motors with relative encoders on 1 of them. we also use victor motor controllers

Use a PID controller

You tune the first parameter. Make it lower if it oscillates too much.
Make it higher if its not getting there enough.

// set the motors to the proper volts
void setMotorVolts(double v) {
  // implement however u want

// read the encoder position
double getEncoderPosition() {
  // implement however u want

// tune the parameters 
PIDController pid = new PIDController(1, 0, 0);

// make sure this method runs periodically 
// set position to the desired setpoint
void moveArmToPosition(double setpoint) {

  double encoderPosition = getEncoderPosition();
  SmartDashboard.putNumber("encoder", encoderPosition);

  double volts = pid.calculate(setpoint, encoderPosition);
  SmartDashboard.putNumber("volts", volts);


I agree with @Jus, a PIDController is the way to do it. You may also want to consider using ArmFeedForward if it’s a “arm”, meaning it pivots vertically. Arm feedforward will deal with the fact that more gravity force exists when the arm is extended, and there’s essentially no gravity force when the arm is upright.
Here is the WPILib documentation for ArmFeedForward

In our rookie years we didn’t use this, and the arm slammed into the upright position when the PID was tuned high enough to raise the arm.