We recently added shaft encoders to our robot and are able to use them. we use the shaft encoders on our drive to make turning more consistent. however, once our robot makes a turn, it does not make another. In our 15-second autonomous, we start the robot facing the stationary goal on the right red side, it then lifts up while driving forward, and then drops the preloaded cone onto the stationary goal. After doing so, the robot backs up, turns right using the encoders, drives forward, lowers the lift, and grabs another cone. This is where our issue is, once it grabs the cone, i have programmed it to turn left to face the stationary goal again using the shaft encoders but nothing happens. i am able to make it turn by directly programming the motors for a certain amount of time but it is less consistent. before the second turn i reset the encoders values including a pause. i should also mention that I’m using natural language 2.0
setDriveMotor ( 50 , 50 ) ;
setLiftMotor ( 35 ) ;
setConeMotor ( 40 ) ;
wait1Msec ( 1550 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -80 ) ;
wait1Msec ( 300 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -40 ) ;
setDriveMotor ( -50 , -50 ) ;
wait1Msec ( 700 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 300 ) ;
turnRight ( 250 , degrees , 90 ) ; ← First turn using encoders
wait1Msec ( 500 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 300 ) ;
setDriveMotor ( 30 , 30 ) ;
wait1Msec ( 200 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 200 ) ;
setSwingMotor ( -127 ) ;
setConeMotor ( 127 ) ;
setLiftMotor ( -50 ) ;
wait1Msec ( 1200 ) ;
setSwingMotor ( 0 ) ;
setConeMotor ( 60 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setSwingMotor ( 127 ) ;
setConeMotor ( 30 ) ;
wait1Msec ( 800 ) ;
setSwingMotor ( 0 ) ;
setConeMotor ( 30 ) ;
SensorValue [dgtl1] = 0;
SensorValue [dgtl3] = 0; ← In the debugger it shows the values were set to zero so i know that works
wait1Msec ( 300 ) ;
turnLeft (460,degrees,90); ← Does not turn but i can use setDriveMotor ( -90 , 90 ) ; to make it turn
setConeMotor ( 30 ) ;
wait1Msec ( 525 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 30 ) ;
wait1Msec ( 300 ) ;
setDriveMotor ( 40 , 40 ) ; ← Program continues but still did not make second turn
setLiftMotor ( 40 ) ;
setConeMotor ( 40 ) ;
wait1Msec ( 1400 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -127 ) ;
wait1Msec ( 500 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -40 ) ;
setDriveMotor ( -40 , -40 ) ;
wait1Msec ( 900 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 300 ) ;
Is anyone able to help? This needs to be ready by March 10th
I don’t code in natural language so can’t really help there. Have you tried using a Yaw Rate Gyro instead? They are actually WAY more consistent than encoders and I have found easier to code autonomous turns.
invent2049:
We recently added shaft encoders to our robot and are able to use them. we use the shaft encoders on our drive to make turning more consistent. however, once our robot makes a turn, it does not make another. In our 15-second autonomous, we start the robot facing the stationary goal on the right red side, it then lifts up while driving forward, and then drops the preloaded cone onto the stationary goal. After doing so, the robot backs up, turns right using the encoders, drives forward, lowers the lift, and grabs another cone. This is where our issue is, once it grabs the cone, i have programmed it to turn left to face the stationary goal again using the shaft encoders but nothing happens. i am able to make it turn by directly programming the motors for a certain amount of time but it is less consistent. before the second turn i reset the encoders values including a pause. i should also mention that I’m using natural language 2.0
setDriveMotor ( 50 , 50 ) ;
setLiftMotor ( 35 ) ;
setConeMotor ( 40 ) ;
wait1Msec ( 1550 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -80 ) ;
wait1Msec ( 300 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -40 ) ;
setDriveMotor ( -50 , -50 ) ;
wait1Msec ( 700 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 300 ) ;
turnRight ( 250 , degrees , 90 ) ; ← First turn using encoders
wait1Msec ( 500 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 300 ) ;
setDriveMotor ( 30 , 30 ) ;
wait1Msec ( 200 ) ;
setDriveMotor ( 0 , 0 ) ;
wait1Msec ( 200 ) ;
setSwingMotor ( -127 ) ;
setConeMotor ( 127 ) ;
setLiftMotor ( -50 ) ;
wait1Msec ( 1200 ) ;
setSwingMotor ( 0 ) ;
setConeMotor ( 60 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setSwingMotor ( 127 ) ;
setConeMotor ( 30 ) ;
wait1Msec ( 800 ) ;
setSwingMotor ( 0 ) ;
setConeMotor ( 30 ) ;
SensorValue [dgtl1] = 0;
SensorValue [dgtl3] = 0; ← In the debugger it shows the values were set to zero so i know that works
wait1Msec ( 300 ) ;
turnLeft (460,degrees,90); ← Does not turn but i can use setDriveMotor ( -90 , 90 ) ; to make it turn
setConeMotor ( 30 ) ;
wait1Msec ( 525 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 30 ) ;
wait1Msec ( 300 ) ;
setDriveMotor ( 40 , 40 ) ; ← Program continues but still did not make second turn
setLiftMotor ( 40 ) ;
setConeMotor ( 40 ) ;
wait1Msec ( 1400 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
setLiftMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -127 ) ;
wait1Msec ( 500 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 400 ) ;
setConeMotor ( -40 ) ;
setDriveMotor ( -40 , -40 ) ;
wait1Msec ( 900 ) ;
setDriveMotor ( 0 , 0 ) ;
setConeMotor ( 0 ) ;
wait1Msec ( 300 ) ;
I would imagine that NL functions are not happy with setting the value to 0. What happens if you remove the set encoder to 0 line? Also turnLeft and turnRight are relative functions not absolute so you don’t need to 0 the encoders anyway.
have you tried resetting the encoder ticks after the first turn? thats what i do on my program and works fine.