Difference between revisions of "Mged simulation"

(mged_simulation tutorial)
 
Line 4: Line 4:
  
 
First open the mged tool, if you have BRL-CAD installed on your Linux system it should be easy, just type mged in a terminal and a mged terminal should open.
 
First open the mged tool, if you have BRL-CAD installed on your Linux system it should be easy, just type mged in a terminal and a mged terminal should open.
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 10: Line 10:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
In the mged terminal select the File menu, and then on the New... (file dialog button). A window will appear and a name for your new database will be required. For the purpose of this tutorial we will name the new database, sim1. Introduce the chosen name (sim1) in the "File name:" field and hit save.
 
In the mged terminal select the File menu, and then on the New... (file dialog button). A window will appear and a name for your new database will be required. For the purpose of this tutorial we will name the new database, sim1. Introduce the chosen name (sim1) in the "File name:" field and hit save.
 
Now you have opened a new database. Next we want to add some geometry to the database. Something that we will have to simulate on.  
 
Now you have opened a new database. Next we want to add some geometry to the database. Something that we will have to simulate on.  
 
In the mged command window we will now type the following series of commands :
 
In the mged command window we will now type the following series of commands :
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 23: Line 23:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
The "in" command creates new geometry, it allows the user to type in the arguments to create a shape with the name provided by the second argument, in the example above is the name provided when "Enter name of solid:" appears on the screen. The arguments of the in command can be provided one by one, as in the example above or in one single line, like in the example below:
 
The "in" command creates new geometry, it allows the user to type in the arguments to create a shape with the name provided by the second argument, in the example above is the name provided when "Enter name of solid:" appears on the screen. The arguments of the in command can be provided one by one, as in the example above or in one single line, like in the example below:
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 31: Line 31:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
We have so far a box, now we want to add a ground plane to our simulation.  
 
We have so far a box, now we want to add a ground plane to our simulation.  
  
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 40: Line 40:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
You should see now 2 boxes on your screen, one perpendicular on the other one, with a little overlap between them.  
 
You should see now 2 boxes on your screen, one perpendicular on the other one, with a little overlap between them.  
 
Using the sed command we will select the box and translate it 100 units on the Y axis.
 
Using the sed command we will select the box and translate it 100 units on the Y axis.
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 51: Line 51:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
To be able to run the simulate command our geometry shapes should be grouped in regions to do this we will use the "r" command and create 2 regions for the box and the ground shapes.
 
To be able to run the simulate command our geometry shapes should be grouped in regions to do this we will use the "r" command and create 2 regions for the box and the ground shapes.
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 60: Line 60:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
Now we are ready to run the simulate command:
 
Now we are ready to run the simulate command:
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 68: Line 68:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
After the simulation runs its course, we will use the "who" command to find out what objects are being displayed.
 
After the simulation runs its course, we will use the "who" command to find out what objects are being displayed.
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 76: Line 76:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
You should get the following answer:
 
You should get the following answer:
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 84: Line 84:
 
</pre>
 
</pre>
 
|}
 
|}
 
+
<br>
 
Now, we don't really want to display the box and the ground shapes, we already have them in the sim.c group so we will unload all the geometry(using the "Z" command) and will load only the simulate geometry(using the "draw sim.c" command).
 
Now, we don't really want to display the box and the ground shapes, we already have them in the sim.c group so we will unload all the geometry(using the "Z" command) and will load only the simulate geometry(using the "draw sim.c" command).
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 94: Line 94:
 
|}
 
|}
  
 
+
<br>
 
Now to actually see the simulation we will raytrace it, using the "rt" command.
 
Now to actually see the simulation we will raytrace it, using the "rt" command.
 
+
<br>
 
{|align="left"
 
{|align="left"
 
  |<pre>
 
  |<pre>
Line 102: Line 102:
 
</pre>
 
</pre>
 
|}
 
|}
 +
<br>

Revision as of 12:40, 10 September 2012


BRL-CAD recently integrated a new command in its mged tool, the simulate command. Those are the steps one should follow in order to run a simulation in the mged tool.

First open the mged tool, if you have BRL-CAD installed on your Linux system it should be easy, just type mged in a terminal and a mged terminal should open.

brlcad@brlcad: mged


In the mged terminal select the File menu, and then on the New... (file dialog button). A window will appear and a name for your new database will be required. For the purpose of this tutorial we will name the new database, sim1. Introduce the chosen name (sim1) in the "File name:" field and hit save. Now you have opened a new database. Next we want to add some geometry to the database. Something that we will have to simulate on. In the mged command window we will now type the following series of commands :

mged> in
Enter name of solid: box
Enter solid type: rpp
Enter XMIN, XMAX, YMIN, YMAX, ZMIN, ZMAX: -1 1 0 5 -1 1


The "in" command creates new geometry, it allows the user to type in the arguments to create a shape with the name provided by the second argument, in the example above is the name provided when "Enter name of solid:" appears on the screen. The arguments of the in command can be provided one by one, as in the example above or in one single line, like in the example below:

mged> in box rpp -1 1 0 5 -1 1


We have so far a box, now we want to add a ground plane to our simulation.


mged> in ground rpp -15 15 -1 1 -15 15


You should see now 2 boxes on your screen, one perpendicular on the other one, with a little overlap between them. Using the sed command we will select the box and translate it 100 units on the Y axis.

mged> sed box
mged> tra 0 100 0
mged> accept


To be able to run the simulate command our geometry shapes should be grouped in regions to do this we will use the "r" command and create 2 regions for the box and the ground shapes.

mged> r region1.r u box
mged> r region2.r u ground


Now we are ready to run the simulate command:

mged> simulate 100


After the simulation runs its course, we will use the "who" command to find out what objects are being displayed.

mged> who


You should get the following answer:

box ground sim.c


Now, we don't really want to display the box and the ground shapes, we already have them in the sim.c group so we will unload all the geometry(using the "Z" command) and will load only the simulate geometry(using the "draw sim.c" command).

mged> Z
mged> draw sim.c


Now to actually see the simulation we will raytrace it, using the "rt" command.

mged> rt