I printed my own little Makerbot Minion a while back and was talking with Grog about making him a very simple Biped to test a Biped MRL service with.  As of now I have to keep him tethered via USB until I work out the power issues I was having.  

Below is the basic sketch I have loaded in him. It's mostly the sketch included on the thingiverse page but I also fixed some of their bad math that cause him to walk in a circle rather than straight.  I've hard coded the throttle and steering variables that would normally get set by the 2 channels on the RC input.  I added a Hop() function but I never tested it. It might work, might just make him stand on his "knife edges" or it might just be a good way to make him fall over.

 

// Simple Walk 2
// this sketch is an evolution of simple walking program for the Minion
// it moves towards the directon of estabilshing some basic control
 
// Functions are as follows ... 
/// Rest() Which will start moving the Minion back to a level position but the steering will still be taken into account. Looping on this will most likely be required to come to full rest position.
/// Walk() Which will start a sequence to walk forward or backward and is controlled by the throttle and steering.  A full step sequence may require looping over this function multiple times depending on th value of the throttle.
/// Hop() Which will attempt to make the Minion hop in place from a flat footed position. Effectiveness of the hop will mostly depend on the speed of your servos and the weight of your Minion.
 
#include <Servo.h> 
 
Servo lfoot;  // create servo object to control Left Foot
Servo rfoot;  // create servo object to control Right Foot
Servo lleg;  // create servo object to control Left Leg
Servo rleg;  // create servo object to control Right Leg
 
 
int hip = 90;    // variable to store the hip servo position 
int ankle = 90;    // variable to store the ankle servo position
 
int hipstep = 10;  // degree of movement of the hips
int anklestep = 5;  // degree of movement of ankles
 
int sequence = 0;  // variable to store current state of walking sequence
int walktime = 0;  // variable to store delay untill next step sequence
 
// Here's where we'll keep our channel values
int ch1; //input value for throttle
int ch2; //input value for steering
 
int throttle = 0;
int steering = 0;
 
//Setup commands
void setup() 
  //Blink the LED on startup to detect reset during operation
  int led = 17;
  pinMode(led, OUTPUT);
  digitalWrite(led,HIGH);
  delay(1000);
  digitalWrite(led,LOW);
 
  pinMode(2, INPUT);// ch1 pins for pulsein to receve from rc remote
  pinMode(3, INPUT);// ch2
  
  //hips.attache(4);
  //waist.attach(5);
  rfoot.attach(6);  // attaches right foot to pin 6
  rleg.attach(7);  // attaches right leg to pin 7
  lfoot.attach(8);  // attaches left foot to pin 8
  lleg.attach(9);  // attaches left leg to pin 9
  
  //get into rest position to start
  rfoot.write(ankle);
  lfoot.write(ankle);
  rleg.write(hip);
  lleg.write(hip);
 
 
//Primaty loop 
void loop() 
  ch1 = pulseIn(2, HIGH, 25000); // Read the pulse width of 
  ch2 = pulseIn(3, HIGH, 25000); // each channel
 
  if(ch1 == 0, ch2 ==0){ // centers input values if pulsein times out, for when remote is disconected
    ch1 = 1400;
    ch2 = 1400;
  }
  
  //throttle = map(ch1, 800, 2000, 0, 20);
  throttle = 11;
  hipstep = throttle;
  anklestep = (throttle / 2);
  
  //steering = map(ch2, 800, 2000, 0, 40);
  steering = 20;
  //  if(throttle == 10){
  //    Rest();
  //  }
  //  else{
  Walk();
  //  }
  
 delay(15);  // delay for servo to get in possiton.  this needs to be replaced with some type of counter function
}
 
 
//Functions
 
void Rest()  //function to return the walker to rest configeration from any possable state
{
  sequence = 0;  //reset the walk sequence
  
  if((ankle >85)&&(ankle <95)) // Need this check in case the ankle is less than 5 degrees from 90 otherwise the ankles will occilate
  {
    ankle = 90;
    rfoot.write(ankle);
    lfoot.write(ankle);
  }
  if(ankle < 90)
  {
    rfoot.write(ankle); 
    lfoot.write(ankle);
    ankle = ankle + 5;
  }
  if ( ankle > 90){
    rfoot.write(ankle); 
    lfoot.write(ankle);
    ankle = ankle - 5;
  }
  if ((hip > (70 + steering - 10))&&(hip < (70 + steering + 10))) // Need this check in case the hips are less than 10 degrees from 70+steering otherwise the hips will occilate
  {
    hip = 70 + steering;
    rleg.write(hip);
    lleg.write(hip);
  }
  if ( hip < (70 + steering)){
    lleg.write(hip);
    rleg.write(hip);
    hip = hip + 10;
  }
  if ( hip > (70 + steering)){
    lleg.write(hip);
    rleg.write(hip);
    hip = hip - 10;
  }
}
 
void Walk() {  //Function to allow the robot to walk forwards and backwards
  
  if(sequence == 0)  // Rotatates both ankles to lift right foot 
  { 
      if(ankle <= 105){      // checks to see if ankle is at 90+15 degrees not 135 degrees
        rfoot.write(ankle); 
        lfoot.write(ankle);
        ankle = ankle + anklestep;
        //lleg.write(hip + steering);
        //rleg.write(hip + steering);
        
        if(steering < 20)
          lleg.write(hip + steering);
        if(steering > 20)
          rleg.write(hip + steering); 
      }
      else{
        if(throttle >= 10){
          sequence = 1;
        }
        else{
          sequence = 3;
        }
      }                      
  } 
  
  if(sequence == 1)  // Rotatates both hips to move right foot  
  {
      if(hip >= 45){  // was 25.  checks to see if hips are at 45 if not they are moved by the amount dictated in hipstep 
         lleg.write(hip);
         rleg.write(hip);
         hip = hip - hipstep;
      }
      else{  //once we reach 45, the sequence number is updated to 2
         if(throttle >= 10){
           sequence = 2;
         }
         else{
           sequence = 0; 
         }     
      }
  }
  
  if(sequence == 2)  // Rotatates both ankles to lift left foot  
  { 
    if(ankle >= 75){    // checks for ankles 90-15 degrees
      lfoot.write(ankle);
      rfoot.write(ankle); 
      ankle = ankle - anklestep;
      //rleg.write(hip + steering);
      //lleg.write(hip + steering);  
      if(steering < 20)
         lleg.write(hip + steering);
 
      if(steering > 20)
         rleg.write(hip + steering);
    }
    else{
         if(throttle >= 10){
            sequence = 3;
         }
         else{
            sequence = 1;
         }      
    }
  }
  
  if(sequence == 3)  // Rotatates both hips to lift right foot 
  { 
    if(hip <= 135){ //was 115
       lleg.write(hip);
       rleg.write(hip);
       hip = hip + hipstep;
    }
    else{
       if(throttle >= 10){
          sequence = 0;
        }
        else{
          sequence = 2;
        }
    }
  }
}
 
void Hop() { //function to attempt a bunny hop in place by rotating the outside edge of both feet down quickly.
  // Ready .....
  lfoot.write(90);
  rfoot.write(90);
  rleg.write(90);
  lleg.write(90);
  delay(15);
  
  // Jump!!
  rfoot.write(0);
  lfoot.write(180);
  delay(15);
  
  // Brace for impact!
  rfoot.write(90);
  lfoot.write(90);
  delay(15);
}
 
The next step is to slap MRLComm on the arduino ProMicro and convert that sketch to Python in MRL. After that it will be a Biped service.

GroG

10 years 10 months ago

I think the "frame" maker is an interesting idea.  In MRL currently the frames are part of Python functions, and Python supports more complexity, but a gui/frame maker might be a nice thing for people not quite comfortable with scripting...  And if your only doing servo positioning it could aid in rapid prototyping.

We already have sliders for Servos & the servo guis allow them to undock and for many of them to be viewable at once. I think this might all be generalized to a multi-purpose Servo Frame Maker service...  albiet rather lame name :)

When I tether him, he tends to have his skull cap off and his brains dragging on the ground behind him.  :)  Zombie Minion!

mehtaatur

10 years 10 months ago

hey kmc,

this bot looks cute :)

have you designed this? do you have the files for printing this??

dwilli9013

10 years 10 months ago

One of us really need to make the eyelid blink on this bot. That would be the final touch.

Cool Beans thanks for sharing Keith.