This is the first project I did with Raspberry Pi. Here is a very simple demo:
It is a quite simple project where I can use my dusty Myo. The most difficult part is to enable Raspberry Pi to communicate with Myo. Because there is no official SDK of Myo for Linux, therefore we have to communicate with Myo through Bluetooth manually. Previous effort can be found in myo-raw and pyoconnect. I wrapped the APIs in my own library in raspberrypy.
A simple sample to use my code to control a robot:
# import the Myo module from raspberrypy.control.myo import Myo, Pose # import the robot motor module from raspberrypy.motor.L289N import L289N if __name__ == '__main__': # define a motor object motor = L289N() # define a Myo object myo = Myo() # define the callback function/handler that is used to respond when action is detected def changeMotorOnPose(pose): print pose if pose == Pose.REST: motor.stop() elif pose == Pose.FIST: motor.forward(-1) elif pose == Pose.WAVE_IN: motor.spin_left(-1) elif pose == Pose.WAVE_OUT: motor.spin_right(-1) elif pose == Pose.FINGERS_SPREAD: motor.backward(-1) else: pass # register the handler myo.add_pose_handler(changeMotorOnPose) # detect Myo and connect with it myo.connect() try: while True: myo.run(1) # keep running except KeyboardInterrupt: pass finally: myo.disconnect() # disconnect with the Myo