<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2702475779139289733</id><updated>2024-09-12T03:30:53.915+01:00</updated><category term="imported modules"/><category term="making tea robotic arm"/><category term="maplin arm command control"/><category term="missing resetarm.dat"/><category term="optparse command line arguments python"/><category term="python"/><category term="python USB robotic arm maplin"/><category term="python linux mint license"/><category term="syntax highlighting python"/><category term="version 1.1 robotic arm python file csv reset origin zero"/><title type='text'>Poly&#39;s Python Projects</title><subtitle type='html'>A blog describing some projects in Python especially focussed on learning Python and controlling a low cost robotic USB arm.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-9042020288770308406</id><published>2013-01-15T21:09:00.001+00:00</published><updated>2013-01-15T21:09:03.691+00:00</updated><title type='text'>Useful extension</title><content type='html'>You will gather that other events have got in the way of this hobby project. &amp;nbsp;However there is an interesting development here:&amp;nbsp;http://mattdyson.org/projects/robotarm/ &amp;nbsp;which includes both controlling the arm from an XBox360 controller and provides a general class based on the orginal code here.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/9042020288770308406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2013/01/useful-extension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/9042020288770308406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/9042020288770308406'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2013/01/useful-extension.html' title='Useful extension'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-2946847713081752664</id><published>2012-01-30T23:37:00.000+00:00</published><updated>2012-01-30T23:37:16.197+00:00</updated><title type='text'>File structure</title><content type='html'>In response to a &lt;a href=&quot;http://python-poly.blogspot.com/2011/01/another-version.html?showComment=1327923941327#comment-c2347350460123955934&quot;&gt;comment &lt;/a&gt;asking for more detail on the csv file structure... ...here is some detail, my arm is not here right now so this is largely from memory and the notes I have and not tested:&lt;br /&gt;
&lt;br /&gt;
Each line in the file should consists of seven values separated by commas. &amp;nbsp;The first six values should be 0, 1 or 2. &amp;nbsp;The last value is a floating point value (e.g. 0.3).&lt;br /&gt;
&lt;br /&gt;
The first five values on each line indicate the direction that the shoulder, elbow, wrist, grip, rotation: 0 = no movement, 1=move in one direction, 2=move in the opposite direction.&lt;br /&gt;
&lt;br /&gt;
The sixth value should turns the light on (1) or off (0).&lt;br /&gt;
&lt;br /&gt;
The seventh value is the time in seconds that the motors should move at this combination of settings.&lt;br /&gt;
&lt;br /&gt;
The file can be created in any text editor (e.g. notepad, leafpad etc.), or probably in MS Excel etc (by saving as CSV).&lt;br /&gt;
&lt;br /&gt;
A file with the single line:&lt;br /&gt;
&lt;br /&gt;
1, 1, 1, 0, 0, 0 0.5&lt;br /&gt;
&lt;br /&gt;
Would move the shoulder, elbow &amp;amp; wrist motors of half a second with the light turned off.&lt;br /&gt;
&lt;br /&gt;
Whilst this line:&lt;br /&gt;
&lt;br /&gt;
0, 0, 0, 1, 1, 0, 0.75&lt;br /&gt;
&lt;br /&gt;
Would move the grip and turn the light on for 0.75 seconds.&lt;br /&gt;
&lt;br /&gt;
So the file:&lt;br /&gt;
&lt;br /&gt;
1, 1, 1, 0, 0, 0, 0.5&lt;br /&gt;
2, 2, 2, 0, 0, 1, 0.5&lt;br /&gt;
&lt;br /&gt;
Should move the shoulder, elbow &amp;amp; wrist motors of half a second with the light turned off, then move them back in the opposite direction for the same time - this time with the light on.&lt;br /&gt;
&lt;br /&gt;
Whilst this moves the arm one motor at a time, flashes the light then moves all motors back at the same time:&lt;br /&gt;
&lt;br /&gt;
1, 0, 0, 0, 0, 0, 0.6&lt;br /&gt;
0, 1, 0, 0, 0, 0, 0.6&lt;br /&gt;
0, 0, 1, 0, 0, 0, 0.6&lt;br /&gt;
0, 0, 0, 1, 0, 0, 0.6&lt;br /&gt;
0, 0, 0, 0, 1, 0, 0.6&lt;br /&gt;
0, 0, 0, 0, 0, 1, 1.0&lt;br /&gt;
0, 0, 0, 0, 0, 0, 0.5&lt;br /&gt;
0, 0, 0, 0, 0, 1, 1.5&lt;br /&gt;
0, 0, 0, 0, 0, 0, 0.25&lt;br /&gt;
0, 0, 0, 0, 0, 1, 0.65&lt;br /&gt;
0, 0, 0, 0, 0, 0, 0.33&lt;br /&gt;
2, 2, 2, 2, 2, 0, 0.6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope that helps any newcomers trying to set up files for the first time. &amp;nbsp;You should be able to copy and paste those examples into your own text editor. &amp;nbsp;You can call the file anything you want, and as you specify the extension you don&#39;t need to call it a .csv - but you may need to select the correct file format when saving.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/2946847713081752664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2012/01/file-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2946847713081752664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2946847713081752664'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2012/01/file-structure.html' title='File structure'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-4873693895556410596</id><published>2011-12-10T17:29:00.002+00:00</published><updated>2011-12-10T17:29:31.004+00:00</updated><title type='text'></title><content type='html'>Anyone looking for a graphic interface for controlling the arm in Linux (or potentially other platforms) should take a look here:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 15px; line-height: 18px;&quot;&gt;http://dl.dropbox.com/u/9418209/arm_control.py http://dl.dropbox.com/u/9418209/arm_gui.py&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 15px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: &#39;trebuchet ms&#39;, verdana, arial, sans-serif; font-size: 15px; line-height: 18px;&quot;&gt;Code developed by user Skimater and posted in one of the comments here.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/4873693895556410596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/12/anyone-looking-for-graphic-interface.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/4873693895556410596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/4873693895556410596'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/12/anyone-looking-for-graphic-interface.html' title=''/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-3277680265362838143</id><published>2011-12-10T17:26:00.000+00:00</published><updated>2011-12-10T17:26:29.661+00:00</updated><title type='text'>A quick update:</title><content type='html'>I&#39;ve obviously not been on for a while. &amp;nbsp;The USB robotic arm project has essentially stalled, mostly because I have nothing &quot;useful&quot; to do with the arm. &amp;nbsp;I think without combining it with some clever machine vision stuff its not going to be much use other than as a pure gizmo/toy. &amp;nbsp;It was however fun trying, but I&#39;m too busy with other projects right now to focus on this. &amp;nbsp;If anyone does have any problems etc with the code I&#39;ve written I am happy to see if I can help though.&lt;br /&gt;
&lt;br /&gt;
Hopefully there will be some more interesting Python projects in the future which will let me resuscitate the blog!</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/3277680265362838143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/12/quick-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/3277680265362838143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/3277680265362838143'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/12/quick-update.html' title='A quick update:'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-6582178201559894263</id><published>2011-01-28T20:15:00.000+00:00</published><updated>2011-01-28T20:15:18.477+00:00</updated><title type='text'>Backlash!</title><content type='html'>Well, its been over a week since I last updated the blog, but in the meantime I&#39;ve not been completely ignoring the code.&amp;nbsp; I&#39;ve added some improvements and will &quot;release&quot; an improved version with better error trapping in the next few days.&amp;nbsp; But I have encountered a problem!&amp;nbsp; Basically the backlash in the motors/gearboxes is such that moving the arm for 2 seconds in one direction is not &quot;undone&quot; by moving it for the same time in the opposite direction.&amp;nbsp; I&#39;m researching at the moment to see if the error is &quot;per command&quot;, start/stop related or directional (e.g. gravity) etc.&amp;nbsp; Once I understand the error I&#39;ll try to mitigate it (it probably won&#39;t be perfect but it has to be better than I get right now).&amp;nbsp; Anyone found interesting ways to do this?</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/6582178201559894263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/backlash.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6582178201559894263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6582178201559894263'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/backlash.html' title='Backlash!'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-2292172344829401289</id><published>2011-01-19T22:04:00.000+00:00</published><updated>2011-01-19T22:04:10.737+00:00</updated><title type='text'>So the &quot;main bit&quot;...</title><content type='html'>So what&#39;s going on in main() then?&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;def main() :

&amp;nbsp;&amp;nbsp;&amp;nbsp; options=parse_commandline()
&amp;nbsp;&amp;nbsp;&amp;nbsp; resetdata=get_resetdata()&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; dev=connecttoarm() &lt;/pre&gt;&lt;br /&gt;
These statements, do the following:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Gather the command line options work out what they are meant to do and store the details in options.&amp;nbsp; Its does this by calling the parse_commandline() function.&lt;/li&gt;
&lt;li&gt;Get the contents of the resetarm.dat file (by calling the get_resetdata() function).&amp;nbsp; &lt;a href=&quot;http://python-poly.blogspot.com/2011/01/missing-resetarmdat-file.html&quot;&gt;Resetarm.dat file is explained a bit here&lt;/a&gt;, but is basically a little cheat that allows us to &quot;remember&quot; where the arm is.&amp;nbsp; The file is not particularly human readable because the pickle function isn&#39;t intended to be easy to read.&amp;nbsp; However the pickle function is effectively storing a python dictionary who&#39;s keys are each of the motor names and who&#39;s values are the time in seconds that the motor has been running (with positive values in one direction and negative in the other).&amp;nbsp; The data is stored within the program in the &quot;dictionary&quot; resetdata&lt;/li&gt;
&lt;li&gt;Calls the connect to arm function, finds our device and allocated the details to the &quot;handle&quot; dev - so we can refer to it elsewhere.&lt;/li&gt;
&lt;/ul&gt;&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if options.filename!=None :

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; filehandle=csv.reader(open(options.filename,&#39;rb&#39;), delimiter=&#39;,&#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp; # opens the resetarm file to read

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in filehandle:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rownumeric=[]
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for each in row[:6]: rownumeric.append(int(each))
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; command=buildcommand(*rownumeric[:6])
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if sendcommand(dev,command)&amp;lt;&amp;gt;3 : print &quot;Possible error sending data&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rownumeric.append(float(row[6]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; time.sleep(rownumeric[6])
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ## need to increment reset file positions!
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sendcommand(dev)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # create dictionary from values
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; datadict=dict(zip([&#39;shoulder&#39;,&#39;elbow&#39;,&#39;wrist&#39;,&#39;grip&#39;,&#39;rotate&#39;],rownumeric[:6]))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resetdata=store_reset_values(datadict, resetdata, rownumeric[6]) &lt;/pre&gt;&lt;br /&gt;
This group of commands are only run if the command line options passed in a filename.&amp;nbsp; If there is a filename, the file is opened (using the csv function).&amp;nbsp; Then for each row in the file, we read it in, convert the values to integers (they should be 0,1 or 2 for off, up, down etc on the motor).&amp;nbsp; The command in the csv file should be in the correct order (shoulder, elbow, wrist, grip, rotate, light and time (time being a floating point value)) so there is no need for any &quot;clever&quot; dictionary type stuff.&amp;nbsp; These first 5 parameters are passed to &quot;build command&quot; which turns each 0,1,2 value into the 3 bytes which are sent to the arm to control it.&amp;nbsp; This command is then sent to our device.&amp;nbsp; If the command is successfully sent it returns &quot;3&quot; for the number of bytes written; there is a basic error trap here in case of failure.&amp;nbsp; The software then waits for the time defined in the final parameter on that line of the csv file.&amp;nbsp; Then sends a &quot;0&quot; command to the device to stop all the motors.&amp;nbsp; The &quot;zip&quot; function is then used to zip the &quot;keys&quot; and the &quot;values&quot; together, these are then added to the &quot;resetdata&quot; so that it can be stored for later recall.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif options.reset_to_origin==True :

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for key in resetdata : 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if resetdata[key]&amp;lt;0 :
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; move_to_reset(dev, key, 1, abs(resetdata[key]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; elif resetdata[key]&amp;gt;0 :
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; move_to_reset(dev, key, 2, abs(resetdata[key]))
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; zeroreset() &lt;/pre&gt;&lt;br /&gt;
These commands are only processed if the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-o&lt;/span&gt; option is used on the command line.&amp;nbsp; (As its an elif statement it is not run if the file option has been run).&amp;nbsp; They read in the data stored in resetarm.dat file, and then move each of the motors in the right direction to bring it back to the origin.&amp;nbsp; Then it sets the resetarm.dat values to zero (by calling our zeroreset() function).&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif options.zero==True :

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; zeroreset()&amp;nbsp;&amp;nbsp;&amp;nbsp; # zero the values in the reset file.&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/pre&gt;&lt;br /&gt;
If the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-z &lt;/span&gt;command line option was used (and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-f &lt;/span&gt;or &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-o&lt;/span&gt; were not) then it resets the values in resetarm.dat to zero.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If none of the z/o/f command options were used then this code is run instead:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else :



&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; command=buildcommand(&amp;nbsp;&amp;nbsp;&amp;nbsp; shoulder=options.shoulder,

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; elbow=options.elbow,

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; wrist=options.wrist,

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; grip=options.grip,

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rotate=options.rotate,

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; light=options.light)

&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if sendcommand(dev,command)&amp;lt;&amp;gt;3 : print &quot;Possible error sending data&quot;



&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resetdata=store_reset_values(options.__dict__, resetdata, options.timedelay)



&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; time.sleep(options.timedelay)

&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sendcommand(dev)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #turn off!

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; dev.reset() &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #reset USB port (no need to release?)&amp;nbsp;&lt;/pre&gt;These commands essentially do the same as the data read in from the file but using the data provided at the command prompt - this makes them slightly more complicated as they aren&#39;t necessarily supplied in the &quot;correct&quot; order to feed directly to the &quot;build command&quot; function based on their position and so have to be passed with their names.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
That lot has taken a bit longer to write than I expected so I don&#39;t think I&#39;ll detail each function at this stage - as they are all subject to change.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/2292172344829401289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/so-main-bit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2292172344829401289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2292172344829401289'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/so-main-bit.html' title='So the &quot;main bit&quot;...'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-2880200053550233714</id><published>2011-01-19T21:22:00.000+00:00</published><updated>2011-01-19T21:22:33.292+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="imported modules"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>What&#39;s going on &quot;under the hood&quot;</title><content type='html'>I&#39;ve been asked to explain a little about what is going on behind the scenes in the program.&amp;nbsp; As everything is still in development I won&#39;t go into too much detail because there are various bits and pieces that I want to add which might result in changes to this code, but at the same time it might help if you knew roughly what the thinking was (if there was any!) behind what I wrote.&lt;br /&gt;
&lt;br /&gt;
I thought the best thing to do was &quot;walk through&quot; the main program (i&#39;m talking about &lt;a href=&quot;http://python-poly.blogspot.com/2011/01/another-version.html&quot;&gt;v1.1, released here&lt;/a&gt;) and come back to discuss the various other functions in later posts.&lt;br /&gt;
&lt;br /&gt;
Firstly some basics for anyone really new to python:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# Python control for Maplin Robotic Arm
# v 1.1 (c) Neil Polwart 2011


import usb.core, sys, time, optparse, pickle, csv &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The real basics: the &lt;b&gt;#&lt;/b&gt; symbol is used in python for comments - the program ignores anything that follows it on this line.&amp;nbsp; These comments are either to remind myself of what something does or to help you follow it (or hopefully both).&lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;import&lt;/b&gt; command calls in other modules that this program uses, effectively saving writing complex code from scratch each time.&amp;nbsp; The modules that the program imports are:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pyusb.sourceforge.net/docs/1.0/tutorial.html&quot;&gt;&lt;b&gt;usb.core&lt;/b&gt;&lt;/a&gt; - the module which lets us communicate with the USB port.&amp;nbsp; This is part of the pyUSB package which you need to install.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.python.org/library/sys.html&quot;&gt;&lt;b&gt;sys&lt;/b&gt;&lt;/a&gt; - imports some basic commands that allow communication with the system, e.g. command line, inputs-outputs, etc... however I don&#39;t think its actually being used (it was in a prototype when I was playing around) - so it might vanish in an update!&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.python.org/library/time.html&quot;&gt;&lt;b&gt;time&lt;/b&gt;&lt;/a&gt; - imports &quot;time&quot; functions - which,l not surprisingly measure time, introduce delays etc.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://docs.python.org/library/optparse.html&quot;&gt;optparse&lt;/a&gt; &lt;/b&gt;-&lt;b&gt; &lt;/b&gt;is a clever module which parses (gathers, chops up and allocates) the command line options and values&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.python.org/library/pickle.html&quot;&gt;&lt;b&gt;pickle&lt;/b&gt;&lt;/a&gt; - is another smart module from python&#39;s inbuilt libraries which lets you move chunks of data around rather easily - especially for loading and dumping variables to a file&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.python.org/library/csv.html&quot;&gt;&lt;b&gt;csv&lt;/b&gt;&lt;/a&gt; - is a module specifically for importing and exporting comma separated value files&lt;br /&gt;
&lt;br /&gt;
Each of the links above points to some detailed documentation about the relevant module.&lt;br /&gt;
&lt;br /&gt;
As per convention the program calls the main() function via the line lurking right at the end of the file:&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;if __name__== &#39;__main__&#39;:main() &lt;/pre&gt;&lt;br /&gt;
This will only directly run the main function if the program is run from the command line (or interpreter) but not if &quot;imported&quot; as part of another module.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/2880200053550233714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/whats-going-on-under-hood.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2880200053550233714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2880200053550233714'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/whats-going-on-under-hood.html' title='What&#39;s going on &quot;under the hood&quot;'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-5972795443583798116</id><published>2011-01-18T09:05:00.000+00:00</published><updated>2011-01-18T09:05:57.191+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="missing resetarm.dat"/><title type='text'>Missing resetarm.dat file</title><content type='html'>If you are trying to use&lt;a href=&quot;http://python-poly.blogspot.com/2011/01/another-version.html&quot;&gt; v1.1 (&#39;released&#39; here)&lt;/a&gt; then you will have discovered the &quot;missing resetarm.dat file&quot; bug that &lt;a href=&quot;http://python-poly.blogspot.com/2011/01/amazing-uptake-level.html&quot;&gt;Skimitar talks about here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The quick fix!&lt;/b&gt; &lt;br /&gt;
&lt;br /&gt;
The simplest fix is to &lt;a href=&quot;https://docs.google.com/leaf?id=0B4GQHcFbRPW4M2NhM2U4MzAtYmY0NC00YjFhLTg2NGYtMmY0ZDMwZDBmOWQx&amp;amp;sort=name&amp;amp;layout=list&amp;amp;num=50&quot;&gt;download the file from here&lt;/a&gt; and put it in the same directory as the arm_1_1.py file. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Why does it need this file?&lt;/b&gt;&lt;br /&gt;
One of the irritations about using the arm is that after many commands you often want it to go &quot;back to the start&quot; - either because you&#39;ve gone off in the wrong direction or because you&#39;ve completed the task you were trying to do.&amp;nbsp; There is no &quot;reset&quot; command built into the arm, indeed the arm is totally unaware of its current position, so to &quot;undo&quot; the movement we need to keep track of the current position.&amp;nbsp; The program does this by holding each motor position in a python dictionary which it then &quot;dumps&quot; to a file (so that it remains &#39;persistent&#39; beyond this session of the program).&amp;nbsp; Next time the program is run it loads the position as its starting position.&amp;nbsp;&amp;nbsp; When you then want to &quot;reset&quot; the arm you simply run it with the command line switch &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-o&lt;/span&gt; and it reverses total movement accumulated since its last reset. This seems to work quite well - although there is backlash in the motors and if you &quot;overrun&quot; any of the motors it will get confused - as a result sometimes you will need to manually adjust it and then &quot;zero&quot; the reset position using the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-z&lt;/span&gt; command line option.&amp;nbsp; I&#39;m going to explain how each bit of the software was intended to work in a series of blog posts tonight and tomorrow - so watch this space for more info.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The long term fix&lt;/b&gt;&lt;br /&gt;
The next release will include exception trapping for this missing file which will enable the program to skip the read instruction if the file is missing.&lt;b&gt; &lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/5972795443583798116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/missing-resetarmdat-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5972795443583798116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5972795443583798116'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/missing-resetarmdat-file.html' title='Missing resetarm.dat file'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-8637481816996756985</id><published>2011-01-18T00:26:00.000+00:00</published><updated>2011-01-18T00:26:41.116+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="making tea robotic arm"/><title type='text'>Amazing uptake level!</title><content type='html'>I wasn&#39;t sure anyone would be interested in this blog or my python progs - but it seems I am wrong and even my early stage experiments are attracting some interest!&amp;nbsp; Someone has even gone as far as using my code as the basis for making a cup of tea:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/9brZBb2r7II?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Which perhaps isn&#39;t the most exciting video in the world! But I&#39;m feeling good that my code has helped someone else have some fun!&amp;nbsp; So if the code is helping you send my your videos, suggestions for improvement, feature requests or just let me know what you are up to!&amp;nbsp;&amp;nbsp; Oh - and I also want to hear your bugs as I&#39;ve only got time for very limited testing.&lt;br /&gt;
&amp;nbsp;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/8637481816996756985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/amazing-uptake-level.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8637481816996756985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8637481816996756985'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/amazing-uptake-level.html' title='Amazing uptake level!'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-6402438838980913566</id><published>2011-01-18T00:05:00.001+00:00</published><updated>2011-01-18T09:08:11.153+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="version 1.1 robotic arm python file csv reset origin zero"/><title type='text'>Another version...</title><content type='html'>Well, we now have v1.1 &lt;a href=&quot;https://docs.google.com/leaf?id=0B4GQHcFbRPW4NDNlYmM4NWQtYzNlNS00MDE3LTkxYjQtOTkzMjI3OWIxYjVl&amp;amp;sort=name&amp;amp;layout=list&amp;amp;num=50&quot;&gt;(download here)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://python-poly.blogspot.com/2011/01/coming-soon.html&quot;&gt;As predicted&lt;/a&gt; this introduces a number of new features which I will discuss in more detail in separate posts over the next day or two.&amp;nbsp; The help screen (&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python arm_1_1.py --help&lt;/span&gt;) will provide general guidance for anyone itching to get going!&lt;br /&gt;
&lt;br /&gt;
I&#39;ve tidied up a few bits of the code into separate functions which I&#39;ll write about in coming days in case anyone wished to call them from their own code.&lt;br /&gt;
&lt;br /&gt;
There is still very little error/exception handling built in so be aware that this may crash the program unexpectedly!&amp;nbsp; You should also beware that there is nothing to stop you running the motor continuously at the limit of its range and screwing up the gearbox.&amp;nbsp; I&#39;m toying with the idea of adding some &quot;safety checks&quot; to prevent this - would that be useful or too restrictive?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Tip:&lt;/b&gt; if you do end up with the motor running continuously and need it to stop then simply run the program with no command line switches.&lt;br /&gt;
&lt;br /&gt;
The key new features are:&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; -f FILENAME, --file=FILENAME&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path/name of a file describing a sequence arm&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movements&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; -o, --origin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Restore arm to the &#39;origin&#39; position&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; -z, --zero&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Zero all values in resetarm file&#39; position&lt;/blockquote&gt;Firstly these options are all mutually exclusive, and applied in the priority order given above, using any of these options also ignores any of the individual motor controls (i.e. if &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-f somefile.txt&lt;/span&gt; is used, it will ignore any other options). &lt;br /&gt;
&lt;br /&gt;
I suggest you move your arm to some sensible origin point (midway on all motors?) and then run &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python arm_1_1.py  -z &lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;to define this position as &quot;zero&quot;.&amp;nbsp; Now when you run commands (with the s,e,w,g,r, and f options) the program will store the movement details, and this can then be reversed by running &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python  arm_1_1.py -&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;o to bring the arm back to this start point.&amp;nbsp; Beware if you get the dreaded &quot;click click click of the motor going &#39;too far&#39; the software is unaware of this and will &quot;overshoot&quot; on returning to origin.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;-f&lt;/span&gt; option calls a file with comma separated values listed as values of 0,1,2 for shoulder, elbow, wrist, grip, rotate, light and a floating point value for time.&amp;nbsp; Multiple lines may be included.&amp;nbsp; All parameters must be present and must be in the correct order.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;i&gt;&lt;b&gt;EDIT: &lt;/b&gt;NOTE: Please read &lt;a href=&quot;http://python-poly.blogspot.com/2011/01/missing-resetarmdat-file.html&quot;&gt;this post&lt;/a&gt; too - you will also need this file.&lt;/i&gt; &lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/6402438838980913566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/another-version.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6402438838980913566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6402438838980913566'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/another-version.html' title='Another version...'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-6089962189256108522</id><published>2011-01-17T15:53:00.000+00:00</published><updated>2011-01-17T15:53:23.394+00:00</updated><title type='text'>Coming soon...</title><content type='html'>Since we seem to have gathered a dozen or so readers in only a few days I thought it might be useful to know what I have in the pipeline.&lt;br /&gt;
&lt;br /&gt;
The next version (1.1) will include:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;The ability to process a file (csv?) which will contain a list of commands&lt;/li&gt;
&lt;li&gt;The ability to reset the arm to an &quot;origin&quot; position / reference point with a single instruction &lt;/li&gt;
&lt;/ol&gt;If the coding goes smoothly these features may go live late tonight.&lt;br /&gt;
&lt;br /&gt;
Subsequent versions will include:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;a graphical user interface (windows type interface)&lt;/li&gt;
&lt;li&gt;better error trapping&lt;/li&gt;
&lt;li&gt;the ability to teach the arm a series of commands and then have then repeated back&lt;/li&gt;
&lt;li&gt;A library / module intended for others to call / import and use in their own program. &lt;/li&gt;
&lt;/ul&gt;These may not happen in that order, and I don&#39;t know how long each will take.&lt;br /&gt;
&lt;br /&gt;
What other features would be useful/helpful?</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/6089962189256108522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/coming-soon.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6089962189256108522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/6089962189256108522'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/coming-soon.html' title='Coming soon...'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-5962850439868974804</id><published>2011-01-17T10:02:00.000+00:00</published><updated>2011-01-17T10:02:06.247+00:00</updated><title type='text'>Why the adverts?</title><content type='html'>The adverts in the blog are as much an experiment as the software itself!&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
I&#39;m intrigued to see how much &#39;revenue&#39; a &lt;a href=&quot;https://www.google.com/adsense/&quot;&gt;Google AdSense&lt;/a&gt; can bring to a small niche blog.&amp;nbsp; Likewise I&#39;ve registered for &lt;a href=&quot;https://affiliate-program.amazon.com/&quot;&gt;Amazon Associates&lt;/a&gt;.&amp;nbsp; The site isn&#39;t costing me anything (except time) so doesn&#39;t need to make money.&amp;nbsp; But I&#39;ve been advertising through Google Ads in &lt;a href=&quot;http://www.hydrosense.biz/&quot;&gt;my day job&lt;/a&gt; for sometime, and wondered how the experience is on the other side.&amp;nbsp; Amazon Associates - seems logical since I will from time-to-time mention books here anyway.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/5962850439868974804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/why-adverts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5962850439868974804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5962850439868974804'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/why-adverts.html' title='Why the adverts?'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-5796267644821032020</id><published>2011-01-16T20:11:00.002+00:00</published><updated>2011-01-17T09:05:44.089+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="optparse command line arguments python"/><title type='text'>Parsing commands from the command prompt</title><content type='html'>&lt;a href=&quot;http://www.amazon.com/Beginning-Python-Professional-Magnus-Hetland/dp/159059519X?ie=UTF8&amp;amp;tag=polwart-21&amp;amp;link_code=btl&amp;amp;camp=213689&amp;amp;creative=392969&quot; target=&quot;_blank&quot;&gt;Beginning Python: From Novice to Professional&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;http://www.assoc-amazon.com/e/ir?t=polwart-21&amp;amp;l=btl&amp;amp;camp=213689&amp;amp;creative=392969&amp;amp;o=1&amp;amp;a=159059519X&quot; style=&quot;border: medium none ! important; margin: 0px ! important; padding: 0px ! important;&quot; width=&quot;1&quot; /&gt; whilst an excellent and lengthy book doesn&#39;t cover in any detail parsing commands from the command prompt (whilst it tells us optparse exists - it doesn&#39;t have the space to explain how to use it).&amp;nbsp; The &lt;a href=&quot;http://docs.python.org/library/optparse.html&quot;&gt;Python Documentation&lt;/a&gt; whilst detailed is &quot;hard work&quot; - and I&#39;ve now discovered a much &lt;a href=&quot;http://www.alexonlinux.com/pythons-optparse-for-human-beings&quot;&gt;better tutorial on optparse&lt;/a&gt; - which will enable some refinement of the next iteration of software.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/5796267644821032020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/parsing-commands-from-command-prompt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5796267644821032020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5796267644821032020'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/parsing-commands-from-command-prompt.html' title='Parsing commands from the command prompt'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-8329210730539704786</id><published>2011-01-16T16:50:00.000+00:00</published><updated>2011-01-16T16:50:43.280+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maplin arm command control"/><title type='text'>New version!</title><content type='html'>Well the code I posted earlier was just about the simplest control you could have for the robotic arm.&amp;nbsp; I&#39;ve been playing around tidying it up a lot into some functions and have just tested a new version.&amp;nbsp; Its far from perfect - but I think it represents the next milestone in development: the arm movement is defined through a series of command line arguments / switches.&amp;nbsp; You can &lt;a href=&quot;https://docs.google.com/leaf?id=0B4GQHcFbRPW4NjQ3NGEzZGYtYjNkOC00MDgxLWE1MmEtMGVkOTQ0YzAxZWUz&amp;amp;hl=en&quot;&gt;download the file here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The simplest way to understand how to use it (as a user rather than a programmer) will be to run the following command:&lt;br /&gt;
&lt;blockquote&gt;python arm_1.py --help&lt;/blockquote&gt;&amp;nbsp;which will bring up something like:&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp;Python program for connecting to USB Robotic Arm&lt;br /&gt;
Usage: arm_1.py [options]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&amp;nbsp; -h, --help&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; show this help message and exit&lt;br /&gt;
&amp;nbsp; -s SHOULDER, --shoulder=SHOULDER&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value 0,1,2 for shoulder motor (off/up/down)&lt;br /&gt;
&amp;nbsp; -e ELBOW, --elbow=ELBOW&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value 0,1,2 for elbow motor (off/up/down)&lt;br /&gt;
&amp;nbsp; -w WRIST, --wrist=WRIST&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value 0,1,2 for wrist motor (off/up/down)&lt;br /&gt;
&amp;nbsp; -g GRIP, --grip=GRIP&amp;nbsp; Value 0,1,2 for grip (off/in/out)&lt;br /&gt;
&amp;nbsp; -r ROTATE, --rotate=ROTATE&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value 0,1,2 for rotation (off/cw/ccw)&lt;br /&gt;
&amp;nbsp; -l LIGHT, --light=LIGHT&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value 0,1 for light (on/off)&lt;br /&gt;
&amp;nbsp; -t TIMEDELAY, --time=TIMEDELAY&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Time (s) to wait before off default0.1&lt;/blockquote&gt;So e.g. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python arm_1.py -g 1 -w 2&lt;/span&gt; will close the gripper and move the wrist down simultaneously for 0.1 seconds.&amp;nbsp; Whilst &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python arm_1.py -r 2 -l 1 -t 3&lt;/span&gt; will rotate the arm in the base counter clockwise and turn the light on for 3 seconds.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;NOTE&lt;/b&gt; Depending on how you have your user privilidges set up you may not have access to the USB port - I need to run all these commands as root, e.g. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;sudo python arm_1...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;ui-datepicker-div&quot; style=&quot;display: none;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/8329210730539704786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/new-version.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8329210730539704786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8329210730539704786'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/new-version.html' title='New version!'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-1225814469203186922</id><published>2011-01-16T13:17:00.001+00:00</published><updated>2011-01-16T13:22:02.786+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="syntax highlighting python"/><title type='text'>Syntax highlighting</title><content type='html'>I&#39;ve added Syntax Highlighting to the blog using the method described here: &lt;a href=&quot;http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html&quot;&gt;http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html&lt;/a&gt; which should help with readability.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/1225814469203186922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/syntax-highlighting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/1225814469203186922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/1225814469203186922'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/syntax-highlighting.html' title='Syntax highlighting'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-1935427898449688400</id><published>2011-01-16T10:09:00.000+00:00</published><updated>2011-01-16T10:09:59.619+00:00</updated><title type='text'>Some basic troubleshooting</title><content type='html'>I&#39;m no expert in USB or Linux, but here are a few debugging things which might be useful for others trying to get the arm working.&lt;br /&gt;
&lt;br /&gt;
1.&amp;nbsp; Is it switched on!&amp;nbsp; Without the switch in the on position the device won&#39;t show up - should be obvious but is of course worth checking!&amp;nbsp; I also think if you leave it on doing nothing it seems to switch itself off (although thats an assumption because it seemed to need &quot;reset&quot; this morning).&amp;nbsp; This also means that dead batteries will presumably mean no response from the device.&lt;br /&gt;
&lt;br /&gt;
2. &amp;nbsp; Run &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;lsusb&lt;/span&gt; at the command prompt.&amp;nbsp; You should see something like this amongst the response:&lt;br /&gt;
&lt;blockquote&gt;Bus 002 Device 022: ID 1267:0000 Logic3 / SpectraVideo plc &lt;/blockquote&gt;3. If you are having problems then the command &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;dmesg&lt;/span&gt; may help diagnose the problem, although where to start may not be easy - but here&#39;s what a working system reports with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;dmesg | grep USB&lt;/span&gt; reports:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;[ 1845.033134] usb 2-1: new low speed USB device using uhci_hcd and address 4&lt;/blockquote&gt;If you disconnect the cable and run again you will then see &lt;br /&gt;
&lt;blockquote&gt;[ 1952.176133] usb 2-1: USB disconnect, address 4&lt;/blockquote&gt;4. If the light works but the motors don&#39;t (this happened to me) it is probably a wiring problem.&amp;nbsp; In my case the single orange wire had come disconnected from the &quot;pins&quot; on the board and just needed slipped back on.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/1935427898449688400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/some-basic-troubleshooting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/1935427898449688400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/1935427898449688400'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/some-basic-troubleshooting.html' title='Some basic troubleshooting'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-5287005982292143293</id><published>2011-01-16T09:17:00.004+00:00</published><updated>2011-01-16T13:20:17.639+00:00</updated><title type='text'>The simplest code!</title><content type='html'>Here is a very simple python code which will let you control the arm:&lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;python&quot;&gt;# Minimalist version of USB arm control to show how simple it could be! (c) N Polwart,&amp;nbsp; 2011

import usb.core, time

dev = usb.core.find(idVendor=0x1267, idProduct=0x0000)
if dev is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise ValueError(&#39;Device not found&#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # if device not found report an error

dev.set_configuration()

datapack=0x40,0,0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # change this to vary the movement
bytesout=dev.ctrl_transfer(0x40, 6, 0x100, 0, datapack, 1000)

time.sleep(1)&amp;nbsp;&amp;nbsp;&amp;nbsp; # waits for 1 second whilst motors move.

datapack=0,0,0
bytesout=dev.ctrl_transfer(0x40, 6, 0x100, 0, datapack, 1000)&lt;/pre&gt;&lt;br /&gt;
A version with some more detailed comments / documentation and user feedback when it runs is available to &lt;a href=&quot;https://docs.google.com/uc?id=0B4GQHcFbRPW4MGZkYWYzZTYtODlkMi00OTFjLTg1NTYtMzI1Mzc1ZDU4MDNj&amp;amp;export=download&amp;amp;hl=en&quot;&gt;download arm_0.py&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
There programs all require the pyUSB library - which can be downloaded from sourceforge.&amp;nbsp;&lt;a href=&quot;http://sourceforge.net/projects/pyusb/files/PyUSB%201.0/1.0.0-alpha-1/pyusb-1.0.0-a1.zip/download&quot;&gt; This is the version I am using.&lt;/a&gt;&amp;nbsp; Download it, extract the zip file and run &quot;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;python setup.py install&lt;/span&gt;&quot; and it should be done.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/5287005982292143293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/simplest-code.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5287005982292143293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/5287005982292143293'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/simplest-code.html' title='The simplest code!'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-8920329688021581150</id><published>2011-01-16T01:41:00.001+00:00</published><updated>2011-01-16T01:45:08.021+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python linux mint license"/><title type='text'>Why Python? Why Linux?</title><content type='html'>Since the whole raison d&#39;etre for this blog is that I&#39;m teaching myself Python it might make sense to explain why!&amp;nbsp; I&#39;ve programmed in one form or another right back to my first home computer - a &lt;a href=&quot;http://en.wikipedia.org/wiki/Sinclair_Spectrum&quot;&gt;48k Spectrum&lt;/a&gt; back in the early 1980s - generally speaking all simple programs to address a specific need I had at the time.&amp;nbsp; As a result I&#39;ve ended up with a basic understanding of &lt;a href=&quot;http://en.wikipedia.org/wiki/BASIC&quot;&gt;BASIC&lt;/a&gt; (several variants including Visual Basic and VBA),&lt;a href=&quot;http://en.wikipedia.org/wiki/COMAL&quot;&gt; COMAL&lt;/a&gt; (a language used mainly in schools for teaching (and possibly not at all any more!), &lt;a href=&quot;http://en.wikipedia.org/wiki/C%2B%2B&quot;&gt;C++&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Object_Pascal&quot;&gt;Delphi&lt;/a&gt; (Pascal), &lt;a href=&quot;http://en.wikipedia.org/wiki/Javascript&quot;&gt;Javascript&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Fortran&quot;&gt;Fortran&lt;/a&gt; which combined gives you the ability to read most languages.&amp;nbsp; However I am far from an expert in any of them - so when I needed to write a program to control a serial device from either a Linux or Windows computer I started exploring the options.&amp;nbsp; After some searching it became clear that this could involve a bit of effort porting across platforms - and even C++ which is routinely &quot;offered&quot; on both platforms was likely to throw up problems with needing different serial libraries.&amp;nbsp; I was then introduced to &lt;a href=&quot;http://www.python.org/&quot;&gt;Python&lt;/a&gt; and clicked with it immediately - perhaps those early days with BASIC and COMAL interpretters on a Spectrum and &lt;a href=&quot;http://en.wikipedia.org/wiki/BBC_Micro&quot;&gt;BBCB&lt;/a&gt; convinced my of the advantages of Interpretted languages!&amp;nbsp; When my 7 year old son declared he&#39;d like to write a program I chose Python and he was learning the elementary steps quickly - with none of the pain involved in compiling etc, but I had also seen some of the really advanced features and impressive programs which had been written in Python and I was convinced.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
So why do I want to program in both Linux and Windows.&amp;nbsp; Firstly let me say whilst I am pretty computer literate and reasonably confident with most things I am not a serious Linux geek!&amp;nbsp; I&#39;m also not a Windows/Microsoft hater, but I do get frustrated when computers which ran fine when they were new slow down amongst clutter either legitimately added by users or malware acquired through use.&amp;nbsp; I started off my experiments with Linux a couple of years ago using PCLinuxOS to overcome this and enable me to use a really cheap PC and whilst I found some things worked really well - I also found a few things incredibly frustrating - in particular doing anything &quot;non standard&quot; as the &lt;a href=&quot;http://www.pclinuxos.com/&quot;&gt;PCLinuxOS&lt;/a&gt; philosophy is not to tweek the OS in case you break it.&amp;nbsp; One day I did break it and rather than reinstall PCLinuxOS decided to try &lt;a href=&quot;http://www.linuxmint.com/&quot;&gt;Mint&lt;/a&gt; - a different distribution of Linux which is also designed to be really simple to use, especially for people migrating from Windows.&amp;nbsp; Mint was amazing and essentially everything (except an old webcam I have) works out the box and just how you would expect it to!&amp;nbsp; I&#39;ve also got a netbook (&lt;a href=&quot;http://www.reghardware.com/2008/08/18/review_acer_aspire_one/&quot;&gt;Acer Aspire A110&lt;/a&gt;) which until recently was running the Linpus Linux OS that came with it - but has just been moved onto the Mint LXDE distribution.&amp;nbsp; Mint is based on &lt;a href=&quot;http://www.ubuntu.com/&quot;&gt;Ubuntu&lt;/a&gt; (the most popular distribution of Linux) - so if something I suggest works for me in Mint it will almost certainly work on native Ubuntu too.&amp;nbsp; In fact it will probably work on any Linux as it will be unusualy for me to be doing anything too clever!&lt;br /&gt;
&lt;br /&gt;
Whilst I like Mint, and almost never have to go back to Windows for normal home or office tasks, it would be niave to ignore the huge number of machines running Windows, and I have some scientific apparatus which only runs in Windows - so any code I need to run there also needs to run in Windows too.&lt;br /&gt;
&lt;br /&gt;
I&#39;ll start off this project with the following basic assumptions about anyone who wants to borrow, use or modify my code:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;You are running Linux.&amp;nbsp; The code should port to Windows (or other systems) with minimum effort - but at this stage I&#39;m only writing it with Linux in mind.&amp;nbsp; A &quot;next step&quot; will be to make it cross platform!&lt;/li&gt;
&lt;li&gt;You already have Python installed.&amp;nbsp; This is probably the case if you are using Linux but if not then it should be readily available via apt / yum / synaptic or whichever package manager you use.&amp;nbsp; e.g. something like:&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; sudo apt-get install python&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;I&#39;m using version 2.6 of Python - I can&#39;t guarantee backwards compatibility but will highlight anything that becomes obvious to me as an issue.&amp;nbsp; The change to Python v3 involves some major differences.&amp;nbsp; I see it as a future project to check and fix any forward compatibility issues (probably once v3 is finalized and a bit more established).&lt;/li&gt;
&lt;li&gt;I assume you already know (or will work out) how to use Python, and edit the source code files etc.&amp;nbsp; I intend as things develop to produce a &quot;distributable&quot; version which will allow any old person to install and run my code - but the early stuff will all by simply *.py files and you&#39;ll need to install libraries etc if they are missing (anything I need to download I&#39;ll briefly describe how/where).&lt;/li&gt;
&lt;li&gt;You&#39;ll recognise this is a work in progress, from someone developing their knowledge so it comes without any guarantees or promises it can be made to work on your system.&amp;nbsp; If you want to be confident you can get your robot arm to work use the software supplied by the manufacturer and run it in Windows!&amp;nbsp; Documentation will not be at a &quot;professional&quot; level!&lt;/li&gt;
&lt;li&gt;This is a bit of fun and learning for me.&amp;nbsp; If you want to use the code feel free.&amp;nbsp; If you want to modify the code feel free.&amp;nbsp; If it is being published or used in a public arena then I&#39;d ask for an acknowledgement in the source code and on any &quot;credits&quot;. If you make improvements then why not send me the code (or post it in a comment) and then it can be shared here for everyone to see.&amp;nbsp; In the unlikely event you think there is money to be made from this (or a derivative of it) then please get in touch and we can formalise license terms.&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/8920329688021581150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/why-python-why-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8920329688021581150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/8920329688021581150'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/why-python-why-linux.html' title='Why Python? Why Linux?'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2702475779139289733.post-2265508396323707541</id><published>2011-01-15T17:18:00.002+00:00</published><updated>2011-01-27T19:01:41.489+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python USB robotic arm maplin"/><title type='text'>In the beginning...</title><content type='html'>So a quick explanation of why this page exists...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&#39;ve been playing with the language Python for a few  months now for ad hoc small projects related to my day job.&amp;nbsp; I&#39;ve been  meaning to learn it in a slightly more structured manner, and got this  book for C&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=polwart-21&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=1590599829&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;hristmas.&lt;br /&gt;
&lt;br /&gt;
I also got given this robotic arm from Maplin (&lt;a href=&quot;http://www.maplin.co.uk/robotic-arm-kit-with-usb-pc-interface-266257&quot;&gt;http://www.maplin.co.uk/robotic-arm-kit-with-usb-pc-interface-266257&lt;/a&gt;) and since it has no Linux software I thought this would be a good opportunity to combine learning and practicing some of the more sophisticated Python features, whilst at the same time producing an easy to use Python script that others could make use of.&lt;br /&gt;
&lt;br /&gt;
In my googling for Linux software for this arm I found this: &lt;a href=&quot;http://www.linuxquestions.org/questions/programming-9/c-code-for-maplin-usb-robot-arm-851033/&quot;&gt;http://www.linuxquestions.org/questions/programming-9/c-code-for-maplin-usb-robot-arm-851033/&lt;/a&gt; - but since there were questions about it actually working and it would mean part learning another language variant (I&#39;m vaguely literate in at least half a dozen computer languages but fluent in none!).&amp;nbsp; That didn&#39;t suit - but did provide some useful info on the possibility of doing it in Python.&amp;nbsp; A few days after I started some C code was then published too &lt;a href=&quot;http://www.blogger.com/%28http://notbrainsurgery.livejournal.com/38622.html&quot;&gt;(http://notbrainsurgery.livejournal.com/38622.html&lt;/a&gt;) - which I&#39;ve not tried - but aware that non programmers are not likely to embrace C as much as they might with Python I decided to finish what I started.&amp;nbsp; Last night I debugged my first prototype and got it moving the arm.&amp;nbsp; My plan is to post a cleaned up version of that code as the beginning of this page sometime this weekend, and then add more advanced functions and packaged code which might be useful for total new comers etc.&lt;br /&gt;
&lt;br /&gt;
Of course I&#39;d be delighted to hear about features you think would be useful and I&#39;ll consider them; or indeed I&#39;m quite happy for you to modify the code to include those features yourself - feel free to send me such improvements if you&#39;d like me to share them here.</content><link rel='replies' type='application/atom+xml' href='http://python-poly.blogspot.com/feeds/2265508396323707541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://python-poly.blogspot.com/2011/01/in-beginning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2265508396323707541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2702475779139289733/posts/default/2265508396323707541'/><link rel='alternate' type='text/html' href='http://python-poly.blogspot.com/2011/01/in-beginning.html' title='In the beginning...'/><author><name>poly</name><uri>http://www.blogger.com/profile/01859734540609680894</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>