Using the Gripper

Learn how to use Sparki’s grippers to grasp objects.

SparkiDuino
Easy

Lessons You Should Know

Introduction

Sparki has a gripper, useful for grabbing and moving objects.

Front - Gripper

The gripper is rack and pinion mechanism driven by a stepper motor, the same kind of motor used to move Sparki’s wheels. The stepper motor’s shaft has a pinion attached, which drives a rack. Moving the motor in one direction opens the gripper, while moving the motor in the other direction closes it:

Rack Pinion

Programming the Gripper

With the mechanics explained, we are now going to program the gripper’s movements.

To move, Sparki needs batteries properly installed, and the power switch on.

These are the basic commands that Sparki’s software provides to control the gripper:

sparki.gripperOpen();  // opens the grippers
sparki.gripperClose(); // closes the grippers
sparki.gripperStop();  // stops the gripper from moving

There is no sensor to detect if the grippers are open or closed. We will control the gripper movements in small, timed movements. To start, make sure the gripper is not fully opened or fully closed.


To open the grippers, we will run this code. It first tells Sparki to open the grippers, then to wait 1500 milliseconds (1.5 seconds), and then to stop the grippers from moving. The result should be that the grippers are opened:

#include <Sparki.h> // include the sparki library

void setup()
{
  sparki.gripperOpen();  // open the robot's gripper
  delay(1500);           // for 1.5 seconds (1500 milliseconds)
  sparki.gripperStop();
}

void loop()
{
}

On the other hand (or gripper!), to close grippers, we will run this code. It first tells Sparki to open the grippers, then to wait 1500 milliseconds (1.5 seconds), and then to stop the grippers from moving. The result should be that the grippers are opened:

#include <Sparki.h> // include the sparki library
void setup()
{
  sparki.gripperClose();  // close the robot's gripper
  delay(1500);           // for 1.5 seconds (1500 milliseconds)
  sparki.gripperStop();
}

void loop()
{
}

Now, try making small modifications to the time interval. For example, you can open (or close) it for 2 seconds. Please don’t try big numbers here, since you will reach the gripper’s mechanical limit fast. By making a few little experiments with the intervals of time, you will soon be familiarized with the gripper’s limits.

Finally, you can try the example program included with the SparkiDuino software.

This small program will open and close your Sparki’s gripper in a never-ending loop, opening it for 1 second (1000 milliseconds), closing it for 1 second, then pausing for 1 second:

Please go to the menu File > Examples > Gripper and download the code to your Sparki:

/*******************************************
 Basic Gripper test

 Sparki has two little grippers it can be 
 used to grab objects and drag them around.
 See what you can grab with them!
********************************************/
#include ; // include the robot library

void setup()
{
}

void loop()
{
  sparki.gripperOpen();  // open the robot's gripper
  delay(1000);           // for 1 second (1000 milliseconds)

  sparki.gripperClose(); // close the robot's gripper
  delay(1000);           // for 1 second (1000 milliseconds)

  sparki.gripperStop();  // stop the grippers from moving
  delay(1000);           // for 1 second (1000 milliseconds)
}

Extra Activities

If you want to improve the control of the gripper, you can always use the stepper motor instructions that we have learned before:

sparki.motorRotate(int motor, int direction,  int speed);
sparki.motorStop(int motor);

Although these two instructions (motorRotate and motorStop) will allow you to control the gripper’s speed, they aren’t as handy as the standard gripper functions learned in this lesson. But why not to experiment with them too? As a tip, the motor parameter that should be used in order to work with the gripper is MOTOR_GRIPPER.