RoboCatz.com

Program 2 (Fall 2022)


The code below is a set of functions, variables, constants, and algorithms that are the work of RoboCatz for the Fall 2022 season.

function moveForward(inches,powerLevel=66){
	resetEncoder(B)
	syncMotors(B,C,powerLevel)
	waitHereWhile abs(encoderValue(B))<50*inches
	stopAllMotors(true)
}

function moveBackward(inches){
	resetEncoder(B)
	syncMotors(B,C,-80)
	beep()
	//sleep(1000)
	waitHereWhile abs(encoderValue(B))<48*inches
	stopAllMotors()
}

function turnright(){
	resetGyroSensor()
	syncMotors(B,C,100,200)
	waitHereWhile abs(gyroSensorValue())<90
	stopAllMotors()
}
function liftWall(power){
	setMotor(D,power)
	sleep (2000)
}
function resetWall(power){
	setMotor(D,power)
	sleep(1000)
	waitHereUntil getMotorSpeed(D)==0
	resetEncoder(D)
}
function downWall(){
	setMotor(D,100)
	sleep(100)
	waitHereWhile abs(encoderValue(D))<1720 && getMotorSpeed(D)>0
	setMotor(D,0)
}

//retrieve part
resetWall(-45)
moveForward(20,20)
downWall()
//liftWall(30)
sleep(1000)
moveBackward(30)