Skip to content

Latest commit

 

History

History
68 lines (54 loc) · 1.81 KB

File metadata and controls

68 lines (54 loc) · 1.81 KB

Astra SDK bindings for Rust

Rust bindings to the Orbbec Astra Sdk

Prerequisites to use this library

  • Download and install the Orbbec Astra Sdk
  • make sure you have these envs in your .profile
# adjust astra home to your astra_sdk path
export ASTRA_HOME=$HOME/astra
export ASTRA_SDK_INCLUDE=$ASTRA_HOME/include
export ASTRA_SDK_LIB=$ASTRA_HOME/lib
# this is so that rust executables know where to find the astra libs
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ASTRA_SDK_LIB

Compiling to Android with feature godot

  • The gdnative-sys dependency requires openjdk-8 headers to be in /usr/include
  • install openjdk-8
  • sudo cp -r /usr/lib/jvm/java-8-openjdk/include /usr/include
  • sudo cp -r /usr/lib/jvm/java-8-openjdk/linux/include /usr/include

Example

Starting with an empty project

cargo init --bin

add dependency

[dependecies]
astra = { git = "https://github.com/rustmain/astra-rust" }

Get first 200 body frames

fn main() -> astra::Result<()> {
    // will stop automatically if fallen out of context
    let mut sensor = astra::Sensor::new();
    // will return err if already initialized
    sensor.init()?;
    // will return err if already started
    sensor.start_body_stream()?;
    let mut index = 0;
    while index < 200 {
        // have to call update in order to get the frame which you need to get data
        if let Ok(frame) = sensor.update() {
            if let Ok(bodies) = sensor.get_bodies(&frame) {
                for body in bodies {
                    for (jt, joint) in body.joints {
                        println!("{:?}: {:?}", jt, joint.world_position);
                    }
                }
            }
        }
        index = sensor.get_body_index();
    }
    Ok(())
}