Introduction: Hugbot - a Soft Robot Who Gives Small Hugs

Hugbot is a soft robot which gives small hugs. Its arms are made of custom 3D printed vertebrae and actuated by fishing wire which is threaded through the vertebrae to stepper motors controlled by an Arduino inside its body. Hugbot was born of an interest in making something soft and squishy which could move based on its outside environment.

They key to Hugbot is its arms, made of 3D printed joints with two strings running through them. Pulling one string or the other causes the arm to bend. Hugbot is simply two of these arms, each hooked up to a pulley on a stepper motor controlled by an Arduino Uno. A flex sensor in its head provides input for when the arms should open or close.

Step 1: Gather Your Materials

I made Hugbot a particular size to fit all the electronics in a project box I bought at the hardware store. Its arms were not very strong, so if I were to do it again I might try for stronger steppers powered separately than the Arduino. Despite not being very strong, this Hugbot was a great size, low power, and still quite cute. So here's what you need to make a Hugbot like mine! If you try more powerful motors, let me know how it goes!

Craft supplies

  • Body: Half a yard of fleece fabric, plus some small amount of a contrasting color for the paws. Stuffing for the body.
  • Eyes: Buttons or plastic eyes
  • Zipper or velcro to close up the back of Hugbot so the electronics are removable.
  • Thread
  • Nylon fishing line or similar thin, strong cord.

Electronics

  • Arduino Uno (or similar) and a cord
  • 2 of the 28BYJ-48 5V stepper motor and 2 of the ULN2003 driver board
  • One flex sensor (I used the 2.2" one from Sparkfun)
  • One 17.3kohm resistor
  • Solid core wire
  • (Optional) Electrical tape / shrink wrap
  • (Optional) Breadboard for prototyping

Misc

Tools

  • 3D printer
  • A computer with which to program the Arduino and run the 3D printer
  • Sewing machine or needle
  • Scissors
  • Soldering iron
  • Needle-nose plyers
  • Wire strippers
  • Screwdriver

Step 2: 3D Print Hugbot's Custom Components

I created Hugbot's components using OnShape and the documents are available for anyone to copy and make their own - the links are below. If you want to use my designs exactly, head over to Hugbot on Thingiverse to download and print the custom Hugbot components.

(12) Hugbot's arm joints. Print more if you want longer arms!

(2) Hugbot's arm base, used as the first joint outside the box, this rotates the cords 90 degrees so that the arms move horizontally instead of vertically.

(2) Hugbot stepper pulley. Attaches to the stepper motor, the cord wraps around this to pull the arms.

(1) Hugbot stepper platform. Please note: the platform fits snuggly into the .7 liter Really Useful Box. If you use a different project box, you might want to modify this platform or mount your stepper motors in a different way.

Step 3: Assemble the Arms!

Maybe it makes sense to do the electronics first, but I just love Hugbot's arms so I recommend you start there!

In this step, we will create an "inner arm" that houses the joints. This will later be covered by an arm "sock" which will be the visible skin of the arm. We will use both the arm joints and the arm "base" joint.

  1. Cut a 2" strip of fleece along the stretchy direction of the fabric. Make it about a foot long for now (or a little long than your Hugbot's arms), we will trim it down later.
    • You will notice that your fleece is more stretchy in one direction than the other. Hugbot's arms must bend, so we want the arm fabric to stretch in the direction of the arms. So cut your strip so that the length of it is stretch, and the width less so.
  2. With a needle and thread, sew the loops on the back of the Hugbot joints down to the fabric, one joint at a time. Leave about a centemeter between joints. This allows the joints to bend! Use half of the joints in each arm.
  3. At the very end, sew on the base joint. Check that the holes for the cord line up with the holes in your other arm joints, and that the loops on the joint are on the same side as those of your other arm joints.
  4. Cut two 18" pieces of nylon cord (extra length, for now). Thread your nylon cord through each of the holes in the joints until it comes out the other side.
  5. Insert a screw into each hole in the final joint, and screw it most of the way in. Use it to hold one end of your nylon cord in place. Careful not to pull the cord all the way through the holes -- it will be hard to re-thread once you do step 6.
  6. Wrap the fleece around the joints and use a whip stitch to sew it closed. You can cut off extra width before doing this -- the joints should be slightly snug inside of the fleece.

Repeat for the second arm!

Step 4: Now for the Electronics!

  1. Upload a program to the Arduino to drive the steppers when the flex sensor is activated. My code is below!
  2. Connect the stepper driver boards to the stepper motors and Arduino. I used pins 2, 3, 4, and 5 and pins 8, 9, 10 and 11 for the two stepper driver boards, but you can use whichever pins you like and adjust the code below accordingly.
  3. The bend sensor has very short legs, so I soldered long pieces of solid core wire to the legs to extend it further from the rest of the project. I used shrink wrap (electrical tape works too) to protect the connection, as the bend sensor will be getting a lot of use and I did not want the legs to break.
  4. Create a voltage divider with the bend sensor and resistor: connect the bend sensor to 5V on one side and the 17.3 kohm resistor on the other. This joint should have a third leg that goes to pin A0 on the arduino. Then connect the remaining leg of the resistor to Arduino ground.
  5. Finally, test it all out! Bend the sensor and see if the motors spin.

Below is the Arduino sketch I used to control the stepper motors with the flex sensor, and it is also an attachment above.

/**
* Code to turn a stepper motor when a flex sensor is activated.

*

*

* The flex is measured by a voltage divider with a 17.3kohm resistor and a 2.2"

* flex sensor. The resistor goes to Arduino ground, the flex sensor goes to 5V,

* and the middle of the divider goes to A0.

*

* One stepper is wired through arduino pins 2, 3, 4 and 5 corresponding to

* the stepper board pins 1N1, 1N2, 1N3, and 1N4. The other is at pins 8, 9, 10 and 11.

*/

#include

#define STEPS_PER_MOTOR_REVOLUTION 32

//---( Steps per OUTPUT SHAFT of gear reduction )---

#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048

Stepper stepper1(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);

Stepper stepper2(STEPS_PER_MOTOR_REVOLUTION, 2, 4, 3, 5);
int STEPS_PER_FLEX = 5; // The degrees of flex at which we assume the user is requesting a hug.

int FLEX_THRESHOLD = 20;

int MAX_ROTATION = STEPS_PER_OUTPUT_REVOLUTION;

int MIN_ROTATION = 0;

int currentRotation = 0;

// The input pin.

int input = 0;

void setup() {

stepper1.setSpeed(600);

stepper2.setSpeed(600);

}

void loop() {

int sensor = analogRead(input);

// Map the flex amount to an angle between 0 and 90 degrees.

// The min and max here are from observation and should be updated for each hugbot.

int flex = map(sensor, 470, 200, 0, 90);

int rotationAmt = 0;

// Calculate whether we should rotate depending on the amount of flex.

// Rotate only STEPS_PER_FLEX at a time to maintain a reactive appearance.

if (flex > FLEX_THRESHOLD) {

rotationAmt = min(MAX_ROTATION - currentRotation, STEPS_PER_FLEX);

} else {

rotationAmt = -1 * min(currentRotation - MIN_ROTATION, STEPS_PER_FLEX);

}

if (rotationAmt != 0) {

currentRotation += rotationAmt; // Move the arms in opposite directions.

stepper1.step(rotationAmt);

stepper2.step(-rotationAmt);

}

}

Step 5: Fitting It in the Project Box

Time to get the electronics to fit in the project box.

Mount your stepper motors to the 3D printed table, with the body of the motor below the table and the shaft sticking through, use the M3 screws and nuts to hold them securely in place. Place the Hugbot pulleys on the stepper shafts.

Carefully layer your electronics under the table. Make sure the Arduino's USB plug is near the back edge of the box so you can run a cord to it later!

I used electrical tape on the back of the stepper driver boards to keep them from shorting out, and more electrical tape to hold wires in bundles for cable management. The Arduino is below the stepper driver boards, and I have a thin piece of plastic, about the size of a credit card, between the Ardiuno and the driver boards. Everything is then secured with more electrical tape. You could drill some more holes in the 3D printed table to mount the Arduino properly with screws, too.

The purpose of all this layering and taping is to get the whole table to fit into the project box. You want the stepper motors to be on top, and all the other electronics to be underneath the table in the bottom of the box.

Once you get it in the project box, figure out where you will need to drill holes:

  • 1 large hole for power for the Arduino (use an knife or large drill bit)
  • An exit for the flex sensor in the lid of the box
  • 4 small holes next to the stepper pulleys for the nylon cords which control the arms

Step 6: Connect the Internal Arms and Test!

Getting the cords wrapped the right way around the pulleys can be tricky, so be patient! Try getting your pulleys to rotate by plugging in the project before wrapping the cords around them, so you can make sure you are doing it the right way.

  1. Thread the cords from the ends of the arms with no screws through the holes in the project box.
  2. Tie each cord on the small hole at the top/bottom of the pulley, than wrap it a few times around. For each arm, one cord wraps clockwise and the other counterclockwise.
  3. Tighten the cords, one at a time, from the far end of the arm. Tighten the screw to hold the cords tight. Both cords should be in tension. It is OK if the arms are not bent the same way -- the pulleys can be rotated on the stepper motors to adjust the position at any time without damaging the motors.
  4. Plug in the Hugbot innerds and give it a test by flexing the flex sensor! Here are some common problems I had:
    • The arms don't move because there isn't enough tension. Increase the tension by adjusting the screw at the far end of the arm.
    • The arms don't move because the stepper is not strong enough. Try using fewer joints or sewing the joints a little further apart to make bending easier.
    • The arms move the wrong way. Unwind the strings from the pulleys and try again.

Step 7: Sew the Body

Arms

You will need to sew two arm-socks (the skin for the arms). The arm-socks should be a little bit loose on the inner arms so as not to create additional resistance when the arms are bending.

  • Cut a piece of fleece that is about 4" wide by a few inches longer than your Hugbot's arms.
  • At one end, sew a round piece of contrasting fabric to make a "paw".
  • Fold the arm over with the paw-patch facing in, and sew along the long edge and the short edge close to the paw-patch. The seam allowance depends on how easily the arm-sock slips over your inner arm! Do not sew along the final short edge.
  • Turn the arm inside-out, and test it on your Hugbot arms then cut it to length.

Body

The body is just a sewn cube. 5 of the panels are exactly the same, but one needs to have a zipper or velcro down its whole length, to allow for the project box to be added and removed (so the project is washable!). When the zipper or velcro is opened, the project box must be able to fit through it. This requirement dictates the minimum size of your cube, but you can absolutely make it larger!

Here's a great tutorial on how to make a cube.

You can also make any other shape of body -- just try to make the body about the same width as the project box, and make an opening large enough to put the box in after it is sewn.

Antenna

Cut a 4" by 1" piece of fleece. Fold it in half length-ways and sew down the open edge. Turn it inside out (pulling on the ends of the thread may help), then whip-stitch up one side. Slide it over the bend sensor, then sew the bottom against the wires to keep it from coming off.

Step 8: Assembly and Hugathon!

  1. Figure out where the arms will come out of the body, and cut a small hole (X) through the body fabric in that place. The hole should be just big enough to allow an arm to pass through.
  2. Use the screws at the end of the arms to loosen the tension on the nylon cords, then thread the arms through their respective holes in the side of the body.
  3. Insert the project box of electronics, and re-tighten the nylon cord using the screws at the end of the arms until you have tension in both cords.
  4. Add some stuffing and make it huggable.
  5. Slip on the arm socks, tucking the ends through the same hole in the body that the arm exits, so that the internal arm is not visible.
  6. Cut a tiny hole in the top of Hugbot for the flex sensor, and pull it through partway.
  7. Finally, plug in Hugbot, close up the back, and get hugging!