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

Uploaded CPython 3.14tmacOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.9-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.9-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.9-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.9-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 928890467c27daa92f51ad5f4b176eba9f8bba7b05797c7132b0aef8a09080d6
MD5 ca5eebe4b966c6a31c9f449d3b0aebed
BLAKE2b-256 5ebf69d96ed1ec14ba600d26d6835ebf033775d671bfff9503f4a4d7009530c0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33b9298fbbf81eff6e429300ce75be8e33b0b8661f41de1eaf6521d8bdf47519
MD5 4cf0c88b7a33b84be43b8f7c392cdbf8
BLAKE2b-256 a4d604f3075f1a578eab1667db34c1f3c3d96ed2613ebd1a37dc787056cd7e16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af2a69ae575ecbf0b4ce87e3459739f939b04cbadeba7bcc90d3d5dba260e761
MD5 2cdb3b97ab6f62f78eddf00ae1ee0b37
BLAKE2b-256 2e810241225614a6092a16bbfc59f96f471058caabcb1742dc098ab0aaec0d9a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c18e96f5af55a78cbbba4b8e727870474a64fed7f6b07d22071d29a19b6cbcd
MD5 12c6339b02e368e76c3f366766cf6138
BLAKE2b-256 46f36d9a4c37e660fb4cbdf1eb2a1dbe57dc4016530faf2d80b63f5d72169829

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 414013f3a11d43f657560d765c5f21234366c2b50660f3fb0fc8408dd24b2721
MD5 8e200d32c3423d131b7c70f29410ef8b
BLAKE2b-256 46c6ca88548f9c0c35bf97c6eec7f70bfad0d349570d845660ff5740be42d84e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 132a357a7c885eaa4f9e4e0553b34e141076e13dac6eec46177d5eba7e10294d
MD5 739fdfeab4c7735295e25e1afe5cd3ec
BLAKE2b-256 a7ded3e7886abaee2c71d732bd0eb7bd04e11bbec22dd32e556034d0bef13368

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f7a78002b6da8093b64fbae3815da7d58aa5ba59d2e2d9de10ca7b847334270
MD5 d38a05fbdfb27f65305236230e0f4d6e
BLAKE2b-256 f0edb16f6556ffa2c3105aaab8feeec0b4c533e209494efddfcdca007efad251

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a09c7fd06caeb5cf530f279eeaaf4c7a5ee0ccda13b8947bacd5e39ae72ff46c
MD5 0648f18161a17563c3cccb21b91174dc
BLAKE2b-256 b8e64346541ba081f900e8a7dadc2ecffcdb3fd1993514f18c1cfd83544e2436

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5e06cfe08953aaaf6ef5f3b6163712fb5ce872e055994b91dfe9dd557f11e5f
MD5 52a0b144ab97f2eb66218f477966ea02
BLAKE2b-256 7e5b293a9f13fbe163d4f816f5aa631d286fd45c9c7465b6de9373ce0ef6cab7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 746de9c3602d044e7e822420aa9b98bebd7ee07f71a3cd199a594aaec9146008
MD5 28dafc7cd04c7290e0397ed199b3e9ae
BLAKE2b-256 edeb1f38cbf26e7046d4a7984ea308a4a824870e8b28bc2caeec859a4e8ce09e

See more details on using hashes here.

Provenance

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