Thursday, May 12, 2016

About the IP5 project

I have tried to do the project, but nothing came to mind at all, and after several tries, I gave up on it entirely to focus on the MeArm project.  I apologize for the inconvenience.

Reflections and the end of the project

https://www.youtube.com/watch?v=pAzShGbk4qI

After a rework of the UI and some more tinkering, we have the project working at 95% efficiency.  There were some hardware flaws with the crane game since the claw grabs horizontally instead of straight down, but it mainly works very well.



We did pretty well in the Robot Olympics and people even liked our crane game, which is a win for me at least.  For the future I will still focus on the software side of things and will look more into visual design as it interested me.  The class in general was very fun and informative, not just because I got most of it, but because I failed miserably with others.  The project in itself taught me a lot of things, but the biggest thing I got out of it is being stubborn but standing back to look at a problem from a new perspective.  It was a very good experience I got overall.


This is the progress of the claw game right now.  It consists of 5 steps that end with the crane going down and attempting to grab whatever is on said height.  The main challenge this week is to figure out the optimal angles for the claw to move in and the speeds.

https://www.youtube.com/watch?v=N3kW1b_w2PM


This is the progress of the UI so far, I am currently trying to have the crane game properly work but there were a couple of minor issues, like trying to have the rest of the buttons lock once the user chooses a button or lets go of it.  I'm still going through the tinkering, but it's progressing very quickly.

//import processing.serial.*;
//import cc.arduino.*;
import controlP5.*;

//Arduino arduino;
ControlP5 cp5;

int xPos = 120; //60-180 [Free Default 120]
int yPos = 80; //60(PULLEDBACK)-150(PUSHEDFORWARD) [Free Default 80]
int elbowPos = 150; //0-180 [Free Default 150]
int clawPos = 100; //50(OPEN)-100(CLOSED) [Free Default 100]

int bg1 = 0;
int bg2 = 0;

boolean craneStart = false;
boolean craneLeft = false;
boolean craneLeftMove = false;
boolean craneForward = false;
boolean craneForwardMove = false;
boolean cranePickup = false;
boolean cranePickupMove = false;
boolean craneReset = false;

//**//**//**//**//**//

void setup() {
  
  size(1200,800);
  background(200,200,200);
  
  //Initialize CP5 Object
  cp5 = new ControlP5(this);
  
  cp5.addButton("freeMode")
     .setLabel("Activate Free Mode")
     .setPosition(5,5)
     .setSize(590,65)
     .setColorBackground(color(255,127,0)) 
     .setColorForeground(color(255,200,0))
     .setColorLabel(color(0))  
     .setColorActive(color(255,255,0))
     ;
  
  cp5.addButton("craneMode")
     .setLabel("Activate Crane Game")
     .setPosition((width/2)+5,5)
     .setSize(590,65)
     .setColorBackground(color(255,127,0)) 
     .setColorForeground(color(255,200,0))
     .setColorLabel(color(0))  
     .setColorActive(color(255,255,0))
     ;
     
  //CRANE MODE BUTTONS
  
  Button crane0 = cp5.addButton("cStart")
     .setPosition((width/2)+5,80)
     .setSize(590,65)
     .setLabel("START (Click once)")
     .setColorBackground(color(0,255,0));
     ;
     
  Button crane1 = cp5.addButton("cLeft")
     .setPosition((width/2)+5,155)
     .setSize(590,65)
     .setLabel("LEFT (Press and hold)")
     .setColorBackground(color(0,255,0));
     ;
     
  Button crane2 = cp5.addButton("cForward")
     .setPosition((width/2)+5,230)
     .setSize(590,65)
     .setLabel("FORWARD (Press and hold)")
     .setColorBackground(color(0,255,0));
     ;
     
  Button crane3 = cp5.addButton("cPickup")
     .setPosition((width/2)+5,305)
     .setSize(590,65)
     .setLabel("PICK UP (Click once)")
     .setColorBackground(color(0,255,0));
     ;
     
  crane0.addCallback(new CallbackListener() {
    public void controlEvent(CallbackEvent theEvent) {
      switch(theEvent.getAction()) {
        case(ControlP5.ACTION_PRESSED): break;
        case(ControlP5.ACTION_RELEASED): craneLeft = true; craneStart = true; break;
      }
    }
  });
  
  crane1.addCallback(new CallbackListener() {
    public void controlEvent(CallbackEvent theEvent) {
      switch(theEvent.getAction()) {
        case(ControlP5.ACTION_PRESSED): craneLeftMove = true; break;
        case(ControlP5.ACTION_RELEASED): craneForward = true; craneLeft = false; craneLeftMove = false; break;
      }
    }
  });
  
  crane2.addCallback(new CallbackListener() {
    public void controlEvent(CallbackEvent theEvent) {
      switch(theEvent.getAction()) {
        case(ControlP5.ACTION_PRESSED): craneForwardMove = true; break;
        case(ControlP5.ACTION_RELEASED): cranePickup = true; craneForward = false; craneForwardMove = false; break;
      }
    }
  });
  
  crane3.addCallback(new CallbackListener() {
    public void controlEvent(CallbackEvent theEvent) {
      switch(theEvent.getAction()) {
        case(ControlP5.ACTION_PRESSED): break;
        case(ControlP5.ACTION_RELEASED): cranePickupMove = true; cranePickup = false; craneReset = true; break;
      }
    }
  });
  
  //arduino = new Arduino(this, Arduino.list()[2], 57600);
  //arduino.pinMode(8, Arduino.SERVO); // BASE (x movement)
  //arduino.pinMode(4, Arduino.SERVO); // SHOULDER (y movement)
  //arduino.pinMode(12, Arduino.SERVO); // ELBOW (elbow movement)
  //arduino.pinMode(2, Arduino.SERVO); //CLAW (claw movement)
  
  freeMode();
  
}

//**//**//**//**//**//

void draw() {

  background(200,200,200);
  noStroke();
  fill(bg1);
  rect(0,0,width/2,height);
  fill(bg2);
  rect(width/2,0,width/2,height);
  
  if (craneStart) {
    cp5.getController("freeMode").lock();
    
    cp5.getController("cStart").hide();
    setLockC(cp5.getController("cStart"),true);
    cp5.getController("cStart").show();
    
    setLockC(cp5.getController("cLeft"),false);
    setLockC(cp5.getController("cForward"),true);
    setLockC(cp5.getController("cPickup"),true);
    
    craneStart = false;
  }
  
  if (craneLeft) {
    
    if (craneLeftMove) {
      //UPDATE INT "xPos"
    }
    
  }
  
  if (craneForward) {
    cp5.getController("cLeft").hide();
    setLockC(cp5.getController("cLeft"),true);
    cp5.getController("cLeft").show();
    
    setLockC(cp5.getController("cForward"),false);
    
    if (craneForwardMove) {
      //UPDATE INT "yPos"
    }
  }
  
  if (cranePickup) {
    cp5.getController("cForward").hide();
    setLockC(cp5.getController("cForward"),true);
    cp5.getController("cForward").show();
    
    setLockC(cp5.getController("cPickup"),false);
    
    if (cranePickupMove) {
      //UPDATE run custom grab and place object movement
    }
  }
  
  if(craneReset) {
    
    cp5.getController("cPickup").hide();
    setLockC(cp5.getController("cPickup"),true);
    cp5.getController("cPickup").show();
    
    setLockC(cp5.getController("cStart"),false);
    
    cp5.getController("freeMode").unlock();
    
    craneReset = false;
  }
  
  /* DEBUG
  println("craneStart = " + craneStart);
  println("craneLeft = " + craneLeft);
  println("craneLeftMove = " + craneLeftMove);
  println("craneForward = " + craneForward);
  println("craneForwardMove = " + craneForwardMove);
  println("cranePickup = " + cranePickup);
  println("cranePickupMove = " + cranePickupMove);
  println("-----------------------");
  END DEBUG */
  
  //arduino.servoWrite(8, xPos);
  //arduino.servoWrite(4, yPos);
  //arduino.servoWrite(12, elbow);
  //arduino.servoWrite(2, clawPos);
  
}

//**//**//**//**//**//

void freeMode() {
  
  bg1 = 255;
  bg2 = 200;
  
  cp5.getController("freeMode").hide();
  cp5.getController("freeMode").lock();
  cp5.getController("freeMode").show();
  cp5.getController("craneMode").unlock();
  
  setLockC(cp5.getController("cStart"),true);
  setLockC(cp5.getController("cLeft"),true);
  setLockC(cp5.getController("cForward"),true);
  setLockC(cp5.getController("cPickup"),true);
  
}

void craneMode() {
  
  bg1 = 200;
  bg2 = 255;
  
  cp5.getController("craneMode").hide();
  cp5.getController("craneMode").lock();
  cp5.getController("craneMode").show();

  cp5.getController("freeMode").unlock();
  
  setLockC(cp5.getController("cStart"),false);
  
}

//To lock/unlock crane buttons...
void setLockC(Controller theController, boolean locked) {
  
  theController.setLock(locked);
  
  if(locked) {
    theController.setColorBackground(color(255,0,0));
  } else {
    theController.setColorBackground(color(0,255,0));
  }
  
}
https://www.youtube.com/watch?v=8XeVJL-sDNo

First post of MeArm



This is the rough sketch me and Paige Ruka put together as a plan for a Crane game, shown here.  It's more of a rough sketch but it will have 2 modes, a free mode and a crane game.  The details are still out in the open but the gist of it is to have the crane game have 3 buttons to have people press in order.  The third button will have a pre-programmed movement to grab whatever is directly below itself.  The challenge is to have it go down perfectly vertical, and also try to find a way to grab things reliably.

Tuesday, February 16, 2016

We looked at the barebones of the code I have and decided that we need to use different ways to make sure that the pong was accurately following the ball so I can manipulate it more closely, most likely using drifting to make it look smoother

Tuesday, February 9, 2016

Custom Function issues

I tried to do the assignment but I ran into a couple of issues:

    void setup() {
 
   size(2000, 1900);
 
   smooth();
 
  }
 
  void draw() {
 
   background(0);
 
   randomSeed(0);
  for (int i = 65; i < width + 20; i += 40) {
  int gray = int(random(0, 102));
  float scalar = random(0.25, 1.0);
  snowman(i, 110, gray, scalar);
 
   }
 
  }
      void snowman (int x, int y, int z, float s){
        translate(x,y);
        noStroke();
    ellipse(250,350,300,200);
    ellipse(250,250,250,150);
    ellipse(250,150,150,150);
    stroke(67,13,3);
    strokeWeight(5);
    fill(67,13,3);
    line(150,220,50,220);
    line(50,220,30,200);
    line(50,220,30,220);
    line(50,220,30,240);
   
    line(350,220,450,220);
    line(450,220,470,200);
    line(450,220,470,220);
    line(450,220,470,240);
   
    ellipse(275,130,10,15);
    ellipse(225,130,10,15);
   
    ellipse(250,210,10,10);
    ellipse(250,235,10,10);
    ellipse(250,260,10,10);
    fill(255);
    arc(180, 150, 200, 60, 0, PI/3);
    strokeWeight(1);
    fill(255,94,0);
    triangle(250, 160, 250, 150, 200, 170);
 
      }
   
       














The main issue is that I can't make it into different sizes, might be something wrong with my for loop.