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

Uploaded CPython 3.14tmacOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.12-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.12-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.12-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.12-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 45cb270167829e025c39a4694fd065fcfb0c4b6bd4d63446fd8cac9ff714cea7
MD5 6dbb0bf2555cc4bed1f187162d2c7a1c
BLAKE2b-256 e7287b57ea0abc14b9dd500c6173d5547df2429840096193250d343ba6a3e6d3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e305667c2d9e6d63a16e2eb0dc82caa3951fda0554962874a71f18f643bef0d
MD5 ee02ecd4378ae7834122ce5530fc8cde
BLAKE2b-256 75dbf35dda207f1db34308d4bac95920614146c99dd844f5672288d06877f884

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 20f23f6605003193ab23a7e90953e3cf76505d4a1b6d6f458952a3931ad72b83
MD5 f8cc3e1339179fb609de273e5fb0e6a3
BLAKE2b-256 d9fcafeb7328e653fcc0c2950e8f54572d8009b3a45114f34ea79c6fb45d1bc3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc8a2d80169e788800108e2bb62a8e66dda47930603538dfcd6c87a7de3ce07f
MD5 53e72e66c79e5d0b0a7bf30bd4a737e7
BLAKE2b-256 09f5fdd048dbe5da909fd9a2ba47540bfdf44ec60f153d6560ae95cf4af6f1ba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b25f243f35eb3adffc3499cf5a7c68d1d18505185e385e4d4393e2b85076bff5
MD5 2f0fa7fb8dd86bd3b4cba6b96112a404
BLAKE2b-256 22b2d2762e510718e15072504eb90973dbccedb601eb1e5f2ce53752389bc3b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e099fee5d11b737c3ee7386d18b17294a144e6f44eb5dc9b84d5e23bec40ea39
MD5 5aeda1f2ba34d82ceb49a572be9d1f91
BLAKE2b-256 51d413037ff90ed50c39d882c8f8b7bee9861efcf2ad4ab494cd6bf03d900508

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a9d05a2c06d506f232a25ccbf8d4ea220eddd72b46d50d54b94fbb1c06c34b62
MD5 4fe85c4c49f66a1bd5d453e33c8041d2
BLAKE2b-256 aef0663ca54ceec3383a28c842b5c68a07c378932d66aa8673219c807ef246bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76678cbc06fc8b1155829be324a410a4c4ed18655927539c18af2086c688521d
MD5 5f091c411334689db95f7127a1ca307c
BLAKE2b-256 cb44193c13743cb14139a5ceefce969cdeecfde658b17e7d4505c58e30911c96

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 50abe87d6fdeb2d6a81f0605d036d9bd640a67023ad8c08b73dfcde8fb1d56b1
MD5 5844b973ed5a70c2e2ea3a78496f6f46
BLAKE2b-256 cd9bb38604ec8736cc9017a204e9c1b70c7802e5e256e39262d0da4f95f0a2e7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for slamd-2.1.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31e334ad18d381772e06054c0e5e097aed0910154e9c09a63dbe8c5d0ad16c24
MD5 188fb2778049ae623c0a393421af3d05
BLAKE2b-256 0836f7d76ee910be173cddb21c2c2debe9329d4a94bc3e8c1e852798681bf305

See more details on using hashes here.

Provenance

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