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

Uploaded CPython 3.14tmacOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.11-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.11-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.11-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.11-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09760bd10a9ef3986b6c65a15e7e3a955b7ab85b199463006bf616ee10aabb70
MD5 ff05fb08114c300ceee602415524f4d9
BLAKE2b-256 e60e79e85a72d12dabe8a95072699d9e9132d625a5d67d68d21dce61ac7a5a42

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 85f2018c285c11cf821cda4fbca87d1f394380a55f47db3dacc5297d5bae2d4a
MD5 75559c91bd6cb4fe7ac3a43d9d062f38
BLAKE2b-256 5c72aef921ac9790935b9877c055117f41600388c915ea421ef4300c86eeff83

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14ae108b1cfacf9beb67dad88a28578e438f75d49386ef2cd401609bc7fead39
MD5 11243adc8810be7b958188c3ad3c2306
BLAKE2b-256 191bf95603490a1bf24b7ef72bf55ae90b6e08e6ac4928acd4b141c1aa7fa9f7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6bfaee6f50a1142d74384fe86f97d654658c69a722e040537c124438ccac0ed
MD5 1382b9685a5dcd31bcf5c814b1bfa60f
BLAKE2b-256 9665e0c78ac318d0f814f1adfe291809f05a110d1403b1caa544b2f145f794e6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e75d93a3ffa10ba15638b7bf8c14b29b184614f969552aa7ccf3fa93af2a8b1
MD5 c9d147c5912d16a27e534c8dc401d98c
BLAKE2b-256 efec13e41f94ef25e0046c4f7a9368b7fc8c108f31eb0a87e004abebd40332f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d250b7f7cc0fd34a7d780dd24e277e6f4f9e9806ab5335511ca21614c219ed2
MD5 7f1393b657686926a3be45f999aac7c9
BLAKE2b-256 8c963ddc92dbeca7d490ee8cd6c1998d26c0e7df6a46db1c4c2c358c71bca4ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0535b861da4a0d153eaf81599de0b05c1b72bdcefe54743dbde99c7b05561300
MD5 01b49411e5f3a433b175ee91f9e19321
BLAKE2b-256 6db86db9afea186e479555f88d89d43ad640a7531a7ccc54f4e24b2258e9f969

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b431d17d435d7a14146079f26a719491178cc02bd9a6a6b3ff9dc49384d98f5
MD5 08687b9498dc67a37492ff82e1ea1c18
BLAKE2b-256 d90fbe950d9819581c3e7a539a111799c5e41bfc10cda2b6a374e948886a8dbd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 894c873424ffd747312620192e0ea241f47c5d36be40c13f4322f80d55ed3b1e
MD5 3b757dd664ff80d175968c461879b03b
BLAKE2b-256 fcf7b71a21dc18ed3eda731404a80b098d9c19bb2b42178e8c0d272a2626d6de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c73a8d0137b4d6670be016c73eda6fa83d382a9b1a0298c1c5ebae2debd0cbe
MD5 2eb5a3c761e2a743190622fa14cacced
BLAKE2b-256 5cf957221a11f088a0767ff5e4837628516f6be5744c7d4bad27821b50901a51

See more details on using hashes here.

Provenance

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