Skip to main content

Python bindings for SlamDunk

Project description


SlamDunk is a powerful and user-friendly C++/Python library for making live 3D and 2D visualizations for prototyping, data exploration, and algorithm development.

It is very lightweight, built using OpenGL and ImGui.

Examples

Hello world

Here is a simple "hello world" program for a SlamDunk visualization.

#python
import slamd

if __name__ == "__main__":
    vis = slamd.Visualizer("Hello world")

    scene = vis.scene("scene")

    scene.set_object("/origin", slamd.geom.Triad())

    vis.hang_forever()
// C++
#include <slamd/slamd.hpp>

int main() {
    auto vis = slamd::visualizer("hello_world");

    auto scene = vis->scene("scene");

    scene->set_object("/origin", slamd::geom::triad());

    vis->hang_forever();
}

This example highlights the main components of SlamDunk.

The Visualizer object maintains the state of the visualization, and starts a TCP server that the visualization window connects to.

By default, it spawns a window process that reads from it and displays the visualizations. You can opt out of this with the spawn argument, and control the port with the port argument. In this case, you can start a window with the slamd-window executable:

slamd-window --port [port] --ip [ip]

If you are using C++, this executable is built next to the library.

This client-server architecture allows launching a visualizer a remote server, and connecting to it on your local machine.

A Scene object represents and contains a tree of 3D objects, accessed by paths like /comp1/comp2/comp3. 3D poses and Geometry objects can be assigned with the set_transform and set_object methods.

Geometry objects represent the objects that are displayed in the scene.

Running this program results in the following interactive visualization:

Multiple scenes

SlamDunk uses ImGui to allow multiple sub-windows with floating and docking support inside the SlamDunk viewer. The following example illustrates creating two windows, each showing its own scene.

# python
import slamd
import numpy as np

if __name__ == "__main__":
    vis = slamd.Visualizer("two windows")

    scene1 = vis.scene("scene 1")
    scene2 = vis.scene("scene 2")

    scene1.set_object("/box", slamd.geom.Box())

    scene2.set_object("/origin", slamd.geom.Triad())

    scene2.set_object("/ball", slamd.geom.Sphere(2.0))

    sphere_transform = np.identity(4, dtype=np.float32)
    sphere_transform[:, 3] = np.array([5.0, 1.0, 2.0, 1.0])

    scene2.set_transform("/ball", sphere_transform)

    vis.hang_forever()
// C++
#include <glm/glm.hpp>
#include <slamd/slamd.hpp>

int main() {
    auto vis = slamd::visualizer("two windows");

    auto scene1 = vis->scene("scene 1");
    auto scene2 = vis->scene("scene 2");

    scene1->set_object("/box", slamd::geom::box());

    scene2->set_object("/origin", slamd::geom::triad());
    scene2->set_object("/ball", slamd::geom::sphere(2.0f));

    glm::mat4 sphere_transform(1.0);
    sphere_transform[3] += glm::vec4(5.0, 1.0, 2.0, 1.0);

    scene2->set_transform("/ball", sphere_transform);

    vis->hang_forever();
}

The resulting window looks like this:

The windows are fully controllable - you can drag then around, make tabs, use them in floating mode, dock them to the sides like you see in the screenshot. All of this is supported by ImGui.

Further reading

The C++ examples in /examples and python examples in python_examples showcase some more features of SlamDunk. Some examples are canvases for 2D visualizations and lots of additional geometry primitives such as point clouds, meshes, camera frustums, etc.

Installation

Python

The python binding wheels are available on PyPi, so you can simply

pip install slamd

C++

With FetchContent

You can use CMake's FetchContent. Add this to your CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(
  slamd
  GIT_REPOSITORY https://github.com/Robertleoj/slam_dunk.git
  GIT_TAG main
  SOURCE_SUBDIR slamd
)

FetchContent_MakeAvailable(slamd)

Linking to it then looks like:

target_link_libraries(
    your_target PRIVATE

    slamd::slamd
)

With git submodules

If you add the repo as a submodule in your project, you can add it as a subdirectory with

add_subdirectory(path/to/slam_dunk/slamd)

Just make sure to

git submodule update --init --recursive

inside the submodule, as all necessary dependencies are vendored.

You can then link it to your executable or library with

target_link_libraries(
    your_target PRIVATE

    slamd::slamd
)

Contributions

All contributions and feedback are welcome and apprechiated!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

slamd-2.1.8-cp314-cp314t-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64

slamd-2.1.8-cp314-cp314t-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

slamd-2.1.8-cp314-cp314-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

slamd-2.1.8-cp314-cp314-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

slamd-2.1.8-cp313-cp313-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

slamd-2.1.8-cp313-cp313-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

slamd-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

slamd-2.1.8-cp312-cp312-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl (67.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

slamd-2.1.8-cp311-cp311-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file slamd-2.1.8-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2074a4686b115cd8ad79904c0f4c08c34c3050b41639b958673fa205f9727a1
MD5 102874b99f1bcf09dcb44269e18a5a8a
BLAKE2b-256 1ec1e7ba4445a60133b7eea5c3b38efd3a6aa8ac91ab8e729138b161ba9189cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp314-cp314t-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 face52116447410bd8f52e456558a9a33431195db906df3153bc5ce337f33c7d
MD5 5c0ddb7c82367a3030af308e7da88a8c
BLAKE2b-256 ea52b69f5a0d9ff858b3e58d72abaee9b8fc96a5987f74f0d1ed41ee3e494f48

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 15b11bfe3f05f106127248f59a98d6f7bd76968e03ef3768ceb4879abef44d50
MD5 b81eaab800d14da4b909ae387c05a6ba
BLAKE2b-256 10a3ec8b4222d2b26ed511a46a3f821e25109b990ac96f588d204020735129eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b0cc9b8d6e1c690eca51587dd9aca497018289b4341c817cbfd259ddeda8e6a
MD5 976930fa9f2e2b164cdcfc6933a4a507
BLAKE2b-256 6eaf6f6d4d2ad8dfad54b0d1fe40174eb42abd0bc27ab81c1b94f25323948256

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 faee6ecc08644dc1cfc9348e509aac76560df05ffbc5d4e78935e1b4c981aa65
MD5 cf4503e189b9f3a12e2b2b1e3de7aed4
BLAKE2b-256 942ba2079b5e1f31a305b9b080c9186bd0a3ce4d0dc17b26ce632cc2ffdd2b11

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e418c42d29a34313e9f1788479ae3fa791155856fa036b5b769139231113e3e
MD5 d984de3e3ae1b27f841746fdc40bfb33
BLAKE2b-256 1349678cdd0ac09ebdde0f9db72de2c9464584d5fb29e7962293833dc368e763

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f8a7e9c559f2e9510031926afef90d662dd3be2e3e93182cf238d58a6057b3b5
MD5 803343892b73dc9083b083156b74dc43
BLAKE2b-256 24694b29beaf1edf2f54848889361ae6e363b1666584ee1535caad487ae10552

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c4633b14b2a2e3a27edd50f03f2c4ac621fc2e0e52f7bf33c4ed5dc8c3c81b7
MD5 88a219498a3708f8b8d1ae7e37714543
BLAKE2b-256 69822cbf1048b3800f1a410ac0bde8a389b080d359be763b57a88b56278172a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e5dfd708842e36f790eccd597f1865f1b7afac6b61603f40bb5941d784863ef
MD5 60bcaf97d2ed79e2721c8cf6ec15cdc4
BLAKE2b-256 fb33d00a3194031275e54dc4c2b061880c531f0893eb1155fa5c9ff576fb60dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d96f9172858b9479e01d52821cad901889b6329f24cc0a4237227984b8c0ba7d
MD5 cf9610124e2de4dfe5139b40c54c01a6
BLAKE2b-256 bfc81af59027afba578bbbe7663a63db3488ac76bc1954a64d284dd3439884da

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.8-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page