Você está na página 1de 13

!"#$%&$%'()"* ,-'.

/)0- !"&1( )"($


2.-"3-%
!"(%$31#()$" ($ 2.-"3-%
Blender is a 4%-- and $&-"56$1%#- 78 #$0&1(-% *%'&9)#6 6$4(:'%- &%$31#( used or creating animated ilms, isual eects, art,
3D printed models, interactie 3D applications and ideo games. Blender's eatures include 3D modeling, UV unwrapping,
texturing, rigging and skinning, luid and smoke simulation, &'%()#.- 6)01.'()$"; 6$4( <$3= 6)01.'()$", sculpting, animating,
match moing, camera tracking, rendering, ideo editing and compositing. It also eatures a built-in game engine.
\ikipedia Commons

2.-"3-% )6 ' &$:-%41. $&-"56$1%#- ($$. 4$%
0$3-.)"* )" 78> !( 9'6 (9- '33-3 <-"-4)( $4
&%$?)3)"* ' 6-( $4 ($$.6 ($ 0$3-. &9=6)#'. 6=6(-06
:9)#9 #'" <- $4 *%-'( <-"-4)( ($ -"*)"--%6>


@9= 2.-"3-%A
B%--CC
D&-" E$1%#-
F$:-%41.
G-6(9-()#'..= E$1"3
E(%$"* &9=6)#'.
($$.<$H
F%-((= #$$.


B$% (9- &1%&$6-6 $4 (9$6- )" (9-
0-#9'(%$")#6 :$%.3; )( #'" <- '
?-%= -44-#()?- :'= ($ -?'.1'(-
3)44-%-"( &9=6)#'. 6)(1'()$"6
:9).- "$( 9'?)"* ($ 0'"1'..=
#9'"*- &'%(6> !( '.6$ &%$?)3-6 '
6(%$"* ?)61'. %-&%-6-"('()$" $4
3="'0)# 6=6(-06>

!3-'
We were interested in using the simulation capabilities of blender
and then manipulating the model with real world inputs...
external system or microprocessor.
Why?
To be able to quickly see changes in model dynamics given real
world control, input without having to retool or recreate a full
scale system.
Less cost, less material
Blender gives awesome visual representations that stem from its
strong background in the gaming industry.

F=(9$" '"3
F=E-%)'.
2.-"3-% )6 <'6-3 $" (9- F=(9$" '"3 16-6 F=E-%)'. '6 '"
'335)" ($$. 4$% 6-%)'. #$001")#'()$">
I$( 0)#%$&%$#-66$% 6&-#)4)#; J16( 6-%)'. #$001")#'()$" 6&-#)4)#

F=(9$" )6 ' :)3-.= 16-3 *-"-%'.5&1%&$6-; 9)*95.-?-. &%$*%'00)"*
.'"*1'*-> !(6 3-6)*" &9).$6$&9= -0&9'6)K-6 #$3- %-'3'<).)(=; '"3 )(6
6="('H '..$:6 &%$*%'00-%6 ($ -H&%-66 #$"#-&(6 )" 4-:-% .)"-6 $4 #$3-
(9'" :$1.3 <- &$66)<.- )" .'"*1'*-6 61#9 '6 L> @)M)&-3)' L$00$"6

Side note: We spent some quality time interpreting how to utilize the toolbox
-44-#()?-.=
Python in practice
@9-%- 3$ ! *-( (9-6-
G:-6$0- ($$.6A
Blender is available at
www.blender.org
There are releases all the time as the open source community continually
pushes advancements.
We are using Version 2.49b in our demo

Python
Typically is packaged with Mac, Linux systems
Windows users will need to download and install
Again, versions are released constantly
We used the version that mated best with Blender 2.49b Python 2.6

Microprocessor
We chose to use the Arduino UNO with our demo based on familiarity,
availability, cost, and available support modules.
You can grab the UNO from just about any electronics store these days
for around $25.
8el[o 8aLllalnen Advanced MechaLronlcs 208
8afael erelra
!"##$%& (#)*#"+ !,$+"
!"#$%&$%'()"* ,-'. ()/- !"&0( )"($ 1.-"2-% 3)/0.'()$" 4"5)%$"/-"(


1hls gulde ls lnLended Lo glve you a llLLle lnslghL lnLo how Lo geL a blender model wlLh real-Llme serlal
lnpuL up and runnlng. We wenL Lhrough a few hurdles durlng our lnvesLlgaLlon and wanL Lo help you
avold Lhose so LhaL you can use Lhese Lools Lo Lhelr full poLenLlal.
Youll need three software components to get things moving: Blender, Python, and PySerial.
!"#$%#&
First thing youll want to do is get a version of Blender. While typically the newest and coolest versions
are Lhe way Lo go, for Lhls purpose we opLed Lo go wlLh 8lender verslon 2.49b whlch was bullL uslng
yLhon 2.6, whlch also happens Lo colnclde wlLh Lhe verslon of ySerlal we used.

Co Lo www.8lender.org and download Lhe approprlaLe verslon for your operaLlng sysLem. 8lender
2.49b comes prepackaged wlLh and bullL upon yLhon 2.6.




!"#$% !'(#)'#*"* +,-'*.", /".0'(1%*#.2 345
!'6'") 7"1"#1'
!"#$%&
If youre using a Mac or Linux OS, youve likely got python installed already. Verify that the version
youre using is at least as current as Python 2.6 89:( (1; (% '-%#, <%-#*= #*(% (0" *"> 7;(0%* ?@A 2"1#"2B
#( <'; <'C" (0#*=2 <"22;D@
For windows users, youll need to travel over to >>>@E;(0%*@%1= (% ,%>*)%', (0" 1".%<<"*,",
-"12#%* %6 7;(0%*@ F" 0', ' )#(()" ,#66#.:)(; :2#*= (0" >#*,%>2 #*2('))"1B 2% >" %E(", 6%1 ' <'*:')
#*2('))'(#%*@ G0"1" '1" 2("E 9; 2("E =:#,")#*"2 E1%-#,", %* (0" E;(0%* >"92#(" (% ="( ;%: :E '*,
1:**#*=H









!"()*+,-
The key to getting communication established with the real world is installing a separate library called
7;I"1#') 6%1 (0" E;(0%* )'*=:'="@ J( #2 '* "A("1*') )#91'1; (0'( =#-"2 :2"12 ' (%%) C#( ,",#.'(", 6%1 2"1#')
.%<<:*#.'(#%*@






8el[o 8aLllalnen Advanced MechaLronlcs 208
8afael erelra
1o geL Lhe llbrary navlgaLe Lo hLLp://pyserlal.sourceforge.neL Lo geL Lhe llbrary. 1here are some very
helpful guldellnes on how Lo lncorporaLe Lhe llbrary on Lhe slLe. We had a few hlccups durlng Lhe
process, so weve included our steps below:
1. Make sure Lhe recommended verslons of yLhon and 8lender are lnsLalled and worklng
properly on your sysLem.
2. Download the Pyserial library (we chose the tar.gz for manual installation) and extract into
your pyLhon dlrecLory (Lhe place where yLhon.exe llves).
3. Cnce Lhe llbrary ls copled lnLo Lhe pyLhon folder sysLem, Lhen we can manually lnsLall
pyserlal.
a. lrom Lhe command prompL navlgaLe Lo Lhe pyLhon home dlrecLory, Lhen lnLo Lhe
extracted pyserial folder where you should find the setup.py file.
b. lnsLall Lhe llbrary by enLerlng: "#$%&'&( )*"$+,, (for wlndows)
l. lor Mac/llnux: "%-. &($/.* "#$%&'&( )*"$+,,
4. Cnce pyserlal ls successfully lnsLalled Lo pyLhon, we need Lo lncorporaLe lL lnLo Lhe blender
pyLhon englne. navlgaLe Lo Lhe yserlal maln folder wlLhln Lhe pyLhon dlrecLory llsL and flnd
the serial sub-folder. Copy the entire folder (were going to put the whole thing in
Blenders englne) and pasLe lnLo your 8lender scrlpLs folder.
a. Now locate your Blender Scripts folder by following the tutorial at
hLLp://www.masLerprlm.com/blender-baslc-command/how-Lo-flnd-blender-scrlpLs-
folder-wlndows-mac-llnux.php (Lhanks Lo Lhose folks, Lhey dld a greaL [ob)
3. now your serlal communlcaLlon should be good Lo go!!
a. ?ou can verlfy lnsLallaLlon by enLerlng )0&.1$ "#1)+, lnLo Lhe scrlpLlng wlndow wlLhln
Python. If no error pops up, then youve done an admirable job! If you do get an
error, Lhen lL mlghL Lake a llLLle more work. 1ry golng back Lhrough Lhe sLeps or
locaLlng a good frlend wlLh vasL knowledge of serlal communlcaLlon proLocols.

We developed some baslc sample code Lo geL you sLarLed wlLh Lhls very helpful llbrary. Agaln, we used
Lhe Ardulno unC as our mlcroprocessor, buL any oLher processor wlLh serlal communlcaLlon should
work [usL flne.
1he followlng examples are baslc, and are used Lo llghL Lhe bullL ln LLu on Lhe unC.










!"#$% !'(#)'#*"* +,-'*.", /".0'(1%*#.2 345
!'6'") 7"1"#1'
888888888888888888888888888888888888888888888888888888888888888888888888888888
9:)%', (0" 6%))%;#*< .%," (% =%>1 +1,>#*% ,"-#."?

//xomple coJe fot tbe AtJoloo uNO
lot leJ = 1J,

volJ setop() {
5etlol.beqlo(9600),
ploMoJe(leJ, Ou1lu1),
}

volJ loop() {
lf ( 5etlol.ovolloble())
{
cbot cb = 5etlol.teoJ(),
lf(cb == '0')
{
Jlqltolwtlte(leJ, lOw),
}
lf(cb == '1')
{
Jlqltolwtlte(leJ, nlCn),
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Blender, go to the text editor screen, type the following code, substituting the name of the
serial port where the Arduino is connected. Substitute COM7 for whichever serial port ID on
whichever system youre using. Substitute the write argument with 0 to turn the LED off.

import serial
ser = serial.Serial(COM7, 9600)
x=ser.write(1)
print(x)
ser.close()

@#(0 (0" +1,>#*% .%," 1>**#*< '*, '(('.0", -#' (0" 2('*,'1, 9AB .'C)"D "E".>(" (0" B)"*,"1 .%,"
F+)(G:H #* (0" 2.1#:(#*< ;#*,%; (% 1>*?

8el[o 8aLllalnen Advanced MechaLronlcs 208
8afael erelra
!" $%"%&'( )**+"+,-'. /+"%0 1,& 2%.3
www.8lendernaLlon.com
www.cgcookle.com/blender
hLLp://ardulno.cc/en/8eference/Serlal
www.masLerprlm.com
www.sLackoverflow.com
www.sourceforge.com
www.blenderarLlsLs.org
hLLp://mylnvenLlons.pl

ln use ScreenshoLs

Você também pode gostar