The Idea
When I first saw the claw robot, it looked really cool. It had a movable claw, which could spin 360 degrees. I got it, and started assembling it. Once it was done, I started tinkering.
How It Works
There are 3 servo motors in the arm, that allow it to flex in 3D. There is another servo allowing the camera to tilt up and down, and another to make the whole arm move. I wrote code some code, so that you can tele-operate the robot. Then I wrote some code that picked up an object in front of the robot, then set it back down. This was basic, but it helped me learn more about the claw robot.
Code to Pick Up an Object
# Importing and initilizing libraries & parameters
import threading
from time import sleep
from jetbot import Robot
from SCSCtrl import TTLServo
import traitlets
import ipywidgets.widgets as widgets
from IPython.display import display
from jetbot import Camera, bgr8_to_jpeg
robot = Robot()
# Displaying the live image feed from the camera
camera = Camera.instance(width=600, height=600)
image = widgets.Image(format='jpeg', width=600, height=600) # this width and height doesn't necessarily have to match the camera
camera_link = traitlets.dlink((camera, 'value'), (image, 'value'), transform=bgr8_to_jpeg)
display(image)
# Function to pick up an object
def pickup():
goalX = 110
goalY = -140
goalC = 120
grabStatus = 100
TTLServo.xyInputSmooth(goalX, goalY, 3)
TTLServo.servoAngleCtrl(1, 0, 1, 100)
TTLServo.servoAngleCtrl(5, 0, 1, 100)
sleep(3.5)
TTLServo.servoAngleCtrl(4, 0, 1, 100)
TTLServo.servoAngleCtrl(4, -40, 1, 100)
print('๐Done!๐')
sleep(1.5)
goalx = 180
goaly = 0
goalc = 0
TTLServo.xyInputSmooth(goalx, goaly, 3)
TTLServo.servoAngleCtrl(1, 0, 1, 100)
TTLServo.servoAngleCtrl(5, 0, 1, 100)
sleep(1.5)
TTLServo.servoAngleCtrl(4, -40, 1, 100)
pickup()
sleep(5.0)
# Function to put the object back down
def putdown():
grabStatus = 100
goalX = 110
goalY = -140
goalC = 120
TTLServo.xyInputSmooth(goalX, goalY, 3)
TTLServo.servoAngleCtrl(1, 0, 1, 100)
TTLServo.servoAngleCtrl(5, 0, 1, 100)
sleep(3.5)
TTLServo.servoAngleCtrl(4, 0, 1, 100)
TTLServo.servoAngleCtrl(4, 0, 1, 100)
print('๐Done!๐')
putdown()
sleep(3.0)
# Funtion to return the arm to its initial position
def initial_position():
goalX = 180
goalY = 0
goalC = 0
TTLServo.xyInputSmooth(goalX, goalY, 3)
TTLServo.servoAngleCtrl(1, 0, 1, 100)
TTLServo.servoAngleCtrl(4, 0, 1, 100)
TTLServo.servoAngleCtrl(5, 0, 1, 100)
sleep(3.5)
print('๐Done!๐')
initial_position()
robot.stop()This isn't the most efficient way, but it is pretty cool.
Video Demonstration
What I Learned
I learned how to use the claw robot, and how to control the arm with code. I also learned a little bit more about coding in the process.