/// <summary> /// contains logic to collect food: /// .) drive a bit back /// .) lower grappler /// .) drive a bit forward with rotating grappler-wheel /// .) rise grappler /// </summary> public static void CollectFood() { SetTrackSpeed(Constants.DRIVE_BACKWARD_SPEED, Constants.DRIVE_BACKWARD_SPEED); Thread.Sleep(1500); TurnOffGrappler(); GrapplerWheelMotor.SetSpeed(Constants.GRAPPLER_WHEEL_SPEED); SetTrackSpeed(Constants.DRIVE_FORWARD_AFT_BACKWARD_SPEED, Constants.DRIVE_FORWARD_AFT_BACKWARD_SPEED); Thread.Sleep(1500); HaltMotors(); RiseGrappler(); FoodState = FoodState.Carrying; }
/// <summary> /// puts down the grappler and opens it, if it's in the air /// closed /// </summary> public static void RealeaseBrickOnMeadow() { if (GrapplerPosition == GrapplerPosition.Up && FoodState == FoodState.Carrying) { SetTrackSpeed(Constants.DRIVE_FORWARD_SPEED, Constants.DRIVE_FORWARD_SPEED); Thread.Sleep(500); HaltTracks(); GrapplerWheelMotor.ResetTacho(); GrapplerWheelMotor.SetSpeed(Constants.GRAPPLER_WHEEL_SPEED); while (Math.Abs(GrapplerWheelMotor.GetTachoCount()) < Constants.GRAPPLER_WHEEL_BOUNDARY) { //Robot.Print($"tacho = {GrapplerMotor.GetTachoCount().ToString()}"); } GrapplerWheelMotor.Off(); FoodState = FoodState.Searching; } }
/// <summary> /// halts the two motors that are responsible for rising/lowering /// and turning the grappler /// </summary> public static void TurnOffGrappler() { GrapplerRiserMotor.Off(); GrapplerWheelMotor.Off(); GrapplerPosition = GrapplerPosition.Down; }