Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Larod #120

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
151cd8c
Add larod-sys crate
JsGjKJzi Oct 25, 2024
8d3defa
Add bindings.
JsGjKJzi Oct 25, 2024
709d58c
Drop back to ACAP SDK 1.3. Get larod crate fleshed out a little to do…
JsGjKJzi Oct 26, 2024
e158693
Swap back to x86_64
JsGjKJzi Oct 28, 2024
024e491
Start implementing LarodMap
JsGjKJzi Oct 28, 2024
56d3720
Implement get_string, get_int_arr2, get_int_arr4.
JsGjKJzi Oct 29, 2024
51e2518
Merge remote-tracking branch 'origin/main' into feature/larod
JsGjKJzi Oct 29, 2024
3d510b6
- Improved error handling to always deallocate a larodError object if…
JsGjKJzi Oct 30, 2024
3e004a0
Added builder pattern for LarodClient.
JsGjKJzi Oct 30, 2024
021ea65
Add log.
JsGjKJzi Oct 31, 2024
f9e0506
Start adding LarodDevice and Session
JsGjKJzi Oct 31, 2024
c05a0a1
Add remote testing
JsGjKJzi Nov 2, 2024
e0fa140
Hide on-device tests behind a device-tests feature
JsGjKJzi Nov 2, 2024
147e438
Inverted remote-test.sh check for CARGO_TEST_CAMERA definition
JsGjKJzi Nov 2, 2024
32db020
Update larod_sys/src/bindings.rs to match new enum style.
JsGjKJzi Nov 4, 2024
b3607bf
Change to EnumVariation::Rust as default bindgen enum style.
JsGjKJzi Nov 6, 2024
a5d62d5
Improve error handling and add documentation
JsGjKJzi Nov 6, 2024
4309ed6
Fix test failure due to renamed method.
JsGjKJzi Nov 6, 2024
de2367b
Remove note that is no longer needed.
JsGjKJzi Nov 6, 2024
1dc6896
Run executable is no camera.
JsGjKJzi Nov 6, 2024
55a7158
Explicitly tie the lifetime of LarodDevice to the lifetime of the Ses…
JsGjKJzi Nov 7, 2024
b294ca3
Don't copy larodDevice data from C to Rust, just provide access via f…
JsGjKJzi Nov 9, 2024
bdeda81
Unwrap result for test listing devices.
JsGjKJzi Nov 9, 2024
1eb3252
Make LarodDevice.get_name() and LarodDevice.get_instance() public.
JsGjKJzi Nov 9, 2024
7941c92
Align getters/setters with RFC344.
JsGjKJzi Nov 9, 2024
59b9ac5
Fix getter names missed in previous commit.
JsGjKJzi Nov 9, 2024
4373b18
Start stubbing LarodModel.
JsGjKJzi Nov 9, 2024
cdaf42b
Remove `bin` crate type from [[example]]
JsGjKJzi Nov 15, 2024
ff868cb
Stub out Tensor struct.
JsGjKJzi Nov 15, 2024
0382a94
Add LarodModel Trait
JsGjKJzi Dec 3, 2024
c03e898
Merge branch 'main' into feature/larod
JsGjKJzi Dec 3, 2024
300af7e
Explicitly use height and width parameters for setting sizes.
JsGjKJzi Dec 17, 2024
4b2f2cb
Implement Send and Sync for LarodError.
JsGjKJzi Dec 18, 2024
486757a
Rename LarodModel.start() to LarodModel.start_job().
JsGjKJzi Dec 18, 2024
714a8bd
Add env_logger as dev dependency for printing data during test.
JsGjKJzi Dec 18, 2024
60b770f
Merge branch 'main' into feature/larod
JsGjKJzi Dec 19, 2024
ec86ed3
Delete remote-test.sh in root directory.
JsGjKJzi Dec 19, 2024
2380e9c
Remove default build target.
JsGjKJzi Dec 19, 2024
c3a87f4
Implement iterating over `Tensors` pointed to by `LarodTensorContainer`.
JsGjKJzi Dec 19, 2024
ae1384c
Add compiler failure tests.
JsGjKJzi Dec 19, 2024
0eea902
Update larod basic example.
JsGjKJzi Dec 19, 2024
d6a0e22
Merge branch 'main' into feature/larod
JsGjKJzi Dec 31, 2024
63e4875
Clean up a few lints for unused results and imports.
JsGjKJzi Dec 31, 2024
9be7b76
Implement iterating over Tensors.
JsGjKJzi Dec 31, 2024
65de920
Update basic example for iterating over tensors.
JsGjKJzi Dec 31, 2024
682cb21
Add anyhow development dependency for basic example.
JsGjKJzi Dec 31, 2024
670fb23
Update cargo lock file for anyhow dependency.
JsGjKJzi Dec 31, 2024
845fadb
Implement ops::Deref for LarodTensorContainer<'a> for Target = [Tenso…
JsGjKJzi Jan 2, 2025
44e00d7
Implement ops::DerefMut for LarodTensorContainer<'a> for Target = [Te…
JsGjKJzi Jan 2, 2025
620808d
Add memory mapped buffer for Tensor.
JsGjKJzi Jan 2, 2025
fff440f
Use file, not self.buffer when setting buffer on Tensor.
JsGjKJzi Jan 2, 2025
9c96b53
Create model outputs.
JsGjKJzi Jan 2, 2025
295dfc8
Add JobRequest struct from larodCreateJobRequest.
JsGjKJzi Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build]
target = "aarch64-unknown-linux-gnu"

[target.aarch64-unknown-linux-gnu]
runner = ["/workspaces/acap-rs/remote-test.sh"]
18 changes: 10 additions & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REPO=axisecp
ARG SDK=acap-native-sdk
ARG UBUNTU_VERSION=22.04
# Keep in sync with `install-sdk.sh`.
ARG VERSION=1.15
ARG VERSION=1.3
ARG BASE_IMAGE=debian:bookworm-20240423

FROM --platform=linux/amd64 ${REPO}/${SDK}:${VERSION}-aarch64-ubuntu${UBUNTU_VERSION} AS sdk-aarch64
Expand All @@ -25,16 +25,10 @@ ENV \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-args=--sysroot=${SYSROOT_AARCH64}" \
CC_aarch64_unknown_linux_gnu="aarch64-linux-gnu-gcc" \
CXX_aarch64_unknown_linux_gnu="aarch64-linux-gnu-g++" \
PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \
PKG_CONFIG_PATH_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}" \
CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_LINKER="arm-linux-gnueabihf-gcc" \
CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_RUSTFLAGS="-C link-args=--sysroot=${SYSROOT_ARMV7HF}" \
CC_thumbv7neon_unknown_linux_gnueabihf="arm-linux-gnueabihf-gcc" \
CXX_thumbv7neon_unknown_linux_gnueabihf="arm-linux-gnueabihf-g++" \
PKG_CONFIG_LIBDIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \
PKG_CONFIG_PATH_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}"
CXX_thumbv7neon_unknown_linux_gnueabihf="arm-linux-gnueabihf-g++"

COPY .devhost/install-system-packages.sh ./
RUN ./install-system-packages.sh \
Expand All @@ -61,6 +55,14 @@ RUN --mount=type=bind,target=/context \
&& ./install-venv.sh $VIRTUAL_ENV \
&& chmod a+w -R $VIRTUAL_ENV

ENV \
PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \
PKG_CONFIG_PATH_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}" \
PKG_CONFIG_LIBDIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \
PKG_CONFIG_PATH_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}"

# If neither `CARGO_HOME` nor `HOME` is set when launching a container, then cargo will try to
# download crates to this directory. If launched with the `--user` option then this will fail.
# TODO: Replace the example in the README with something that does not mount any volumes.
Expand Down
4 changes: 2 additions & 2 deletions .devhost/install-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eux
DIRECTORY="${1}"

# Keep version in sync with `Dockerfile`.
docker run axisecp/acap-native-sdk:1.15-armv7hf-ubuntu22.04 tar \
docker run axisecp/acap-native-sdk:1.3-armv7hf-ubuntu22.04 tar \
--create \
--directory /opt/ \
--file - \
Expand All @@ -18,7 +18,7 @@ docker run axisecp/acap-native-sdk:1.15-armv7hf-ubuntu22.04 tar \
--strip-components 1

# Keep version in sync with `Dockerfile`.
docker run axisecp/acap-native-sdk:1.15-aarch64-ubuntu22.04 tar \
docker run axisecp/acap-native-sdk:1.3-aarch64-ubuntu22.04 tar \
--create \
--directory /opt/ \
--file - \
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ axstorage = { path = "crates/axstorage" }
axstorage-sys = { path = "crates/axstorage-sys" }
bbox = { path = "crates/bbox" }
bbox-sys = { path = "crates/bbox-sys" }
larod = { path = "crates/larod" }
larod-sys = { path = "crates/larod-sys" }
licensekey = { path = "crates/licensekey" }
licensekey-sys = { path = "crates/licensekey-sys" }
mdb = { path = "crates/mdb" }
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ Important workflows are documented in the [Makefile](./Makefile) and can now be
Development environments outside containers are more difficult to reproduce and maintain.
Should it nonetheless be of interest, one procedure is documented in [this workflow](.github/workflows/on-host-workflow.yml).

## Testing
Some items in this workspace rely on libraries or hardware on Axis cameras. This makes testing difficult since these tests cannot run on an arbitrary x86_64 host. Below are some steps to enable running unit test on device.

1. Connect an Axis camera to your network and ensure it is accessible.
2. The user will likely need to be `root`, such that the Axis camera file system is writable.
3. Set the `CARGO_TEST_CAMERA` environment variable to the user and IP of the camera with the format `user@ip`
4. Set up an identity based SSH connection to the camera.
1. Create an ID via `ssh-keygen`
2. Copy the id to the device via `ssh-copy-id`

Now, via the [remote-test.sh](remote-test.sh) script, and the `runner = ["/workspaces/acap-rs/remote-test.sh"]` line in the .cargo/config.toml, tests with the `aarch64-unknown-linux-gnu` target triplet will automatically be copied to the remote camera and executed there. Run these tests via `cargo test --target aarch64-unknown-linux-gnu`.

If you want to run tests locally, just make sure you clear the `CARGO_TEST_CAMERA` environment variable via `unset CARGO_TEST_CAMERA`.

## Example applications

Below is the list of examples available in the repository.
Expand Down
11 changes: 11 additions & 0 deletions crates/larod-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
build = "build.rs"
name = "larod-sys"
version = "0.1.0"
edition.workspace = true

[build-dependencies]
bindgen = { workspace = true }
pkg-config = { workspace = true }

[dependencies]
23 changes: 23 additions & 0 deletions crates/larod-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::{env, path};

fn populated_bindings(dst: &path::PathBuf) {
let library = pkg_config::Config::new().probe("liblarod").unwrap();
let mut bindings = bindgen::Builder::default()
.header("wrapper.h")
.allowlist_recursively(false)
.allowlist_function("^(larod.*)$")
.allowlist_type("^(_?larod.*)$")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.layout_tests(false);
for path in library.include_paths {
bindings = bindings.clang_args(&["-F", path.to_str().unwrap()]);
}
bindings.generate().unwrap().write_to_file(dst).unwrap();
}

fn main() {
let dst = path::PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs");
if env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default() != "x86_64" {
populated_bindings(&dst);
}
}
Loading