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.10-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.10-cp314-cp314t-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

slamd-2.1.10-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.10-cp314-cp314-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

slamd-2.1.10-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.10-cp313-cp313-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

slamd-2.1.10-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.10-cp312-cp312-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.10-cp311-cp311-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

slamd-2.1.10-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.10-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f54e25bb91b3f8e456ad3a8bada139e819e142f6b54c743fb34c792916d1828
MD5 94e817023ecd9e513b38456204d0edfe
BLAKE2b-256 15751c4eefb04e44e204b85ba08353f1dc664773ee2137e2a2876e4af64bd9cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e44940d05e738d9593989eac362534dcaecb05f88c6d5f76d943a713f5c2ce39
MD5 ce93264bcfc3f46388ca7cdd95f2db3d
BLAKE2b-256 6a31ad30b0c3bc93d3b515b2af48a44666abcc3e730451e9c06a7ae7fe881b74

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7f61b1584d792636dfd03957fe7b7debfc56df7cc6825fa7ee1840373bee4837
MD5 8277947cce5b1a5813df1bda9bdf910c
BLAKE2b-256 cb0cd4fb9949a62418e09ebec0579073d90c4c1bd652431f602aa483b5a4fba0

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb622ad05ec8c6d334722e408c9afe4b4fbcf745f664adb6c8c85ac893ad017e
MD5 868d0aca50f098df272782c6f6be7fe1
BLAKE2b-256 57764c36910dbb387832ebc40329e1edafc8be5327e68ecd8c2ad38024ea3924

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 803e720149ab907fe4e7dd1d8e269148581da4f2e4cd702fee259ce435f9b4dd
MD5 68876adbe7e41bdc5d27f36f90a3f4aa
BLAKE2b-256 bb2a41386ce90ddaf06792a5f6bb7fe4a390116157922647acad02efbc9840ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ca44d9a659383756ff7490d96cc60baa06a8e0dc50b5e39e4993aeffac84cbb
MD5 b1276393b0ae1a3d9e72ba1432968961
BLAKE2b-256 cec7a9ccb5594de91aa2e8c620616451f4bb7a25ddb9a5fc3133448b155a29da

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c699148482333c12a1142d49160b590af8ccca61b2a8072697e52bcf5f7d85c2
MD5 12a5e92f6581470a19defc8c2ada3b18
BLAKE2b-256 b7e0a29715392b88fc126b23fcd655b1ffa1b81e388a18f16a935265c30f883c

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a89c178489a3cfd8c6fe31e90991a5d473deda5252db56ebd423967bdce41939
MD5 80fe3af7f4afe825af7cd4f0c59644a7
BLAKE2b-256 f20c8cdd8c9d247c2a7e071c20969321217cb6f4aed3a9fe744f8196ab61bf76

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2586a8352e089028637f23f81a647ddf76855409745d963685c174614dc9d903
MD5 4eaa8ec5191717e9cad90e5569f80793
BLAKE2b-256 ce5521a0cee5b02af80e34eca95ba17acb492e3eafd0e227c551f86a6b0089af

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b695ef872cdad418fd6975becfdc06f8a4e65d888105e584934511e21a67b091
MD5 2dbc0d026397f6b2df8f1ab3b4512dfc
BLAKE2b-256 68b91a3f4e755a7387c52a88f0109289a9c2813d88b9eae742073a14a947a668

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.10-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