Program 3 (Fall 2024)
The code below is a set of functions, variables, constants, and algorithms that are the work of RoboCatz for the Fall 2023 season.
const pi = 3.14159
wheelDiameter = 5.6
wheelCircumference = wheelDiameter * pi
distanceBetweenWheels = 12
degreesPerCentirmeter=360/wheelCircumference
swingTurnDiameter = distanceBetweenWheels * 2
swingTurnCircumference = swingTurnDiameter*pi
gearRatio=28/20
resetVector(50)
function moveForward (distance) {
acceleration =gearRatio* degreesPerCentirmeter * distance*.1
atTopSpeed =gearRatio* degreesPerCentirmeter * distance*.8
deceleration = gearRatio* degreesPerCentirmeter * distance*.1
stepMotors( B , C , 80 ,acceleration, atTopSpeed, deceleration)
waitHereWhile getMotorSpeed(B) == 0
waitHereUntil getMotorSpeed(B) == 0
stopAllMotors(true)
}
function moveBackward (distance) {
acceleration =gearRatio* degreesPerCentirmeter * distance*.1
atTopSpeed =gearRatio* degreesPerCentirmeter * distance*.8
deceleration = gearRatio* degreesPerCentirmeter * distance*.1
stepMotors( B , C , -80 ,acceleration, atTopSpeed, deceleration)
waitHereWhile getMotorSpeed(B) == 0
waitHereUntil getMotorSpeed(B) == 0
stopAllMotors(true)
}
moveForward(85)
setMotor( A, -100 )
sleep(2000)
setMotor(A,0)
moveBackward(85)