示例#1
0
 // default constructor
 public Odometer(Motors pMotors) {
   leftMotor = pMotors.getLeftMotor();
   rightMotor = pMotors.getRightMotor();
   wheelRadius = pMotors.getWheelRadius();
   axleLength = pMotors.getAxleLength();
   x = 0.0;
   y = 0.0;
   distanceTravelled = 0.0;
   // by default the robot is pointing along the positive y axis
   theta = Math.PI / 2;
   lock = new Object();
 }
 public ObstacleAvoider(
     Odometer pOdometer,
     UltrasonicPoller pUltraSonicPoller,
     UltrasonicController pwallFollowerController,
     Motors pMotors) {
   ultraSonicPoller = pUltraSonicPoller;
   wallFollowerController = pwallFollowerController;
   odometer = pOdometer;
   leftMotor = pMotors.getLeftMotor();
   rightMotor = pMotors.getRightMotor();
   leftUltraSoundMotor = pMotors.getLeftUltraSoundMotor();
   wheelRadius = pMotors.getWheelRadius();
   axleLength = pMotors.getAxleLength();
 }