Advertisement
Technologyman00

Hood Tracking

Sep 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. import java.util.Random;
  2. public class AdjustableHoodBot {
  3. public static void main(String[] args) {
  4.    
  5.     //Instances
  6.     Random gen = new Random();
  7.    
  8.     //Variables
  9.     double x,y,height,width;
  10.     double[] wantx = new double[2];
  11.     double LeftMotor = 0, RightMotor = 0;
  12.     double hoodangle = 0, wanthoodangle, distanceh, distancew, heightofgoal;
  13.     boolean auto = false;
  14.     boolean[] good = new boolean[2];
  15.     int testdisth = 0, testheighth = 0;
  16.     int testdistw = 0, testheightw = 0;
  17.    
  18.     //Create Data
  19.     x = gen.nextInt(640);
  20.     y = gen.nextInt(400);
  21.     height = gen.nextInt(400);
  22.     width = gen.nextInt(640);
  23.    
  24.     heightofgoal = 88; //Probably should be Minus the height of the shooter
  25.     wantx[0] = 0; // Big
  26.     wantx[1] = 0; // Small
  27.  
  28.    
  29.    
  30.         //Y-Axis of the Target
  31.         //Angle Adjust
  32.             distanceh=((height*testdisth)/testheighth);
  33.             //distancew=((width*testdistw)/testheightw);
  34.             wanthoodangle = Math.atan2(heightofgoal,distanceh);
  35.             if(wanthoodangle > hoodangle){
  36.                 //Move hood down
  37.                 //Make Code to Take care of this if only ran once
  38.             }
  39.             else if(wanthoodangle < hoodangle){
  40.                 //Move hood up
  41.                 //Make Code to Take Care of this if only ran once
  42.             }
  43.             else if(wanthoodangle == hoodangle){
  44.                 //Hood is Good
  45.                 good[0] = true;
  46.             }
  47.            
  48.         //X-Axis of the Target
  49.         //Differs Depending on Has Turret or Not   
  50.             if(wantx[0] < x){
  51.                 //Turn with Controller so that it doesn't turn too far
  52.                
  53.             }
  54.             else if(wantx[1] > x){
  55.                 //Turn with Controller so that it doesn't turn too far
  56.             }
  57.             else if(wantx[0] <= x && x >= wantx[1]){
  58.                 //good
  59.                 good[1] = true;
  60.             }
  61.         //Check if all is good
  62.             if(good[0] && good[1]){
  63.                 //Shoot Ball if Trigger is Held
  64.             }
  65.             else{
  66.                 //Repeat Code But Shouldnt Need to.
  67.             }
  68.            
  69.            
  70.            
  71.         System.out.println("LeftMotor: "+LeftMotor+" RightMotor: "+RightMotor);    
  72.  
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement