def __init__(self): self.srv = servo.ServoController() self.trackerThread = threading.Thread(target=self.track, name="tracker") self.trackingState = False self.trackerThread.setDaemon(True) self.event_stopTracking = threading.Event() self.capture = cv2.VideoCapture(0)
import servo pan = servo.ServoController(25) tilt = servo.ServoController(24) for deg in range(-90, 91, 5): pan.setAngle(deg) tilt.setAngle(deg)
#!/usr/bin/env python import servo grip = servo.ServoController(17) grip.setAngle(90) elbow = servo.ServoController(27) elbow.setAngle(0) shoulder = servo.ServoController(22) shoulder.setAngle(25) hip = servo.ServoController(23) hip.setAngle(0) def move(servo, action): # Choose the direction of the request if servo == 'g': if action == 'o': grip.setAngle(45) elif action == 'c': grip.setAngle(90) elif servo == 'e': elbow.setAngle(int(action)) elif servo == 's': shoulder.setAngle(int(action)) elif servo == 'h':
elif arm_command == 'elbowup': servoController.incAngle(ELBOW, -10) elif arm_command == 'elbowdown': servoController.incAngle(ELBOW, 10) elif arm_command == 'shoulderback': servoController.incAngle(SHOULDER, -10) elif arm_command == 'shoulderforward': servoController.incAngle(SHOULDER, 10) elif arm_command == 'hipleft': servoController.incAngle(HIP, 10) elif arm_command == 'hipright': servoController.incAngle(HIP, -10) return arm_command if __name__ == '__main__': servoController = servo.ServoController() servoController.setAngle(GRIP, -90) servoController.setAngle(ELBOW, -20) servoController.setAngle(SHOULDER, -40) servoController.setAngle(HIP, -25) app.run(host='0.0.0.0', debug=True)