Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.62 KB | None | 0 0
  1. ////////////////////////////////// new method parkatstorageplatform    
  2.  
  3. /**
  4.      * Makes the AGV park on the storage platform
  5.      * Side to park is recognized automatically by using the z axis
  6.      * which platform to park at is recognized by the location/waypoint it is standing on
  7.      * @param location
  8.      */
  9.     public void parkAtStoragePlatform(int location) {
  10.         location += 1;
  11.         int temp = location;
  12.         int xStartPoint;
  13.         float eastorwest;
  14.         //determine which side the AGV is at
  15.         if (this.getWorldTranslation().z < 0) {
  16.             eastorwest = -122f;
  17.         }
  18.         else{
  19.             eastorwest = 113f;
  20.         }
  21.         //if the agv is lower than x=70 its at ship platform
  22.         if (this.getWorldTranslation().x < 70) {
  23.             xStartPoint = -167;
  24.         }
  25.         //if lower than 330 train platform
  26.         else if (this.getWorldTranslation().x < 330) {
  27.             xStartPoint = 113;
  28.         }
  29.         //else it's at the lorry platform
  30.         else{
  31.             xStartPoint = 363;
  32.         }
  33.         //AGVs spawn in groups of 6, after 6 a extra distance is added
  34.         while (temp > 6) {
  35.             temp -= 6;
  36.             xStartPoint += 22;
  37.         }
  38.         path.clearWayPoints();
  39.         path.addWayPoint(new Vector3f(this.getWorldTranslation()));
  40.         path.addWayPoint(new Vector3f(xStartPoint + (4.7f * location), 0, this.getWorldTranslation().z));
  41.         path.addWayPoint(new Vector3f(xStartPoint + (4.7f * location), 0, eastorwest));
  42.         motionControl.play();
  43.     }
  44.  
  45. ////////////////////////////////////////fixes in leavestorageplatform method
  46.  
  47.     /**
  48.      * Determine in which storagearea this AGV is parked and send the AGV to the
  49.      * nearby waypoint
  50.      */
  51.     public void leaveStoragePlatform() {
  52.         char[] gotowaypoint = new char[1];
  53.         int west = -122;
  54.         int east = 113;
  55.         //western ship platform -> goto waypoint P
  56.         if ((int)this.getWorldTranslation().x < 12 && (int)this.getWorldTranslation().z == west) {
  57.             gotowaypoint[0] = 'P';
  58.         } //eastern ship platform -> goto waypoint Q
  59.         else if ((int)this.getWorldTranslation().x < 12 && (int)this.getWorldTranslation().z == east) {
  60.             gotowaypoint[0] = 'Q';
  61.         } //western train platform -> goto waypoint O
  62.         else if ((int)this.getWorldTranslation().x > 110f && (int)this.getWorldTranslation().x < 300 && (int)this.getWorldTranslation().z == west) {
  63.             gotowaypoint[0] = 'O';
  64.         } //eastern train platform -> goto waypoint N
  65.         else if ((int)this.getWorldTranslation().x > 110f && (int)this.getWorldTranslation().x < 300 && (int)this.getWorldTranslation().z == east) {
  66.             gotowaypoint[0] = 'N';
  67.         } //western lorry platform -> goto waypoint L
  68.         else if ((int)this.getWorldTranslation().x > 365f && (int)this.getWorldTranslation().x < 550 && (int)this.getWorldTranslation().z == west) {
  69.             gotowaypoint[0] = 'L';
  70.         } else if ((int)this.getWorldTranslation().x > 365f && (int)this.getWorldTranslation().x < 550 && (int)this.getWorldTranslation().z == east) {
  71.             gotowaypoint[0] = 'M';
  72.         } //AGV is not in any of the storage area's, send a msg and add 0
  73.         else {
  74.             System.out.println("AGV at location " + this.getWorldTranslation() + " cannot leave storage area because this AGV is not in any storage area.");
  75.             gotowaypoint[0] = '0';
  76.         }
  77.         //only call move method when there's a valid waypoint in the char[] to avoid exception
  78.         if (gotowaypoint[0] != '0') {
  79.             move(gotowaypoint);
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement