Package: pykeigan-motor
IntroductionYou can control your Keigan Motor through USB Serial and BLE.https://www.keigan-motor.com/This library has been updated from v1 to more than v2.The method names are not comatible, but we added many important features.We strongly recommend more than v2 from now on.Just in case you can get v1 from: https://github.com/keigan-motor/pykeigan_motor/tree/v1At present we support Linux only for BLE, because the BLE functions of this library depends on bluepy(Python interface to Bluetooth LE on Linux by Mr. Ian Harvey):https://github.com/IanHarvey/bluepyThe USB serial functions should work on Windows and Mac too.Requirementspython >= 3.5 (recommended)pyserial >= 3.4bluepy >= 1.1.4 (BLE support. Linux only)NOTE) This library runs on python 3.5 or later.If you want to use it with python 2.7 in ROS, etc., please use 2.2.0.https://github.com/keigan-motor/pykeigan_motor/tree/2.2.0We recommend to update your KeiganMotor firmware to the latest as python script can cause error if it use new API commands.Update 2.4.0support both python2.7 and 3InstallationInstall from source:sudo apt install git
git clone https://github.com/keigan-motor/pykeigan_motor
cd pykeigan_motor
python setup.py install
# and to install BLE Support
    sudo apt-get install python-pip libglib2.0-dev
    sudo pip install bluepy
pip install .[ble]Install from PyPI:pip3 install pykeigan-motor
# or to install BLE Support
pip3 install pykeigan-motor[ble]NOTE) Use pip instead of pip3 in case of Python2.x or Windows OS.USB SerialTo connect your Keigan Motor through USB serial, you need to know the mounted path.
You can get the unique path of your Keigan Motor by:ls /dev/serial/by-id/Your Keigan Motor’s ID should be like ‘usb-FTDI_FT230X_Basic_UART_DM00XXXX-if00-port0’.
To use your Keigan Motor through USB serial, you need to add R/W permission to it.:sudo chmod 666 /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DM00XXXX-if00-port0Simplest Sample CodeRotate counter-clockwise with 1.0 rad/sec.frompykeiganimportusbcontrollerdev=usbcontroller.USBContoller('/dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DM00xxxx-if00-port0')dev.enable_action()dev.set_speed(1.0)dev.run_forward()examples/usb-simple-connection.pyBasic connection to the Motor.examples/usb-rotate-the-motor.pyRotate the Motor continuously and stop.examples/usb-position-control.pyRotate the Motor to the relative and absolute position.examples/usb-get-motor-Informations.pyAcquire the speed, position, torque and IMU values of the Motor.examples/usb-actuator.pyLet the Motor go and return for the specific distance.examples/usb-torque-control.pyDemonstration for a torque control. Increase the torque as you rotate the Motor by hand.examples/usb-teaching-control.pyLet the Motor record and playback your motion.BLE (for Linux Only)You need to know the MAC address of your Keigan Motor for BLE connection.For example, you can use the following simple script. Please run with sudo.KM1Scan.pyfrombluepy.btleimportScannerscanner=Scanner()devices=scanner.scan(5.0)fordevindevices:for(adtype,desc,value)indev.getScanData():ifdesc=="Complete Local Name"and"KM-1"invalue:print(value,":",dev.addr)Simplest Sample CodeRotate counter-clockwise with 1.0 rad/sec.frompykeiganimportblecontrollerdev=blecontroller.BLEController("xx:xx:xx:xx:xx")dev.enable_action()dev.set_speed(1.0)dev.run_forward()examples/ble-simple-connection.pyBasic connection to the Motor.examples/ble-scanner-connection.pyConnect to the Motor by BLE scanning.examples/ble-rotate-the-motor.pyRotate the Motor continuously and stop.examples/ble-get-motor-Informations.pyAcquire the speed, position, torque and IMU values of the Motor.Release NotesRelease 2.4.0Added support both python2 and 3 supportUpdate some examplesAdd reinit, reconnection during initializeRelease 2.2.5Respond to KeiganMotor firmware ver >= 2.40Bug fixesAdded serial reconnection feature(USB)Added some new APIsAdded some examplesRelease 2.1.0Added python 2 supportRelease 2.0.1Added APIs for reading and writing teaching dataAdded read_motion and write_motion_positionRelease 2.0.0Method Names RenewalAdded Debug ModeAdded Data Acquisition on USB serialAdded Windows and Mac Support for USB serial