Visualisation utilities for krec files
krecviz_leg2.mp4
pip install git+https://github.com/kscalelabs/krecviz.git
# or clone the repo and run
pip install -e .
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
Instructions here.
# cd to the repo root
cargo build
NOTE: For now, in the rerun viwer, make sure to select "log tick" as the time unit. will fx this soon
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"
)
You can either run krecviz as a standalone CLI or call its functionality directly as a library.
# 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
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).
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
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
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
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