{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Motors scan\n", "## Scan all ports to find the connected Dynamixel motors" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ports found ['/dev/ttyACM99']\n" ] } ], "source": [ "import pypot.dynamixel\n", "\n", "ports = pypot.dynamixel.get_available_ports()\n", "if not ports:\n", " raise IOError('no port found!')\n", "print 'ports found', ports" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Protocol is not the same for XL320 servomotors, set the using_XL320 flag to True if you use them.\n", "Set my_baudrate to the baudrate you are using (1000000 for motors already configured, 57600 for new ones)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "using_XL320 = False\n", "my_baudrate = 1000000" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the code below gives you an exception, try to restart all other notebooks that may be running, wait 5 seconds and try again." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/dev/ttyACM99\n", "scanning\n", "[]\n" ] } ], "source": [ "for port in ports:\n", " print port\n", " try:\n", " if using_XL320:\n", " dxl_io = pypot.dynamixel.Dxl320IO(port, baudrate=my_baudrate)\n", " else:\n", " dxl_io = pypot.dynamixel.DxlIO(port, baudrate=my_baudrate)\n", " \n", " print \"scanning\"\n", " found = dxl_io.scan(range(60))\n", " print found\n", " dxl_io.close()\n", " except Exception, e:\n", " print e" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![motor naming convention](./img/motor_naming_convention.jpg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Kill whoever uses the ports (should be used only as last chance try to free the ports)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os\n", "for port in ports:\n", " os.system('fuser -k '+port);" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }