amino
Lightweight Robot Utility Library
|
The scene graph compiler aarxc
parses scene files and outputs C code, which you can compile and link either statically into your application or into a shared library.
Compiled scenes do, however, present an initial, one-time compilation cost, around 10-20 seconds for common robot models. The following table summarizes average compilation time (10 runs) – including mesh processing, code generation, and C compilation – using Blender 2.77 and GCC 4.9.2 on an Intel(R) Core(TM) i7-4790:
Robot | Compilation Time | Run-Time Loading |
---|---|---|
Rethink Baxter | 14.0s | 0.33ms |
Universal UR10 | 11.7s | 0.17ms |
Kinova Jaco | 15.6s | 0.20ms |
The following command will convert the Example Scene into the C file table.c
:
aarxc table.robray -n table -o table.c
To simply view a scene file, use the --gui
option:
aarxc --gui table.robray
Note: Aarxc converts any meshes referenced in the source scene file to Wavefront OBJ using Blender and then directly parse the OBJ file. To load non-OBJ meshes (e.g., COLLADA/DAE), you must have Blender installed.
If your application needs to deal with only a particular scene graph, then you can link directly against the compiled C file.
If your application may need to deal with a variety of scene graphs, you can compile the C files for the scene graphs as shared objects and dynamically load them using aa_rx_dl_sg().
If you have a single scene graph and a single application, then it is sufficient to statically link the scene graph into your application, just as you would with any other C file. For example, to compile and link using GCC:
PKG_CONFIG_MODULES="amino amino-gl sdl2 glew" CFLAGS="$CFLAGS `pkg-config --cflags $PKG_CONFIG_MODULES`" LDFLAGS="$LDLAGS `pkg-config --libs $PKG_CONFIG_MODULES`" gcc $CFLAGS $LDFLAGS table.c MY_OTHER_SOURCE_FILES -o MY_PROGRAM
(Of course, you would typically use a build automation tool such as Make, the Autotools, or CMake.)
Then, load the scene graph with the following C code:
FindPkgConfig
If multiple applications need to use the same scene graph, you will reduce disk and memory use by compiling the scene graph into a shared object. The details of building shared libraries vary by platform and are best managed with build automation tools such as the Autotools or CMake. For simple cases using gcc on GNU/Linux, you can build a shared library as follows:
PKG_CONFIG_MODULES="amino" CFLAGS="$CFLAGS `pkg-config --cflags $PKG_CONFIG_MODULES`" gcc -shared -fPIC $CFLAGS table.c -c -o libscene-table.so
The code to load the scene graph is identical to the static linking case.
add_library
For dynamic loading, the scene graph C file must be compiled into a shared object. Amino provides the convenience function aa_rx_dl_sg which will load the shared object (via dlopen) and call the contained function to load the scene graph.
To load the previous table example after compiling the C code to shared object "libscene-table.so":
Set the ROS_PACKAGE_PATH
environment variable to point at your ROS installation, and call aarxc
. For example, to compile the URDF for the Baxter robot:
export ROS_PACKAGE_PATH=/opt/ros/indigo/share/ aarxc 'package://baxter_description/urdf/baxter.urdf' -o baxter-model.c -n baxter