Generate CUDA for a robot#
GRiD’s code generator lives in grid_codegen/ in this repository. It
produces a robot-specific grid.cuh header; generating the header does
not compile or run CUDA. Complete the source installation first, including the Git submodules.
Generate a header#
From the repository root:
grid-generate config/robot_assets/iiwa14.urdf --algorithm-list dynamics -o /tmp/iiwa_grid.cuh
--algorithm-list restricts emission to named algorithms or profiles.
Omit it to use the full profile. Add -f for a floating base; use
--no-mujoco-kernels to omit the additional MuJoCo-convention kernels.
For collision geometry, see Collision code generation.
Generate from Python#
from URDFParser import URDFParser
from grid_codegen import GRiDCodeGenerator
robot = URDFParser().parse("config/robot_assets/iiwa14.urdf")
generator = GRiDCodeGenerator(robot)
generator.gen_all_code(
algorithm_list=["dynamics"],
output_path="/tmp/iiwa_grid.cuh",
)
GRiDCodeGenerator is the Python class name, not a separate repository
or installable module. GRiD’s code generator vendors GLASS device-side
linear algebra into the header by default. Set vendor_glass=False when
using an external glass.cuh on your C++ include path.
Use the generated code#
For Python applications, Python Wrappers (grid-rbd) handles generation, compilation and caching through
grid_rbd.load_robot(...).For CUDA applications, include the header in a CUDA C++ translation unit. See GRiD’s code generator for the entry-point layers and Library-safe initialization and cleanup for allocation and cleanup.
Use Fast Robot Setup to reduce large-robot build time and memory, and CUDA Validation And Performance Reporting to check generated results.