Skip to content

Added python bindings for iiwa generated grid.cuh file #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kawotwi
Copy link
Collaborator

@kawotwi kawotwi commented May 13, 2025

Changes

This PR adds Python bindings for CUDA-accelerated rigid body dynamics algorithms using pybind11. The goal is to expose key GRiD functionality—like inverse dynamics—to Python for easier integration, testing, and scripting.


Highlights

  • Exposes CUDA logic to Python via pybind11
  • Adds GRidDataFloat Python class in pybind logic
  • Implements .load_joint_info() and .inverse_dynamics()as well as others included in grid.cuh within this PR.
  • installs via pip install -e .
  • Integrates CMake with setuptools (setup.py)
  • Separates device-only code to avoid host compilation errors

How to Use

Install:

cd bindings
pip install -e .

Basic usage:

import gridCuda
import numpy as np

q = np.zeros(gridCuda.NUM_JOINTS, dtype=np.float32)
qd = np.zeros(gridCuda.NUM_JOINTS, dtype=np.float32)
u = np.zeros(gridCuda.NUM_JOINTS, dtype=np.float32)

g = gridCuda.GRidDataFloat()
g.load_joint_info(q, qd, u) # customizable can do random as well. 
c = g.inverse_dynamics()

Notes

  • Currently supports fixed-base robots only for now based on logic that checks joint length sizes but this can be a q uick change.
  • CUDA resources (streams, device memory) are initialized and released properly.
  • Resolved issues with host-side compilation of device-only symbols like blockDim and __syncthreads.

Next Steps

  • Add unit tests for Python bindings
  • Document edge cases and expected input formats
  • Add performance benchmarks and profiling tools

Questions / Discussion

If anyone has thoughts on how to extend this to batched dynamics calls or better handle stream management, please share.


📁 Directory Changes

GRiD/
├── bindings/
│   ├── grid_cuda.cpp        # pybind11 wrapper
│   ├── setup.py             # builds shared object via CMake
│   ├── CMakeLists.txt
│   └── ...
├── include/
│   └── grid.cuh             # CUDA dynamics logic

kawotwi and others added 4 commits May 13, 2025 14:54
…imited number of functions represented in the current grid.cuh in the bindings folder. This is a good template for adding python bindings and can be easily followed to create more applications. Follow the readme for instructions or @me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant