Drawing forearm and bicep with a fix shoulder using accelerometers gyro and magnetometer

edited April 2014 in How To...

Hi everyone,

This is my first post here and new to processing, but I'm eager to learn. I'm doing this project were I'm recording emg (muscle activity)data from master craftsman, as well as movements using accelerometers gyro and magnetometer. I will like to visualize this data by drawing two lines that replicate the arm movements from the sensor data. I have all the sensors data coming from Teensy 3.1 using arduino IDE. Could you guys help me with this challenge, any help will be greatly appreciated.

Thanks in advanced

Tagged:

Answers

  • Sort of, I'm just focusing on the forearm and bicep. I'm confused as how to do it I guess I have to create two vectors and make the elbow where they intersect.

  • http://forum.processing.org/two/discussion/comment/14472#Comment_14472

    See my 1st sketch here

    We were not able to solve the thing

  • edited April 2014

    Thank you Chrisir,

    I have done some progress but I can't figure out how to do the elbow. Here it is my code so far

    import processing.serial.*;
    String message="  ";
    
    Table table;
    int lf = 10;
    String[] columns;
    String values = null;
    Serial myPort;  // The serial port
    float armY,armP,armR, bicepY, bicepP, bicepR;
    void setup(){
      size(1300,800,OPENGL);
    
      columns=message.split("\t");
     println(columns);
    
      background(0);
      frameRate(30);
      String portName = Serial.list()[9];
      if(myPort==null)
      myPort = new Serial(this, portName, 115200);
    //table=loadTable("MOTION_RECORD_TEST1.csv","header");
    
    }
    int currentTime=0;
    int counter=0;
    float alpha=0.5;
    
    void draw(){
    
         box(100,100,100);
         if(columns.length==6){
          armY=float(columns[0]);//println(armY);
          armP=float(columns[1]);
          armR=float(columns[2]);
          bicepY=float(columns[3]);
          bicepP=float(columns[4]);
          bicepR=float(columns[5]);
    
    
      fill(255,0,0);
      background(0);
    
    
    //Forearm
      pushMatrix();
      translate(width/2,height/2);
       rotateY(-radians(armY));
      rotateX(-radians(armP));
      rotateZ(radians(armR)); 
    
      translate(0,0,500);
       box(50,50,200);
       popMatrix();
    
    //bicep
      pushMatrix();
      translate(width/2,height/2);
       rotateY(-radians(bicepY));
      rotateX(-radians(bicepP));
      rotateZ(radians(bicepR)); 
    
      translate(0,0,500);
       box(50,50,200);
       popMatrix();
    
    
    
       counter++;
      if(counter>10000)
      counter=0;
     }
    
    }
    
    void serialEvent(Serial myPort) {
       int inByte=myPort.read();
      if(inByte!=lf){
      message+=char(inByte);
       //println(message);
     println(" ");
      }
      else{
    // println(message);
    // println(" ");
      columns=message.split("\t");
      message="";
      // println(message);
     println(" ");
      }
    
      }
    
  • I can't help you with that

  • edited April 2014

    Not a problem Chrisir, and thanks for looking into it.

    For anyone interested. I have sort gotten it to be have you have to change the rotation matrix according to your sensors

        import processing.serial.*;
    String message="  ";
    
    Table table;
    int lf = 10;
    String[] columns;
    String values = null;
    Serial myPort;  // The serial port
    float armY,armP,armR, bicepY, bicepP, bicepR;
    void setup(){
      size(1300,800,OPENGL);
    
      columns=message.split("\t");
     println(columns);
    
      background(0);
      frameRate(30);
      String portName = Serial.list()[9];
      if(myPort==null)
      myPort = new Serial(this, portName, 115200);
    //table=loadTable("MOTION_RECORD_TEST1.csv","header");
    
    }
    int currentTime=0;
    int counter=0;
    float alpha=0.5;
    
    void draw(){
    
         box(100,100,100);
         if(columns.length==6){
    
          bicepY=float(columns[0]);
          bicepP=float(columns[1]);
          bicepR=float(columns[2]);
          armY=float(columns[3]);//println(armY);
          armP=float(columns[4]);
          armR=float(columns[5]);
    
     lights();
    
      fill(255,0,0);
      background(0);
    
    
    //ARM
    
      pushMatrix();
    
      translate(width/2.5,height/2.5);
      rotateX(radians(bicepP));
      rotateX(radians(90));
    
      translate(120,0);
      rotateY(radians(-bicepY));
      rotateY(radians(-bicepR));
       translate(0,100,0);
    
       box(50,250,50);
       translate(0,100,0);
     rotateY(radians(armR));
      rotateX(radians(armP));
         translate(0,100,0);
    
      fill(0,130,255);
      box(50,250,50);
      popMatrix();
    
    
    
       counter++;
      if(counter>10000)
      counter=0;
     }
    
    }
    
    void serialEvent(Serial myPort) {
       int inByte=myPort.read();
      if(inByte!=lf){
      message+=char(inByte);
       //println(message);
     println(" ");
      }
      else{
    // println(message);
    // println(" ");
      columns=message.split("\t");
      message="";
      // println(message);
     println(" ");
      }
    
      }
    
Sign In or Register to comment.