Creating a gesture with Arduino script for InMoov2

 

 

 

Letters in red is what I modified today to start creating a gesture. It works but I would like to create intermediate positions. for exemple the thumb stops at the middle instead of fully retracting.

 

//This is based on the MiniBot project, MiniBlue.pde from Zagros Robotics, Inc
//Modified by Elizabeth Greene (Elizabeth.a.Greene@gmail.com) 30 August 2013 for the inMoov Prosthetics project
//Modified by Gaël Langevin (hairygael@gmail.com) 13/11/2014 for the inMoov Prosthetics project
//Todo:Create gestures positions in a loop!

int r_motor_RotThumb_n = 2;  //Arduino pin to motor Controller Ain1
int r_motor_RotThumb_p = 3;  //Arduino pin tomotor Controller Ain2

int r_motor_Thumb_n = 4;  //Arduino pin to motor Controller Bin1
int r_motor_Thumb_p = 5;  //Arduino pin to motor Controller Bin2

int r_motor_Index_n = 6;  //Arduino pin to motor Controller Ain1
int r_motor_Index_p = 7;  //Arduino pin to motor Controller Ain2

int r_motor_Majeure_n = 8;  //Arduino pin to motor Controller Bin1
int r_motor_Majeure_p = 9;  //Arduino pin to motor Controller Bin2

int r_motor_Pinky_n = 10;  //Arduino pin to motor Controller Ain1
int r_motor_Pinky_p = 11;  //Arduino pin to motor Controller Ain2

int incomingByte = 0; // for incoming serial data

//This value sets the maximum speed of the motor.  It's a value between 1 and 255.
//64 is 1/4 speed, 128 is 1/2 speed, 255 is full speed
int maxSpeed = 250;
int halfSpeed = 150;
int minSpeed = 128;

//These are the values you determined to be the limit for the minimum and maximum finger positions.
int potLimitLowRotThumb = 700;  //RotThumb extend
int potLimitHighRotThumb = 1000;  //RotThumb retract
int potLimitLowThumb = 120;  //Thumb extend
int potLimitHighThumb = 350;  //Thumb retract
int potLimitLowIndex = 20;  //Index extend
int potLimitHighIndex = 470;  //Index retract
int potLimitLowMajeure = 70;  //Majeure extend
int potLimitHighMajeure = 400;  //Majeure retract
int potLimitLowPinky = 170;  //Pinky extend
int potLimitHighPinky = 660;  //Pinky retract

int countRotThumb = 1;
int countThumb = 1;
int countIndex = 1;
int countMajeure= 1;
int countPinky = 1;

int openhand[]={ 700,120,20,70,170};

int sensorValue;

void setup()
{
    pinMode(r_motor_RotThumb_n, OUTPUT);  //Set control pins to be outputs
    pinMode(r_motor_RotThumb_p, OUTPUT);

    digitalWrite(r_motor_RotThumb_n, LOW);  //set both motors off for start-up
    digitalWrite(r_motor_RotThumb_p, LOW);
    
    pinMode(r_motor_Thumb_n, OUTPUT);  //Set control pins to be outputs
    pinMode(r_motor_Thumb_p, OUTPUT);

    digitalWrite(r_motor_Thumb_n, LOW);  //set both motors off for start-up
    digitalWrite(r_motor_Thumb_p, LOW);
    
    pinMode(r_motor_Index_n, OUTPUT);  //Set control pins to be outputs
    pinMode(r_motor_Index_p, OUTPUT);

    digitalWrite(r_motor_Index_n, LOW);  //set both motors off for start-up
    digitalWrite(r_motor_Index_p, LOW);
    
    pinMode(r_motor_Majeure_n, OUTPUT);  //Set control pins to be outputs
    pinMode(r_motor_Majeure_p, OUTPUT);

    digitalWrite(r_motor_Majeure_n, LOW);  //set both motors off for start-up
    digitalWrite(r_motor_Majeure_p, LOW);
    
    pinMode(r_motor_Pinky_n, OUTPUT);  //Set control pins to be outputs
    pinMode(r_motor_Pinky_p, OUTPUT);

    digitalWrite(r_motor_Pinky_n, LOW);  //set both motors off for start-up
    digitalWrite(r_motor_Pinky_p, LOW);

    Serial.begin(57600);

    Serial.print("a = retract RotThumb finger //n");
    Serial.print("w = extend RotThumb finger  //n");
    Serial.print("z = retract Thumb finger  //n");
    Serial.print("x = extend Thumb finger  //n");
    Serial.print("e = retract Index finger //n");
    Serial.print("c = extend Index finger //n");
    Serial.print("r = retract Majeure finger //n");
    Serial.print("v = extend Majeure finger //n");
    Serial.print("t = retract Pinky finger //n");
    Serial.print("b = extend Pinky finger //n");
    Serial.print("s = stop //n");

}

void loop()
{
    if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();
    }

    switch(incomingByte)
    {
        // stop at any time
        case 's':
            digitalWrite(r_motor_RotThumb_n, LOW);
            digitalWrite(r_motor_RotThumb_p, LOW);
                        digitalWrite(r_motor_Thumb_n, LOW);
            digitalWrite(r_motor_Thumb_p, LOW);
                        digitalWrite(r_motor_Index_n, LOW);
            digitalWrite(r_motor_Index_p, LOW);
                        digitalWrite(r_motor_Majeure_n, LOW);
            digitalWrite(r_motor_Majeure_p, LOW);
                        digitalWrite(r_motor_Pinky_n, LOW);
            digitalWrite(r_motor_Pinky_p, LOW);
            Serial.println("Stopped.//n");
            incomingByte='*';
        break;

        case 'a':
            // if were not too high we can retract
            if (analogRead(A2) <= potLimitHighRotThumb) {
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_n, maxSpeed);
                Serial.println("Retract RotThumb//n");
                                countRotThumb = 2;            }
            incomingByte='*';
        break;

        case 'w':
            // if were not too low we can extend
            if (analogRead(A2) >= potLimitLowRotThumb) {
                sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_p, maxSpeed);
                Serial.println("Extend RotThumb//n");
                                countRotThumb = 3;
            }
            incomingByte='*';
        break;
        
        case 'z':
            // if were not too high we can retract
            if (analogRead(A3) <= potLimitHighThumb) {
                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                delay(1);
                analogWrite(r_motor_Thumb_n, maxSpeed);
                Serial.println("Retract Thumb//n");
                                countThumb = 2;            }
            incomingByte='*';
        break;

        case 'x':
            // if were not too low we can extend
            if (analogRead(A3) >= potLimitLowThumb) {
                sensorValue = analogRead(A5);
                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                delay(1);
                analogWrite(r_motor_Thumb_p, maxSpeed);
                Serial.println("Extend Thumb//n");
                                countThumb = 3;
            }
            incomingByte='*';
        break;        
        
        case 'e':
            // if were not too high we can retract
            if (analogRead(A4) <= potLimitHighIndex) {
                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                delay(1);
                analogWrite(r_motor_Index_n, maxSpeed);
                Serial.println("Retract Index//n");
                                countIndex = 2;            }
            incomingByte='*';
        break;

        case 'c':
            // if were not too low we can extend
            if (analogRead(A4) >= potLimitLowIndex) {
                sensorValue = analogRead(A4);
                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                delay(1);
                analogWrite(r_motor_Index_p, maxSpeed);
                Serial.println("Extend Index//n");
                                countIndex = 3;
            }
            incomingByte='*';
        break;          
        
        case 'r':
            // if were not too high we can retract
            if (analogRead(A5) <= potLimitHighMajeure) {
                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                delay(1);
                analogWrite(r_motor_Majeure_n, maxSpeed);
                Serial.println("Retract Majeure//n");
                                countMajeure = 2;            }
            incomingByte='*';
        break;

        case 'v':
            // if were not too low we can extend
            if (analogRead(A5) >= potLimitLowMajeure) {
                sensorValue = analogRead(A5);
                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                delay(1);
                analogWrite(r_motor_Majeure_p, maxSpeed);
                Serial.println("Extend Majeure//n");
                                countMajeure = 3;
            }
            incomingByte='*';
        break;  
        
        
        case 't':
            // if were not too high we can retract
            if (analogRead(A6) <= potLimitHighPinky) {
                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_Pinky_n, maxSpeed);
                Serial.println("Retract Pinky//n");
                                countPinky = 2;            }
            incomingByte='*';
        break;

        case 'b':
            // if were not too low we can extend
            if (analogRead(A6) >= potLimitLowPinky) {
                sensorValue = analogRead(A6);
                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_Pinky_p, maxSpeed);
                Serial.println("Extend Pinky//n");
                                countPinky = 3;
            }
            incomingByte='*';
        break;
    
    case 'y':
            // Type writing position
                if (analogRead(A2) >= potLimitLowRotThumb);
                   (analogRead(A3) <= potLimitHighThumb);
                   (analogRead(A4) >= potLimitLowIndex);
                   (analogRead(A5) <= potLimitHighMajeure);
                   (analogRead(A6) <= potLimitHighPinky); {
                                sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A4);
                                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                                delay(1);
                                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_p, minSpeed);
                                analogWrite(r_motor_Thumb_n, minSpeed);
                                analogWrite(r_motor_Index_p, maxSpeed);
                                analogWrite(r_motor_Majeure_n, halfSpeed);
                                analogWrite(r_motor_Pinky_n, halfSpeed);
                Serial.println("Type writing position//n");
                                countRotThumb = 3;
                                countThumb = 2;
                                countIndex = 3;
                                countMajeure = 2;
                                countPinky = 2;            }
            incomingByte='*';
        break;
        
        case 'u':
            // Victory position
               if  (analogRead(A2) >= potLimitLowRotThumb);
                   (analogRead(A3) <= potLimitHighThumb);
                   (analogRead(A4) >= potLimitLowIndex);
                   (analogRead(A5) >= potLimitLowMajeure);
                   (analogRead(A6) <= potLimitHighPinky); {
                                sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                                delay(1);
                                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                                sensorValue = analogRead(A4);
                                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A5);
                                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_p, maxSpeed);
                                analogWrite(r_motor_Thumb_n, minSpeed);
                                analogWrite(r_motor_Index_p, maxSpeed);
                                analogWrite(r_motor_Majeure_p, halfSpeed);
                                analogWrite(r_motor_Pinky_n, halfSpeed);
                Serial.println("Victory position//n");
                                countRotThumb = 3;
                                countThumb = 2;
                                countIndex = 3;
                                countMajeure = 3;
                                countPinky = 2;            }
            incomingByte='*';
        break;
        
        case 'i':
            // All finger open position
                if (analogRead(A2) >= potLimitLowRotThumb);
                   (analogRead(A3) >= potLimitLowThumb);
                   (analogRead(A4) >= potLimitLowIndex);
                   (analogRead(A5) >= potLimitLowMajeure);
                   (analogRead(A6) >= potLimitLowPinky); {
                                sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A3);
                                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A4);
                                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A5);
                                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A6);
                                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_p, maxSpeed);
                                analogWrite(r_motor_Thumb_p, minSpeed);
                                analogWrite(r_motor_Index_p, maxSpeed);
                                analogWrite(r_motor_Majeure_p, halfSpeed);
                                analogWrite(r_motor_Pinky_p, halfSpeed);
                Serial.println("All finger Open//n");
                                countRotThumb = 3;
                                countThumb = 3;
                                countIndex = 3;
                                countMajeure = 3;
                                countPinky = 3;            }
            incomingByte='*';
        break;
        
        
        case 'o':
            // Suitcase position (todo: add the thumb at mid position)
                if (analogRead(A2) <= potLimitHighRotThumb);
                   (analogRead(A3) >= potLimitLowThumb);
                   (analogRead(A4) <= potLimitHighIndex);
                   (analogRead(A5) <= potLimitHighMajeure);
                   (analogRead(A6) <= potLimitHighPinky); {
                                //sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                                delay(1);
                                sensorValue = analogRead(A3);
                                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A4);
                                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A5);
                                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A6);
                                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_n, maxSpeed);
                                analogWrite(r_motor_Thumb_p, minSpeed);
                                analogWrite(r_motor_Index_n, maxSpeed);
                                analogWrite(r_motor_Majeure_n, halfSpeed);
                                analogWrite(r_motor_Pinky_n, halfSpeed);
                Serial.println("Suitcase position//n");
                                countRotThumb = 2;
                                countThumb = 3;
                                countIndex = 2;
                                countMajeure = 2;
                                countPinky = 2;            }
            incomingByte='*';
        break;
        
        case 'p':
            // Cup position
                if (analogRead(A2) <= potLimitHighRotThumb);
                   (analogRead(A3) <= potLimitHighThumb);
                   (analogRead(A4) <= potLimitHighIndex);
                   (analogRead(A5) <= potLimitHighMajeure);
                   (analogRead(A6) <= potLimitHighPinky); {
                                //sensorValue = analogRead(A2);
                digitalWrite(r_motor_RotThumb_n, LOW);
                digitalWrite(r_motor_RotThumb_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A3);
                                digitalWrite(r_motor_Thumb_n, LOW);
                digitalWrite(r_motor_Thumb_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A4);
                                digitalWrite(r_motor_Index_n, LOW);
                digitalWrite(r_motor_Index_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A5);
                                digitalWrite(r_motor_Majeure_n, LOW);
                digitalWrite(r_motor_Majeure_p, LOW);
                                delay(1);
                                //sensorValue = analogRead(A6);
                                digitalWrite(r_motor_Pinky_n, LOW);
                digitalWrite(r_motor_Pinky_p, LOW);
                delay(1);
                analogWrite(r_motor_RotThumb_n, maxSpeed);
                                analogWrite(r_motor_Thumb_n, minSpeed);
                                analogWrite(r_motor_Index_n, maxSpeed);
                                analogWrite(r_motor_Majeure_n, halfSpeed);
                                analogWrite(r_motor_Pinky_n, halfSpeed);
                Serial.println("Cup Position//n");
                                countRotThumb = 2;
                                countThumb = 2;
                                countIndex = 2;
                                countMajeure = 2;
                                countPinky = 2;            }
            incomingByte='*';
        break;

    
        
        
        default :
                if ((analogRead(A2) <= potLimitLowRotThumb) && (countRotThumb != 2) && (countRotThumb != 1 )){
                     digitalWrite(r_motor_RotThumb_n, LOW);
                     digitalWrite(r_motor_RotThumb_p, LOW);
             Serial.println("Stopped.//n");
                     countRotThumb = 1;}
                else if ((analogRead(A2) >= potLimitHighRotThumb) && (countRotThumb != 3) && (countRotThumb != 1)){
                     digitalWrite(r_motor_RotThumb_n, LOW);
                     digitalWrite(r_motor_RotThumb_p, LOW);
             Serial.println("Stopped.//n");
                     countRotThumb = 1;}
                if ((analogRead(A3) <= potLimitLowThumb) && (countThumb != 2) && (countThumb != 1 )){
                     digitalWrite(r_motor_Thumb_n, LOW);
                     digitalWrite(r_motor_Thumb_p, LOW);
             Serial.println("Stopped.//n");
                     countThumb = 1;}
                else if ((analogRead(A3) >= potLimitHighThumb) && (countThumb != 3) && (countThumb != 1)){
                     digitalWrite(r_motor_Thumb_n, LOW);
                     digitalWrite(r_motor_Thumb_p, LOW);
             Serial.println("Stopped.//n");
                     countThumb = 1;}
                if ((analogRead(A4) <= potLimitLowIndex) && (countIndex != 2) && (countIndex != 1 )){
                     digitalWrite(r_motor_Index_n, LOW);
                     digitalWrite(r_motor_Index_p, LOW);
             Serial.println("Stopped.//n");
                     countIndex = 1;}
                else if ((analogRead(A4) >= potLimitHighIndex) && (countIndex != 3) && (countIndex != 1)){
                     digitalWrite(r_motor_Index_n, LOW);
                     digitalWrite(r_motor_Index_p, LOW);
             Serial.println("Stopped.//n");
                     countIndex = 1;}
                if ((analogRead(A5) <= potLimitLowMajeure) && (countMajeure != 2) && (countMajeure != 1 )){
                     digitalWrite(r_motor_Majeure_n, LOW);
                     digitalWrite(r_motor_Majeure_p, LOW);
             Serial.println("Stopped.//n");
                     countMajeure = 1;}
                else if ((analogRead(A5) >= potLimitHighMajeure) && (countMajeure != 3) && (countMajeure != 1)){
                     digitalWrite(r_motor_Majeure_n, LOW);
                     digitalWrite(r_motor_Majeure_p, LOW);
             Serial.println("Stopped.//n");
                     countMajeure = 1;}
                if ((analogRead(A6) <= potLimitLowPinky) && (countPinky != 2) && (countPinky != 1 )){
                     digitalWrite(r_motor_Pinky_n, LOW);
                     digitalWrite(r_motor_Pinky_p, LOW);
             Serial.println("Stopped.//n");
                     countPinky = 1;}
                else if ((analogRead(A6) >= potLimitHighPinky) && (countPinky != 3) && (countPinky != 1)){
                     digitalWrite(r_motor_Pinky_n, LOW);
                     digitalWrite(r_motor_Pinky_p, LOW);
             Serial.println("Stopped.//n");
                     countPinky = 1;}
        break;
                                

        delay(1);
    }
}


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
theuserbl's picture

At 0:23 in the video there

At 0:23 in the video there stand:
"Unlike the first InMoov hand which was released freely, I am now looking for a way to make this project economically viable"

Can you specify it a little bit more?
So, the InMoov2 hand will not be OpenSource? Or will it be made OpenSource, if the InMoov3 hand is out?
Or will be every new thing five years after the release published as OpenSource?

And what will be happening with the legs and so on? If they are finished, will it NOT published too?

What does it mean for the free InMoov project?
If the new things are closed, then I think you will be no longer having motivation to improve the old things (like the InMoov1 hand).

That also mean, that in the future your creations diverge from the OpenSource InMoov creations other people.
So the OpenSource InMoov1 needs a new home (new central internet side with forum, etc), because it is a complete other thing then that, what you (currently and in future) creates.

Greatings
theuserbl