<?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>BrickEngineer: LEGO Design &#187; &#187; programming</title>
	<atom:link href="http://www.brickengineer.com/pages/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brickengineer.com/pages</link>
	<description>LEGO Engineering for LEGO NXT and Robot Enthusiasts</description>
	<lastBuildDate>Tue, 10 Mar 2015 04:45:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>LEGO Rendering Tutorial: The Basics</title>
		<link>http://www.brickengineer.com/pages/2009/02/15/lego-rendering-tutorial-the-basics/</link>
		<comments>http://www.brickengineer.com/pages/2009/02/15/lego-rendering-tutorial-the-basics/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 01:44:37 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Rendering]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[exploration]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[LDRAW]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[LEGO mindstorms]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[MLCAD]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[POV-Ray]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[solutions]]></category>
		<category><![CDATA[starting]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.brickengineer.com/pages/?p=49</guid>
		<description><![CDATA[This is the first in a series of installments that describe how to render high-quality 3D images of your LEGO creations.  You will need the following free software: LDraw MLCad L3P POV-Ray v3.6 which can be downloaded with the LDraw All In One Installer In this tutorial, we will be aiming for a nice simple [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This is the first in a series of installments that describe how to render high-quality 3D images of your LEGO creations.  You will need the following <em>free</em> software:</p>
<ul>
<li>LDraw</li>
<li>MLCad</li>
<li>L3P</li>
<li>POV-Ray v3.6</li>
</ul>
<p>which can be downloaded with the <a title="LDRAW Installer" href="http://www.ldraw.org/Article104.html" target="_blank">LDraw All In One Installer</a></p>
<p>In this tutorial, we will be aiming for a nice simple still image of three bricks.  In later tutorials, we will animate them.  That will require extra software to put a series of inages together to form a video or an animated gif.  I use Adobe ImageReady to make animated gifs, but there are cheaper solutions.</p>
<p>You can also download all the files we will create here<br />
<a href="http://www.brickengineer.com/pages/files/BE_render_tutorial_1.zip">BE_render_tutorial_1.zip</a><br />
and follow along.</p>
<p><strong>STEP 1: Create an MLCad file of the scene to be rendered<br />
</strong></p>
<p>Open MLCad and prepare to place a few LEGO pieces in the scene.</p>
<p><strong><em>Step 1.1</em>: </strong>Set up a 1&#215;1 brick<br />
On the upper left-hand side, click on <em>Brick</em>.<br />
Drag the 1&#215;1 brick into one of the three viewing panels.<br />
With the brick selected click the <span style="color: #ff0000;">RED</span> color button to color it red.<br />
Right-click on the brick and select <em>Enter Pos. + Rot&#8230;<br />
Use Position Values</em> should be checked<br />
Set the X and Z values all to zero and Y to -100 (negative 100)</p>
<p><strong><em>Step 1.2</em>: </strong>Add a 2&#215;4 brick<br />
Following the steps above, find the 2&#215;4 brick in the <em>Brick</em> list (+ will expand the list) and add it to the scene.  Set its color to <span style="color: #ffcc00;">YELLOW</span> and its position to X=100, Y=-100,  Z=50.</p>
<p><strong><em>Step 1.3</em>: </strong>Add a 2&#215;6 plate<br />
Following the steps above, find the 2&#215;6 plate in the <em>Plate</em> list (you will have to scroll down to the <em>Plate</em> tab) and add it to the scene.  Set its color to <span style="color: #0000ff;">BLUE</span> and its position to X=100, Y=-100,  Z=-100.</p>
<p>Be sure that these pieces are all at Y=-100.  The -y direction points upward and this will place them above the Y=0 plane.</p>
<p><strong><em>Step 1.4</em>: </strong>Save your work as <strong><em>part-zoo-1.ldr</em></strong></p>
<p>The screenshot below shows what you should see at this point on your MLCad screen.</p>
<div id="attachment_57" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-57" title="mlcad-screenshot-render-tutorial-1_450x316" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/mlcad-screenshot-render-tutorial-1_450x316.jpg" alt="MLCad Screenshot" width="450" height="316" /><p class="wp-caption-text">MLCad Screenshot</p></div>
<p><em><br />
</em><strong><em></em></strong></p>
<p><strong>STEP 2: Create a POVRay file using L3PAO</strong></p>
<p>Open LP3AO (<em>L3P-Add-on)</em> keeping in mind where you stored your MLCad files.  This figure shows you the basic L3PAO window.</p>
<div id="attachment_59" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-59" title="l3pao-screenshot-render-tutorial-1_450x468" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/l3pao-screenshot-render-tutorial-1_450x468.jpg" alt="L3PAO Screenshot" width="450" height="468" /><p class="wp-caption-text">L3PAO Screenshot</p></div>
<p><strong><em>Step 2.1</em>:</strong> In the <em>L3P-Add-on</em> window set the <em>Model File</em> to point to your MLCad file.  To browse, you may need to click on the button labeled &#8230;</p>
<p><strong><em>Step 2.2</em>:</strong> In the <em>L3P-Add-on</em> window set the <em>POV-Ray Output File</em> to point to the folder where you want your POV-Ray file to go.  To browse, you may need to click on the button labeled &#8230;</p>
<p><strong><em>Step 2.3</em>:</strong> In the middle of the right-hand column is the Quality Level setting.  Set this to 2.  IF you select 3 it prints the LEGO logo on every stud.  If you want this, you may leave it.  But I prefer to remove them.</p>
<p><strong><em>Step 2.4</em>:</strong> At the bottom of the middle column is the <em>Render upon Completion</em> option.  This will launch POV-Ray automatically.  However, if you have problems with the automatic launch, turn this option off and load it manually.  In later tutorials, we will edit the POV-Ray file manually anyway.</p>
<p><strong>Step: 2.5:</strong> To start <em>L3PAdd-on</em> click on the <em>Run L3P</em> button in the lower right.  This will create the POV-Ray <strong><em>part-zoo-1.pov</em></strong> file in the directory you specified, and possibly launch POV-Ray depending on the settings you used in <em>Step 2.4</em> above.</p>
<p><strong>STEP 3: Render the Image with POV-Ray<br />
</strong></p>
<p>If you launched POV-Ray automatically, you will already have your image.  Here we assume that you will render it manually.</p>
<div id="attachment_60" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-60" title="povray-screenshot-render-tutorial-1_450x433" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/povray-screenshot-render-tutorial-1_450x433.jpg" alt="POV-Ray Screenshot" width="450" height="433" /><p class="wp-caption-text">POV-Ray Screenshot</p></div>
<p><strong><em>Step 3.1</em>:</strong> Open POV-Ray and in the <em>File Menu</em>, use <em>Open File</em> to open the .pov file that was created by L3pAO.</p>
<p><strong><em>Step 3.2</em>:</strong> Once the file is open, you can simply press the <em>Run</em> button on the upper bar.  This will create a default image, which is a 640&#215;480 .bmp bitmap image.  This is saved automatically in the same folder as your .pov file.  Here it is:</p>
<div id="attachment_61" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-61" title="part-zoo-1-default" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/part-zoo-1-default.jpg" alt="Part-Zoo-1 Default image" width="450" height="338" /><p class="wp-caption-text">Part-Zoo-1 Default image</p></div>
<p>Note that the LEGO pieces are lifted up above the floor.  This is because we set their y-coordinates to be -100, which is above the floor at zero.  Remember that negative y is up.  We now look to change a few features of our render.</p>
<p><strong><em>Step 3.3</em>:</strong> If you click on the <em>Ini</em> button (to the left of <em>Run</em> above), you will go to a screen that enables you to change the size of the output image.  The <em>Section</em> field on the right has many options that include the resolution of the final image as well as whether <a title="Anti-Aliasing" href="http://en.wikipedia.org/wiki/Anti-aliasing" target="_blank">Anti-Aliasing</a> (AA) is used.  Try changing the resolution and look at the differences between anti-aliased images and non-anti-aliased images.</p>
<p>Note however, that the output images will always be saved in either .bmp or .png format.  You will have to use another program to convert them to other formats if you are interested.</p>
<p><strong><em>Step 3.4</em>: </strong>You can try playing with the commands in the .pov file.  POV-Ray acts like an editor and you can manually edit your files.  For example, there is a section near the bottom that reads:</p>
<blockquote><p>// Floor:<br />
object {<br />
plane { y, 24 hollow }<br />
texture {<br />
pigment { color rgb &lt;0.8,0.8,0.8&gt; }<br />
finish { ambient 0.4 diffuse 0.4 }<br />
}<br />
}</p></blockquote>
<p>This code controls the floor of the image.  If you delete it completely, the floor will disappear as you can see here in this image:</p>
<div id="attachment_64" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-64" title="part-zoo-1-no-floor" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/part-zoo-1-no-floor.jpg" alt="Part-Zoo-1 with No Floor" width="450" height="338" /><p class="wp-caption-text">Part-Zoo-1 with No Floor</p></div>
<p><strong>Step 3.4: </strong>IF you don&#8217;t like the black background, look in the .pov file for the <em>Background</em> section:</p>
<blockquote><p>// Background:<br />
background { color rgb &lt;0,0,0&gt;}</p></blockquote>
<p>Changing the rgb (red, green, and blue) colors to &lt;0.7, 0.7, 1.0&gt;:</p>
<blockquote><p>// Background:<br />
background { color rgb &lt;0.7, 0.7, 1.0&gt;}</p></blockquote>
<p>Will give you an image with no floor and a light blue background:</p>
<div id="attachment_66" style="width: 460px" class="wp-caption alignleft"><img class="size-full wp-image-66" title="part-zoo-1-blue-background" src="http://www.brickengineer.com/pages/wp-content/uploads/2009/02/part-zoo-1-blue-background.jpg" alt="Part-Zoo-1 with a blue blackground" width="450" height="338" /><p class="wp-caption-text">Part-Zoo-1 with a blue blackground</p></div>
<p>We have explored making simple cad images in MLCad, generating a .pov file using L3PAO, and rendering a high-quality bitmap image using POV-Ray.   You should read through the .pov file and try to figure out what the different parts do.  You can change their values and re-render the image to see what impact your changes have.  Just remember that POV-Ray saves the changes on top of the original file,  so you may want to make a backup first.</p>
<p>Happy Rendering!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brickengineer.com/pages/2009/02/15/lego-rendering-tutorial-the-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MATLAB Packages for the NXT</title>
		<link>http://www.brickengineer.com/pages/2009/02/11/matlab-packages-for-the-nxt/</link>
		<comments>http://www.brickengineer.com/pages/2009/02/11/matlab-packages-for-the-nxt/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 07:10:14 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[LEGO mindstorms]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[starting]]></category>

		<guid isPermaLink="false">http://www.brickengineer.com/pages/?p=45</guid>
		<description><![CDATA[There are now several MATLAB packages for robotics, and specifically for the NXT.  One paradigm is to run the code on a PC and have it communicate direct commands to the NXT Brick via Bluetooth or USB.  I have found this paradigm to be a bit dangerous since in the event of a MATLAB crash [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>There are now several MATLAB packages for robotics, and specifically for the NXT.  One paradigm is to run the code on a PC and have it communicate direct commands to the NXT Brick via Bluetooth or USB.  I have found this paradigm to be a bit dangerous since in the event of a MATLAB crash or a miscommunication, the NXT Brick will continue with its last command until ordered to stop.  This has the potential to destroy your robot.  The paradigm that I prefer to use is to write several programs that run on the brick.  These programs take commands from files on the brick that can be uploaded rapidly from the PC.  The MATLAB code then is in charge of sending the command files and starting and stopping programs.  In the event of a MATLAB crash or communication failure, the software running on the NXT Brick can be designed to terminate gracefully.</p>
<p>Here are the MATLAB packages that I know of.  The first two are specifically geared toward the NXT; whereas the last is a general robotics package.</p>
<ul>
<li>LEGO MINDSTORMS NXT Toolkit for MATLAB and Simulink<br />
<a href="http://www.mathworks.com/programs/mindstorms/" target="_blank">http://www.mathworks.com/programs/mindstorms/</a></li>
<li>Robotics Toolbox for MATLAB (Release 7.1) (P.I. Corke)<br />
<a href="http://petercorke.com/Robotics%20Toolbox.html" target="_blank">http://petercorke.com/Robotics%20Toolbox.html</a></li>
<li>RWTH Mindstorms NXT Toolbox for Matlab<br />
<a href="http://www.mindstorms.rwth-aachen.de/" target="_blank">http://www.mindstorms.rwth-aachen.de/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.brickengineer.com/pages/2009/02/11/matlab-packages-for-the-nxt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Matlab Package for LEGO Mindstorms</title>
		<link>http://www.brickengineer.com/pages/2008/03/09/matlab-package-for-lego-mindstorms/</link>
		<comments>http://www.brickengineer.com/pages/2008/03/09/matlab-package-for-lego-mindstorms/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 03:20:17 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[exploration]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[interfacing]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[motor]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://www.brickengineer.com/pages/2008/03/09/matlab-package-for-lego-mindstorms/</guid>
		<description><![CDATA[I recently received a comment on my post on controlling NXT robots with Matlab that pointed me to the RWTH &#8211; Mindstorms NXT Toolbox for MATLAB®, which is a public domain Matlab package that enables one to interface with and control LEGO mindstorms. The RWTH &#8211; Mindstorms NXT Toolbox for MATLAB® was developed as a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I recently received a comment on my post on <a target="_blank" href="http://www.huginn.com/knuth/blog/2007/03/30/controlling-lego-nxt-robots-with-matlab/">controlling NXT robots with Matlab</a> that pointed me to the RWTH &#8211; Mindstorms NXT Toolbox for MATLAB®, which is a public domain Matlab package that enables one to interface with and control LEGO mindstorms.</p>
<p>The <a href="http://www.mindstorms.rwth-aachen.de/">RWTH &#8211; Mindstorms NXT Toolbox for MATLAB®</a> was developed as a student project in the <a href="http://www.lfb.rwth-aachen.de/">Institute of Imaging and Computer Vision</a> at <a target="_blank" href="http://www.rwth-aachen.de/go/id/hi/">RWTH Aachen University</a> in Aachen Germany. It provides a Matlab interface with the NXT brick that includes Bluetooth communication, sensor interface and motor interface. It requires a working Matlab license, of course.</p>
<p>The package is very easy to set up. It took me less than ten minutes to successfully test the example programs over Bluetooth.</p>
<p>There are some very nice motor features, such as motor synchronization and speed ramp-up and ramp-down.</p>
<p>I have yet to explore how easy it is to modify or extend the code, but it ought to be a straightforward matter.</p>
<p>The package can be downloaded from<br />
<a rel="nofollow" href="http://www.mindstorms.rwth-aachen.de/"><font color="#000066">http://www.mindstorms.rwth-aachen.de</font></a></p>
<p>Kevin Knuth<br />
Albany NY</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brickengineer.com/pages/2008/03/09/matlab-package-for-lego-mindstorms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
