simulationimporttutorials

Cancel Save Edit
Summary: Information on how to import your 3D robot model into MSRS

SolidWorks → Blender → MSRS


SolidWorks (http://www.solidworks.com) is an easy to use 3D CAD package. It allows for quick and precise modeling of your robot. Usage of SolidWorks in not covered here, but there are many tutorials on the web. SolidWorks does not export to the .obj format which is needed for MSRS, so we use Blender to convert. Blender (http://blender.org) is a free open source 3D modeling program. Again, full usage of Blender is not covered here, but there are tutorials on the web.

NOTE: There is a SolidWorks to .OBJ export program, but it is $200 and only works with a single part. Complex models in SolidWorks are typically assemblies made up of a number of parts. Also, if you have a really nice model, Blender can be used to make excellent photorealistic renderings of it.


Configure your robot in SolidWorks

* Orient your model so that when you are looking at the front view, you are looking at the back of the robot, but otherwise right side up.
* NOTE: You can rotate your model later in Blender if you are more comfortable with that program.
* At this stage, you can choose to color the various parts of the assembly by selecting a part (left click in the design tree) then Edit > Appearance > Color.
* NOTE: You can change the colors of your model later in Blender if you are more comfortable with that program.


Export your robot to .WRL format
* Open your assembly.
* If you don't want to export all the objects, suppress the objects you don't want to export first.
* The export quality (strangely enough) depends on the screen settings. To improve this, go to Tools > Options > Document Properties tab > Image Quality. If your model looks faceted in your viewport, just set the "Shaded and draft quality HLR/HLV resolution" to a higher value. However, a higher value means a bigger file and slower operations within Blender.
* Go to File > Save As...
* Select VRML as your file-type and click on the "Options..." button.
* Make sure "VRML 1.0" is selected.
* Set the Units to meters.
* uncheck "save all components of the assembly into a single file"
* Because SolidWorks appears to be making a mess out of large assemblies (randomly combining several parts into one mesh), we'll export the assembly as separate files into one directory. To be able to load these files easily, you need to create a new directory for this export first. Later on, we'll import all the files in this directory at once (time saver), so make sure there's no other files in this directory!
* Close the "Export Options" window (click OK).
* Create a new directory for the export (or use an empty one), and hit "Save".


Importing in Blender
* It is recommended that you now close SolidWorks for better performance. We'll import the exported VRML data into Blender.
* First you need a script to import all the .wrl files in your export directory at once. You can download one from: http://www.extrapuur.nl/blender/vrmlbatch.py
* Place the script inside your blender scripts folder (probably something like C:\Program Files\Blender Foundation\Blender\.blender\scripts). After you have done this, the script will always be easily accessible from the import menu!
* Start Blender (if you had already started it before installing the script, you need to restart Blender)
* Delete the default cube and light.
* Go to "File > Import > VRML batch loader". Select a file in your export dir (any file), and press "Open files in this dir".
* You may get some "Error: No Data" messages in Blender, but you can ignore these.


Touchup robot in Blender and export to .OBJ
* When you look at your model with the front view (by pressing #1 on the keypad) you should be looking at the bottom of your robot, facing down.
* You might want to consider re-calculating the normal vectors to point outwards by: selecting the entire model (a key) then (Ctrl N)
1 Now is the time to rotate, scale, and color your model if you are more comfortable with Blender. But if you followed the steps above, none of this should be necessary.
* Save your model, then go to File > Export > Wavefront (.obj)
* Name the file, then click "Export Wavefront OBJ"
* IMPORTANT: Select (darken) "Triangulate" and "Normals". Unselect "Selection Only". Select "Object Groups" and "Material Groups". "Apply Modifiers", "UVs", and "Materials" should already be selected.
* Press OK
* Move the resulting .obj and .mtl files to C:\Microsoft Robotics Studio\store\media

Use robot in MSRS
* Edit a Simulation Tutorial and add this line with your file name: AddConvexMesh("myrobot.obj", new Vector3(0f, 0f, 0f));
* To make your robot drivable, you need to make a robot class that extends DifferentialDriveEntity, and is in the Microsoft.Robotics.Simulation.Engine namespace. Follow the LegoNXT or Pioneer examples.
* That’s it!


		 NOTE: Portions of this tutorial taken from: 
		 http://en.wikibooks.org/wiki/Blender_3D:_Import_and_Render_a_SolidWorks_Model
	




Alibre → Blender → MSRS


Similar to SolidWorks, Alibre (http://www.alibre.com) is a 3D CAD package. It does not export to the the .OBJ or VRML format, so we will use the .STL format to get the model into Blender. Then Blender will export to the .OBJ format.

You can export an assembly or part in Alibre as a .STL file. This can then be imported in Blender. Note that the entire assembly will be a single mesh in Blender. If you want different colors for different parts of the model, you will have to break it up in Blender. (See Blender documentation on this). Once the model is in Blender, follow the steps above under the section "Touchup robot in Blender and export to .OBJ" to continue the import into MSRS.




.STL → STL_UTIL → MSRS


It is possible to skip the Blender step and use the STLUTIL program to convert a .STL file directly into a .OBJ file. STLUTIL can be downloaded here: http://www.ptcuser.org/rugs/U52/downloads/index.html

Notes:
* SolidWorks will export an assembly as multiple .STL files. Each part will have its own .STL file. (This is probably unacceptable for what you want since these multiple objects will need to be combined back into a single file.)
* Alibre will export an assembly as a single .STL file. (This is probably unacceptable for what you want since you can't have different colors for different parts.)
* STL_UTIL doesn't put vertex normals in the .OBJ file. This makes the models look really bad in MSRS.
* You will have to add a color to the model manually.




.bmp → .3ds/.obj → MSRS


To do that, you have to create a .bmp file with MS paint. Then, as explained in this video: http://www.youtube.com/watch?v=mu7PcaiBq8I you can create a 3D model out of your 2D painting. The 3D model then can be exported. After exporting, the model consists of two files: ".obj", and ".mtl". These files (when stored under the "../store/medeia" directory) can be presented in the Microsoft Robotics Studio simulated environment. To do that you will need to use the following line in your code: AddConvexMesh("myobject.obj", new Vector3(0f, 0f, 0f));.

Notes:
* You will need to purchase "SketchUp Pro" or use the trial version for a limited time.
* In general, it would be better to get a CAD file of floor plan rather than generating a bitmap. Then Google "Sketch Up Pro" will generate a better and more accurate 3D representation of the model.
* Original thread: http://groups.google.com/group/SketchUp3d/browse_thread/thread/1aa3eede1aee61ea/
* A related thread in the Microsoft Robotics Studio forum: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2617609&SiteID=1