<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arkadian.eu</title>
	<atom:link href="http://www.arkadian.eu/feed" rel="self" type="application/rss+xml" />
	<link>http://www.arkadian.eu</link>
	<description>thinking out loud...</description>
	<lastBuildDate>Wed, 23 Jan 2013 20:35:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple File Rename script in Python</title>
		<link>http://www.arkadian.eu/pages/728/simple-file-rename-script-in-python</link>
		<comments>http://www.arkadian.eu/pages/728/simple-file-rename-script-in-python#comments</comments>
		<pubDate>Wed, 23 Jan 2013 20:35:07 +0000</pubDate>
		<dc:creator>arkadian</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=728</guid>
		<description><![CDATA[
import os
indir = 'c:\\datafilepath\\'

for filename in os.listdir(indir):
	if filename.startswith("xyz_"):
		newname = filename.replace("xyz_","abc_")
		try:
			os.rename(indir + filename, indir + newname)
			print "[NEW]", filename, "-->", newname

		except:
			print "[OLD]", filename, "-->", newname

]]></description>
			<content:encoded><![CDATA[<pre>
import os
indir = 'c:\\datafilepath\\'

for filename in os.listdir(indir):
	if filename.startswith("xyz_"):
		newname = filename.replace("xyz_","abc_")
		try:
			os.rename(indir + filename, indir + newname)
			print "[NEW]", filename, "-->", newname

		except:
			print "[OLD]", filename, "-->", newname
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/728/simple-file-rename-script-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robot Challenge 009</title>
		<link>http://www.arkadian.eu/pages/723/robot-challenge-009</link>
		<comments>http://www.arkadian.eu/pages/723/robot-challenge-009#comments</comments>
		<pubDate>Sun, 02 Dec 2012 18:56:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[robotics]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=723</guid>
		<description><![CDATA[Not much progress to report. My compass module seems to have died, probably due to the fact I was feeding it 5V instead of the required 3.3V&#8230; Never mind, new module ordered.
I&#8217;ve added a new level to the robot and now looks neater. Here are a couple of photos:
With a camera (placeholder &#8211; not really [...]]]></description>
			<content:encoded><![CDATA[<p>Not much progress to report. My compass module seems to have died, probably due to the fact I was feeding it 5V instead of the required 3.3V&#8230; Never mind, new module ordered.</p>
<p>I&#8217;ve added a new level to the robot and now looks neater. Here are a couple of photos:</p>
<p>With a camera (placeholder &#8211; not really attached):<br />
<img src="http://www.arkadian.eu/wp-content/uploads/2012/12/DSCF0920_top_20.jpg" alt="DSCF0920_top_20" title="DSCF0920_top_20" width="410" height="474" class="alignnone size-full wp-image-724" /></p>
<p>Without camera:<br />
<img src="http://www.arkadian.eu/wp-content/uploads/2012/12/DSCF0928_no_cam_20.jpg" alt="DSCF0928_no_cam_20" title="DSCF0928_no_cam_20" width="453" height="458" class="alignnone size-full wp-image-725" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/723/robot-challenge-009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi Samba Share</title>
		<link>http://www.arkadian.eu/pages/715/raspberry-pi-samba-share</link>
		<comments>http://www.arkadian.eu/pages/715/raspberry-pi-samba-share#comments</comments>
		<pubDate>Sun, 18 Nov 2012 09:01:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RaspberryPi]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[RPi]]></category>
		<category><![CDATA[Samba]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=715</guid>
		<description><![CDATA[My RPi is the brain of my ARK-AV-01 robot. As I currently am in the programming phase, I found myself programming it from the command line. I wanted something easier, with no login/password, so I activated samba with the following samba.conf file:

[global]
workgroup = mygroup
interfaces = wlan
bind interfaces only = yes
server string = Arkadian's ARK-AV-01
security = [...]]]></description>
			<content:encoded><![CDATA[<p>My RPi is the brain of my ARK-AV-01 robot. As I currently am in the programming phase, I found myself programming it from the command line. I wanted something easier, with no login/password, so I activated samba with the following samba.conf file:</p>
<pre>
[global]
workgroup = mygroup
interfaces = wlan
bind interfaces only = yes
server string = Arkadian's ARK-AV-01
security = share
guest account = nobody
log file = /var/log/samba.%m

[Robot]
comment = Robot Control Center
path = /robot/
available = yes
browseable = yes
public = yes
writable = yes
read only = no
guest ok = yes
</pre>
<p>The above configuration allows you to connect to the /robot/ folder from any windows or linux machine.</p>
<p>I had to also run the following commands</p>
<pre>sudo chown nobody /robot</pre>
<p>and </p>
<pre>sudo chmod 777 /robot -R</pre>
<p>to ensure the folder is owned by user nobody and is writable.</p>
<p>then, just restart the samba service:</p>
</pre>
<p>sudo service samba restart</pre>
<p>And now you can mount the folder /robot to your windows or linux machine!<br />
if everything works ok, make sure to add samba to the startup script:</p>
<pre>sudo update-rc.d samba defaults</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/715/raspberry-pi-samba-share/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robot Challenge 008</title>
		<link>http://www.arkadian.eu/pages/704/robot-challenge-008</link>
		<comments>http://www.arkadian.eu/pages/704/robot-challenge-008#comments</comments>
		<pubDate>Mon, 12 Nov 2012 00:34:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[ARK-AV1]]></category>
		<category><![CDATA[RC mode]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=704</guid>
		<description><![CDATA[As promised, here is a video I&#8217;ve put together of the RC mode.

Robot Challenge 008 from Arkadian.Eu on Vimeo.
Also as promised, here is the Python code which, when run on a Raspberry Pi, it receives OSC signals from my iPad, interprets them and gets the Arduino board to perform the required action.
This is very rough, [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is a video I&#8217;ve put together of the RC mode.</p>
<p><iframe src="http://player.vimeo.com/video/53290674?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/53290674">Robot Challenge 008</a> from <a href="http://vimeo.com/user2266264">Arkadian.Eu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Also as promised, here is the Python code which, when run on a Raspberry Pi, it receives OSC signals from my iPad, interprets them and gets the Arduino board to perform the required action.</p>
<p>This is very rough, and doesn&#8217;t not include the code for clockwise and anticlockwise rotation (as I made the addition directly on the raspberry and it&#8217;s now out of battery). Clearly, this requires the simpleOSC and pyFirmata libraries to be installed. Most of the code you see here is just a quick mashup, based on examples from the SimpleOSC and pyFirmata libraries. For me the key is that it works! <img src='http://www.arkadian.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> OSC, <span style="color: #dc143c;">time</span>, <span style="color: #dc143c;">threading</span>, <span style="color: #dc143c;">os</span>, serial
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> pyfirmata
<span style="color: #ff7700;font-weight:bold;">from</span> pyfirmata <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
<span style="color: #ff7700;font-weight:bold;">from</span> boards <span style="color: #ff7700;font-weight:bold;">import</span> BOARDS
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> ArduinoMega<span style="color: black;">&#40;</span>Board<span style="color: black;">&#41;</span>:
	<span style="color: #483d8b;">&quot;&quot;&quot;
	A board that will set itself up as an Arduino Mega.
	&quot;&quot;&quot;</span>
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
		args = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>
		args.<span style="color: black;">append</span><span style="color: black;">&#40;</span>BOARDS<span style="color: black;">&#91;</span><span style="color: #483d8b;">'arduino_mega'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
		<span style="color: #008000;">super</span><span style="color: black;">&#40;</span>ArduinoMega, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>args, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__str__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'Arduino Mega %s on %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">name</span>, <span style="color: #008000;">self</span>.<span style="color: black;">sp</span>.<span style="color: black;">port</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Adjust that the port match your system:</span>
PORT = <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\\</span>.<span style="color: #000099; font-weight: bold;">\C</span>OM4'</span> 		<span style="color: #808080; font-style: italic;">#On Windows</span>
<span style="color: #808080; font-style: italic;">#PORT = '/dev/ttyACM0' 	#On RPi</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Creates a new board </span>
board = ArduinoMega<span style="color: black;">&#40;</span>PORT<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #ff7700;font-weight:bold;">def</span> engine<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source
	<span style="color: #008000;">file</span> = <span style="color: #483d8b;">&quot;Car_Start_2.mp3&quot;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;starting engine&quot;</span>
	<span style="color: #808080; font-style: italic;">#os.startfile(file) # </span>
&nbsp;
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #ff7700;font-weight:bold;">def</span> rcMode<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Switching to RC mode&quot;</span>
	<span style="color: #808080; font-style: italic;">#os.startfile(file)</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #ff7700;font-weight:bold;">def</span> autoMode<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Switching to AUTO mode&quot;</span>
	<span style="color: #808080; font-style: italic;">#os.startfile(file)</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #ff7700;font-weight:bold;">def</span> questMode<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Switching to QUEST mode&quot;</span>
	<span style="color: #808080; font-style: italic;">#os.startfile(file)	</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># LIGHTS SECTION</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
PIN2 = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:2:p'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> lightR<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	PIN2.<span style="color: black;">write</span><span style="color: black;">&#40;</span>1 - args<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source	
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
PIN3 = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:3:p'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> lightG<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	PIN3.<span style="color: black;">write</span><span style="color: black;">&#40;</span>1- args<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source	
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
PIN4 = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:4:p'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> lightB<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	PIN4.<span style="color: black;">write</span><span style="color: black;">&#40;</span>1-args<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source	
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
PIN13 = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:13:p'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> lightFloor<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	PIN13.<span style="color: black;">write</span><span style="color: black;">&#40;</span>1 - args<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source	
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># MOTOR SECTION</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
PINA = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:8:s'</span><span style="color: black;">&#41;</span>
PINB = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:9:s'</span><span style="color: black;">&#41;</span>
PINC = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:10:s'</span><span style="color: black;">&#41;</span>
PIND = board.<span style="color: black;">get_pin</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'d:11:s'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> motor<span style="color: black;">&#40;</span>aa,bb,cc,dd<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> aa, bb, cc, dd
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> aa==1: PINA.<span style="color: black;">write</span><span style="color: black;">&#40;</span>20<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> aa==-1: PINA.<span style="color: black;">write</span><span style="color: black;">&#40;</span>138<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> aa==0: PINA.<span style="color: black;">write</span><span style="color: black;">&#40;</span>91<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> bb==1: PINB.<span style="color: black;">write</span><span style="color: black;">&#40;</span>20<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> bb==-1: PINB.<span style="color: black;">write</span><span style="color: black;">&#40;</span>138<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> bb==0: PINB.<span style="color: black;">write</span><span style="color: black;">&#40;</span>91<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> cc==1: PINC.<span style="color: black;">write</span><span style="color: black;">&#40;</span>20<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> cc==-1: PINC.<span style="color: black;">write</span><span style="color: black;">&#40;</span>138<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> cc==0: PINC.<span style="color: black;">write</span><span style="color: black;">&#40;</span>91<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> dd==1: PIND.<span style="color: black;">write</span><span style="color: black;">&#40;</span>20<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> dd==-1: PIND.<span style="color: black;">write</span><span style="color: black;">&#40;</span>138<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> dd==0: PIND.<span style="color: black;">write</span><span style="color: black;">&#40;</span>91<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> xmotor<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	direction = path.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>2<span style="color: black;">&#93;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;PIN&quot;</span>, path.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, 
	<span style="color: #ff7700;font-weight:bold;">print</span> tags, <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source	
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">if</span> args<span style="color: black;">&#91;</span>0<span style="color: black;">&#93;</span>==0: 
		motor<span style="color: black;">&#40;</span>0,0,0,0<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">else</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;nn&quot;</span> 	: motor<span style="color: black;">&#40;</span>1,0,-1,0<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;ne&quot;</span>	: motor<span style="color: black;">&#40;</span>1,1,-1,-1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;ee&quot;</span>	: motor<span style="color: black;">&#40;</span>0,1,0,-1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;se&quot;</span>	: motor<span style="color: black;">&#40;</span>-1,1,1,-1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;ss&quot;</span>	: motor<span style="color: black;">&#40;</span>-1,0,1,0<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;sw&quot;</span>	: motor<span style="color: black;">&#40;</span>-1,-1,1,1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;ww&quot;</span>	: motor<span style="color: black;">&#40;</span>0,-1,0,1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;nw&quot;</span>	: motor<span style="color: black;">&#40;</span>1,-1,-1,1<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> direction == <span style="color: #483d8b;">&quot;freeze&quot;</span>: motor<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># ##################################################################	</span>
<span style="color: #808080; font-style: italic;"># ##################################################################</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> user_callback<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #dc143c;">user</span> = <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;cb--&gt;&quot;</span>,  path, <span style="color: #483d8b;">&quot;@TAGS&quot;</span>, tags, 
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;@ARGS&quot;</span>, args, <span style="color: #483d8b;">&quot;@SOURCE&quot;</span>, source
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> quit_callback<span style="color: black;">&#40;</span>path, tags, args, source<span style="color: black;">&#41;</span>:
	<span style="color: #808080; font-style: italic;">#pass</span>
	<span style="color: #808080; font-style: italic;"># don't do this at home (or it'll quit blender)</span>
	<span style="color: #ff7700;font-weight:bold;">global</span> run
	run = <span style="color: #008000;">False</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># tupple with ip, port</span>
receive_address = <span style="color: #483d8b;">&quot;192.168.0.47&quot;</span>, <span style="color: #ff4500;">7110</span>  
&nbsp;
<span style="color: #808080; font-style: italic;"># OSC Server. there are three different types of server. </span>
<span style="color: #808080; font-style: italic;">#s = OSC.OSCServer(receive_address) # basic</span>
s = OSC.<span style="color: black;">ThreadingOSCServer</span><span style="color: black;">&#40;</span>receive_address<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># threading</span>
<span style="color: #808080; font-style: italic;">##s = OSC.ForkingOSCServer(receive_address) # forking</span>
&nbsp;
s.<span style="color: black;">addDefaultHandlers</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/start&quot;</span>, engine<span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/rc&quot;</span>, rcMode<span style="color: black;">&#41;</span> 	
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/auto&quot;</span>, autoMode<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/quest&quot;</span>, questMode<span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/nn&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/ne&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/ee&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/se&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/ss&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/sw&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/ww&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/nw&quot;</span>, xmotor<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/1/freeze&quot;</span>, xmotor<span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/2/red&quot;</span>, lightR<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/2/green&quot;</span>, lightG<span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/2/blue&quot;</span>, lightB<span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/2/grey&quot;</span>, lightFloor<span style="color: black;">&#41;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/ping&quot;</span>, user_callback <span style="color: black;">&#41;</span>
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;/quit&quot;</span>, quit_callback <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># define a message-handler function for the server to call.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> printing_handler<span style="color: black;">&#40;</span>addr, tags, stuff, source<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;---&quot;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;received new osc msg from %s&quot;</span> <span style="color: #66cc66;">%</span> OSC.<span style="color: black;">getUrlStr</span><span style="color: black;">&#40;</span>source<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;with addr : %s&quot;</span> <span style="color: #66cc66;">%</span> addr
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;typetags %s&quot;</span> <span style="color: #66cc66;">%</span> tags
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;data %s&quot;</span> <span style="color: #66cc66;">%</span> stuff
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;---&quot;</span>
&nbsp;
s.<span style="color: black;">addMsgHandler</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/print&quot;</span>, printing_handler<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># adding our function</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># just checking which handlers we have added</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Registered Callback-functions are :&quot;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> addr <span style="color: #ff7700;font-weight:bold;">in</span> s.<span style="color: black;">getOSCAddressSpace</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">print</span> addr
&nbsp;
<span style="color: #808080; font-style: italic;"># Start OSCServer</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Starting OSCServer. Use ctrl-C to quit.&quot;</span>
st = <span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span><span style="color: black;">&#40;</span> target = s.<span style="color: black;">serve_forever</span> <span style="color: black;">&#41;</span>
st.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">try</span> :
	<span style="color: #ff7700;font-weight:bold;">while</span> 1 : <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyboardInterrupt</span> :
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Closing OSCServer.&quot;</span>
	s.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Waiting for Server-thread to finish&quot;</span>
	st.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">##!!!</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Done&quot;</span></pre></td></tr></table></div>

<p>Lines 150-173 are linked to my touchOSC template. For instance &#8220;nn&#8221; stands for North, &#8220;ne&#8221; for North East etc&#8230;<br />
The TouchOSC editor allows you to give your buttons friendly names. The created template itself, while suffixed with a &#8220;.touchosc&#8221;, is simply a zipped xml file (in case you want to really fine-tune it!). The editor does a great job &#8211; pity it doesn&#8217;t work with Android&#8230;  </p>
<p>Lines 116-124 control the wheels. Basically, 1 is clockwise, -1 is acti-clockwise and 0 is break. The list in motor(1,0,-1,0) includes a value for each one of my four motors. The two rotation functions missing here, simply have motor(1,1,1,1) and motor(-1,-1,-1,-1).</p>
<p>The engine function (line 28) will be playing an mp3 with the sound of a car engine starting, when the virtual engine key is turned. It works fine on Windows and it should be quite easy to get it to work on RPi too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/704/robot-challenge-008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robot Challenge 007</title>
		<link>http://www.arkadian.eu/pages/698/robot-challenge-007</link>
		<comments>http://www.arkadian.eu/pages/698/robot-challenge-007#comments</comments>
		<pubDate>Sat, 10 Nov 2012 23:01:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[Sparkfun]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=698</guid>
		<description><![CDATA[I had a productive couple of days. Arkadian AV-1 is now operational as a remote control vehicle.
Arduino
I&#8217;m using the StandardFirmata library on the Arduino Mega 2560, with no modifications whatsoever. It was by far the easiest way to get RaspberryPi to control the 4 motors, receive feedback from the 4 sensors (on order from Sparkfun, [...]]]></description>
			<content:encoded><![CDATA[<p>I had a productive couple of days. Arkadian AV-1 is now operational as a remote control vehicle.</p>
<p><strong>Arduino</strong><br />
I&#8217;m using the StandardFirmata library on the Arduino Mega 2560, with no modifications whatsoever. It was by far the easiest way to get RaspberryPi to control the 4 motors, receive feedback from the 4 sensors (on order from Sparkfun, should be here soon) and have the ability to switch on and off the lights on the robot. </p>
<p><strong>RaspberryPi</strong><br />
The RaspberryPi is loaded with Ladyada&#8217;s RPi distro, as it had the latest python library and a few other things that I&#8217;m planning on using later on. I have added the <a href="https://bitbucket.org/fab/pyfirmata">PyFirmata</a> library (to control the Arduino) and the OSC library  (as described previously) to receive instructions from the OSC pad.</p>
<p><strong>TouchOSC</strong><br />
I have been using TouchOSC to create the remote control interface. My original plan was to use the Nexus tablet to control the robot. The problem is that TouchOSC is a bit behind when it comes to Android. The app is available to buy, but you cannot upload your own templates, which makes it pretty useless. I&#8217;ll be using an iPad for now, but I hope they get the android version sorted soon.</p>
<p>Here is my latest layout (first page):<br />
<img src="http://www.arkadian.eu/wp-content/uploads/2012/11/OSC_Control_Panel_004.jpg" alt="OSC_Control_Panel_004" title="OSC_Control_Panel_004" width="702" height="397" class="alignnone size-full wp-image-699" /></p>
<p>The two buttons under the &#8220;Quest&#8221;, are for clockwise and anti-clockwise rotation.</p>
<p>Vehicle is very responsive and drives really well. Orientation gets a bit tricky for the human brain if the rotation buttons are not used, but for the &#8220;Quest Mode&#8221; this will really be ideal.</p>
<p>I&#8217;ll post the code, photos and a video tomorrow.</p>
<p>Next week, I&#8217;ll finish off the sensors (proximity and compass), tidy up the cables and put everything in a more permanent position. My code needs a bit of tidying up too; it&#8217;s really a mess right now (but, hey, it works!).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/698/robot-challenge-007/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robot Challenge 006</title>
		<link>http://www.arkadian.eu/pages/684/robot-challenge-006</link>
		<comments>http://www.arkadian.eu/pages/684/robot-challenge-006#comments</comments>
		<pubDate>Sun, 04 Nov 2012 21:33:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[cable harness]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://www.arkadian.eu/?p=684</guid>
		<description><![CDATA[Not as productive as I hoped this weekend. I managed to complete the cable harness of the motors and blue leds (which was rather boring but important for the project) and tried out a new look (as I&#8217;m moving away from the use of reel cans as my chassis).
Here is the cable harness, before the [...]]]></description>
			<content:encoded><![CDATA[<p>Not as productive as I hoped this weekend. I managed to complete the cable harness of the motors and blue leds (which was rather boring but important for the project) and tried out a new look (as I&#8217;m moving away from the use of reel cans as my chassis).</p>
<p>Here is the cable harness, before the insulation tape got applied:<img src="http://www.arkadian.eu/wp-content/uploads/2012/11/cable_harness.jpg" alt="cable_harness" title="cable_harness" width="665" height="414" class="alignnone size-full wp-image-685" />.</p>
<p>The advantage of this harness is that all the motor cables are neatly hidden away and only 4 cables appear on the top surface (one for each motor), plus one for the blue LEDs and the ground cable.</p>
<p>Regarding the new look &#8211; I got a few patterns printed on photographic paper and converted them to the side motor panels with a bit of cutting and scoring:<br />
<img src="http://www.arkadian.eu/wp-content/uploads/2012/11/cat_style_corners.jpg" alt="cat_style_corners" title="cat_style_corners" width="698" height="523" class="alignnone size-full wp-image-686" /></p>
<p>Here is how Arkadian-AV1 looks like at the moment (this is still a temporary look):</p>
<p><img src="http://www.arkadian.eu/wp-content/uploads/2012/11/latest_arkadian-AV1.jpg" alt="latest_arkadian-AV1" title="latest_arkadian-AV1" width="529" height="474" class="alignnone size-full wp-image-688" /></p>
<p>The image shows an old Freeduino I have for testing. The final robot will be using an Arduino Mega for controlling the motors, reading the sensors and lighting the lights, but all the &#8220;thinking&#8221; will be done by the Raspberry Pi. <img src="http://www.arkadian.eu/wp-content/uploads/2012/11/rpi_ardmega.jpg" alt="rpi_ardmega" title="rpi_ardmega" width="557" height="482" class="alignnone size-full wp-image-690" /></p>
<p>Here is a little video, where each motor goes forward for a sec, backwards for a sec, then all the leds are turned on and then the same sequence is repeated on another motor.</p>
<p><iframe src="http://player.vimeo.com/video/52804547?badge=0" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/52804547">Robot Challenge 006</a> from <a href="http://vimeo.com/user2266264">Arkadian.Eu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.arkadian.eu/pages/684/robot-challenge-006/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
