Skip to content

kscalelabs/krecviz

Repository files navigation

krecviz

Visualisation utilities for krec files

image

krecviz_leg2.mp4

Installation

Python

pip install git+https://github.com/kscalelabs/krecviz.git
# or clone the repo and run
pip install -e .

Rust

Install Protocol Buffers

First, make sure you have protobufs installed for the krec dependency. Follow these commands to install it:

cd /tmp
wget https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip
unzip protoc-28.3-linux-x86_64.zip
sudo cp bin/protoc /usr/local/bin/protoc

Install the Rerun Viewer

Instructions here.

Build the krecviz Rust library

# cd to the repo root
cargo build

Usage

NOTE: For now, in the rerun viwer, make sure to select "log tick" as the time unit. will fx this soon

image

Python

CLI usage:

# cd to the repo root
cd krecviz

python -m krecviz.visualize \
    --urdf ../tests/assets/urdf_examples/gpr/robot.urdf \
    --krec ../tests/assets/krec_examples/actuator_22_right_arm_shoulder_roll_movement.krec

Python API usage:

import krecviz

krecviz.viz(
    krec_path="path/to/recording.krec",
    urdf_path="path/to/robot.urdf"
)

Rust

You can either run krecviz as a standalone CLI or call its functionality directly as a library.

1) CLI usage (via cargo run)

# cd to the repo root
cargo run -- \
    --urdf tests/assets/urdf_examples/gpr/robot.urdf \
    --krec tests/assets/krec_examples/actuator_22_right_arm_shoulder_roll_movement.krec

# run in debug mode 
RUST_LOG=krecviz=debug cargo run -- \
    --urdf tests/assets/urdf_examples/gpr/robot.urdf \
    --krec tests/assets/krec_examples/actuator_22_right_arm_shoulder_roll_movement.krec

2) Using the library from another Rust project

We haven't published the krecviz crate yet, so you need to add it as a dependency in your Cargo.toml:

[dependencies]
krecviz = { path = "../krecviz" }

Then simply call viz:

use anyhow::Result;
use krecviz::viz;

fn main() -> Result<()> {
    viz(
        Some("path/to/robot.urdf"),
        Some("path/to/robot.krec"),
        Some("path/to/output.rrd"), // optional
    )?;

    Ok(())
}

You can leave any of the arguments as None if you don't have them (e.g., no .rrd output).

Tests

Python

Various examples from the web

These tests will show what a correct visualization should look like.

In the krecviz/tests/test_visualize.py file, you can uncommnet which visualization test you want to run. (In python, running multiple visualizations from the same file overwrites the previous visualization, so one at a time for now.)

# cd to the repo root
# uncomment the test you want to run
python -m tests.test_visualize 

Manual URDF

The file krecviz/tests/test_manual_urdf.py creates a minimal URDF with 3 links, 2 joints, and visualizes it.

You can then visualize this same URDF with rust to see the difference in the rotation, and compare the logs.

# cd to the repo root
python -m tests.test_manual_urdf

Rust

Various examples from the web

These tests will show incorrect rotations, despite having the same logic as the python code/tests.

# cd to the repo root
# uncomment the test you want to run
cargo test
# to get the logs as well, do 
RUST_LOG=krecviz=debug cargo test -- --nocapture

Manual URDF

To visualize the manual URDF created by the python script above, we simply pass the path to the urdf file to the rust code.

# cd to the repo root
cd krecviz_rust
# uncomment the manual_urdf test
cargo test
# to get the logs as well, do 
RUST_LOG=krecviz=debug cargo test -- --nocapture

About

Visualisation utilities for krec files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published