RoboCatz.com

Program 4 (Fall 2023)


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


function moveForward(distance) {
    acceleration = 20.571 * distance*.1
    atTopSpeed = 20.571 * distance*.8
    deceleration = 20.571 * distance*.1

   stepMotors( B , C , 50 ,acceleration, atTopSpeed, deceleration)
   waitHereWhile getMotorSpeed(B) == 0
   waitHereUntil getMotorSpeed(B) == 0
   stopAllMotors(true)
   
} 
function moveBackward(distance) { 
  if (distance > 0) {
    acceleration = 20.571 * distance*.1
    atTopSpeed = 20.571 * distance*.8
    deceleration = 20.571 * distance*.1
    stepMotors( B , C , -50 ,acceleration, atTopSpeed, deceleration)
    waitHereWhile getMotorSpeed(B) == 0
    waitHereUntil getMotorSpeed(B) == 0
    stopAllMotors(true)
  } else {
    syncMotors( B, C, -25)
  } 
}
function turnLeft( gyroTarget) { 
  syncMotors( B, C, 25, -100 )
  resetGyroSensor()
  waitHereWhile  abs(gyroSensorValue()) < gyroTarget
  stopAllMotors()
}
function turnRight( gyroTarget) { 
  syncMotors( B, C, 25, +100 )
  resetGyroSensor()
  waitHereWhile  abs(gyroSensorValue()) < gyroTarget
  stopAllMotors()
}
   
moveForward(10000)
//turnLeft(90)
//moveForward(15)
//turnRight(90)
//moveForward(15)
//moveBackward(45)

//moveBackward()
//waitHereUntil lightSensor() < 20
//stopAllMotors(true)