Lego Animations

I forgot my camera when I went to the lab today, so photos of my Lego Laser Scanner will have to wait.

In the meantime, I spent the early evening figuring out how to use the LDraw tools to draw and animate Lego constructions.  To start, I simply made a figure of the four angled liftarm pieces using MLCAD.  There are some nice tutorials for using MLCAD that I described in a previous posting.

I then converted the LDRAW file format to the ray-tracing POV format using L3PAO.  From there I was able use POV-Ray to access the POV script and modify it to make the animation.  The animation was performed by following the Rotation Animation Tutorial by OrionP. 

Lego Animation

The key is to go into the POV file near the end and find the object commands.  Here is one of the four (for my four Lego pieces):

object {
  _32009_dot_dat
  matrix <1-SW/98,0,0,0,1-SW/20,0,0,0,1-SW/178,SW/2.45,0,SW/-2.225>
  matrix <1,0,0,0,1,0,0,0,1,38,23,-2>
  #if (version >= 3.1) material #else texture #end { Color0 }

The second matrix specification has two parts:
1,0,0,0,1,0,0,0,1
and
38, 23, -2
The first part is the 3×3 identity matrix, and the second is a translation.

To rotate the pieces, simply remove the translation.  Then apply a rotation about the objects center of mass, then translate it.  The code looks like this…

 object {
  _32009_dot_dat
  matrix <1-SW/98,0,0,0,1-SW/20,0,0,0,1-SW/178,SW/2.45,0,SW/-2.225>
  matrix <1,0,0,0,1,0,0,0,1,0,0,0>  rotate<0,0,45> translate<38,23,-2>  translate<0,-50,0>
  #if (version >= 3.1) material #else texture #end { Color0 }

This will rotate the piece about the z-axis by 45 degrees.

To make an animation, we simply replace 45 by clock (or clock * some number).  POV has a variable clock, which advances in time with each rendering.  This will increase the rotation.

To pull this off, you need an .ini file.  Following OrionP’s lead, this is what mine looks like:

; Animation INI File

Initial_Frame=1
Final_Frame= 30

;Subset_Start_Frame = 1
;Subset_End_Frame = 30

Initial_Clock=0 
Final_Clock=360

Width=350     
Height=262

Cyclic_Animation=on   
Pause_when_Done=off          
Output_File_Type=N          
; T – Uncompressed Tar 24-bit File
; N – New PNG (portable network graphics) format
; S – System-specific such as Mac Pict or Windows BMP
; C – Compressed Targa-24 format (RLE, run length encoded)
; P – Unix PPM format   
Antialias=On
Antialias_Threshold=0.3

This gives me 30 frames with the clock going from 0 to 360 (around the clock so to speak).
To get POV-Ray to use the .ini file, you have to click on the ini icon and set the ini file.
Then run it!

I then took the 30 .png images and converted them to gifs in Adobe Photoshop.
Last, I used Adobe ImageReady to put the gifs together into an animated gif.

This is admittedly a crappy tutorial… its late!
So I promise that I will write up a more detailed one in the near future.

In the immortal words or Tor Johnson, “Time for go to bed!”

Tor Johnson in THE UNEARTHLY (featured on MST3K) 

Kevin Knuth
Albany NY

Posted under Fun, Lego, Software, Solutions

This post was written by drknuth on April 4, 2007

Tags: , , , , , , , ,

Lego Mechanisms

I am in the process of making a Lego Laser Scanner.  The instrument is designed to move a mirror both back and forth and up and down to reflect a laser beam in any direction within a solid angle defined by the range of motion of the mirror.  At this stage, the Lego Laser Scanner is more like a Lego Laser Show as it has two motors that rotate at distinct and programmable rates to produce Lissajous figures with the reflected laser beam.  Stay tuned, as next week, I plan to have photos and a movie.

To make a useful scanner, I would prefer to use one motor rather than two.  This will require some complex gearing, but it is straight-forward.  The part that had me a bit puzzled was the fact that I want the scanner to make one horizontal sweep while maintaining a constant vertical position.  Once the horizontal sweep is finished, I need it to nudge the vertical orientation of the mirror just a bit, and then perform another horizontal sweep and so on.  How to do this with a single motor was not clear.  Until I came across a set of fabulous mechanisms by Leo Dorst of the Intelligent Systems Laboratory Amsterdam at the University of Amsterdam in The Netherlands.

Leo Dorst's Design for a Geneva Mechanism

Leo Dorst created a Lego version of the Geneva Mechanism, which moves film through a projector by holding it still while intermittently feeding it through the mechanism.  His sketch is above, but better images and instructions exist on his website.  He has a wide variety of Lego Mechanisms, that I am sure I will find useful in the near future.

In the meantime, his design (below) of a six degree-of-freedom robotic arm is fantastic!!!

Leo Dorst's Design of a Robotic Arm

I have found the books below to be very good.

Enjoy,
Kevin Knuth
Albany NY

Posted under Fun, Intelligent Systems, Inventions, Lego, NXT, Research, Robotics, Solutions

This post was written by drknuth on April 1, 2007

Tags: , , , , , , , , , ,

Rendering Lego Figures

A couple of weeks ago, I described the free software package called LDraw that with MLCad and POV-Ray allows you to design Lego creations and illustrate them with ray tracing software.  The software actually goes far beyond this, as MLCad is a real Computer Aided Design program that allows you to save the steps so that you can automatically generate instructions for your Lego creations.  It also generates a Parts List so that you know which parts you will need beforehand.

I was playing around with it this weekend, and made one of the spaceships described in a good online tutorial.  Then I rendered him with POV-Ray, and then overlaid the Lego image over a lovely picture of Saturn.  The result is: Our Hero Races Past Saturn

Our Hero Races Past Saturn

Go ahead and laugh… that’s the whole point!
Kevin Knuth
Albany NY

Posted under Fun, Lego, Software

This post was written by drknuth on March 21, 2007

Tags: , , , , , , , , , ,