A CGMOI Primer

Prepared by Jason Bowman

January 14, 1998

The files for the CGMOI code can be found on the AAE451 class account. The path is /home/cartoon/a/aae451/space/structures/cgmoi and can be accessed with the shorthand path as ~aae451/space/structures/cgmoi. “cgmoi” is a directory with many subdirectories. All of the non-interface functions can be found in the subdirectory “core-code”. A set of sizing routines made to work with the CGMOI can be found in the “sizing” directory under “structures”. See the example in the on-line structures manual for details.

The CGMOI code is based on a variable called components. This variable is actually a structure that operates like a C structure. The dot operator is used to access the fields. There are many fields in the components structure. Several examples are “mass”, “volume”, and “evaluate”. Componentscan also be an array of structures. The proper way to access data is

components(n).mass

components(n).dimensions.length

where n is some number between 1 and the number of objects that are stored. The dimensions field is also a structure that stores the dimensions of the object.

There are several basic functions used by the CGMOI code. Some of them can be seen in the “fuselage.m” and “tps.m” functions in the “sizing” subdirectory of the “structures” directory. These functions are

load_vehicle_data

save_components

components_gui

get_inertia_properties

add_component

The first two functions load and save the components structure in ASCII format. Matlab will not do this. Matlab will only save structures in binary format. The option to save in ASCII was given so that you could view the structure outside of Matlab. Note that the load and save functions in the CGMOI interface only work with ASCII files. Binary files have to be loaded with Matlab’s load and save commands. See the example.m file for an example.

Load_vehicle_data is actually a script and not a function. The only requirement is that you have a variable called filename defined that is a string representing the path to the correct file. For example, filename = ‘c:\matlab\bin\myvehicle’. Use forward slashed on a UNIX platform. If the file exists in the directory where Matlab was started (on a UNIX platform), then you can use the filename rather than the whole path. For example, filename = ‘myvehicle’.

Save_components save the components structure in ASCII format. For example,

> save_components(filename, components)

components_gui is a function that takes either no arguments or one argument. With no arguments, the main interface is displayed. With the one argument being the components structure, the main interface is displayed with the components structure loaded into the interface. Note that the interface assumes that the variable is actually called components. The 4 functions listed previously should work with any name as long as you use that name wherever you would use components.

> components_gui

or

> components_gui(components)

get_inertia_properties is what makes the code useful. It does the calculations and updates the mass, volume, and inertia fields of the components structure. It takes the components structure as an argument and returns the updatedcomponents structure, the total mass, the system CG, and the system inertia matrix. You must use an output variable for the changes to be effective.

> get_inertia_properties(components)

Does not update the components structure

[components, mass, cg, inertia] = get_inertia_properties(components)

This works!!!

add_componentallows you to add a component gracefully. While you can do this by hand, the function sets up the proper default values. This is especially important for the dimensions field. It takes 3 arguments and returns 1.

> components = add_component(components, geom, description)

The input geom can be any of the following (also listed in the source code): “cone”, “cylinder”, “sphere”, “rectangular prism”, “rectangular pyramid”, “half sphere”, “half cone”, “ellipsoid”, “plate”, and “frustum”. description is simply a string.

Placing the add_component function in a loop makes adding multiple objects (usually same geom) easy. For an example, see the fuselage.m file where this is done for the fuselage shells.

The interface is almost self-explanatory. There are two extra menus in the figure window. They are “Components” and “Properties”. Under the “Components” menu are the load, save, and draw commands. The “draw” command is also on a button in the interface. The “Properties” menu allows access to other interfaces that allow changes to the mass properties, dimensions, rotations, and drawing properties. The evaluate checkbox sets the evaluate field in the components structure. The evaluate property indicates to the get_inertia_properties function whether or not to include that object in the mass and inertia matrix calculations. The interface checkbox DOES NOT stay in sync as you select different objects. However, as long as you don’t touch the checkbox when you have an object selected, the state does not change even if the checkbox indicates the opposite state. Clicking on the checkbox definitely sets the state to what is displayed after the click. So if you are unsure, one or two clicks to the proper state should do the trick.