Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/cargo-deny.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Cargo Dependencies
name: Safe Stage - Check Dependencies
on:
pull_request:
branches: [$default-branch]
branches: [ main ]
paths:
- "**/Cargo.lock"
- "**/Cargo.toml"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Release Service Application
name: Build and Release
on:
push:
tags:
Expand All @@ -23,10 +23,10 @@ jobs:
- name: Build Safe Stage
run: |
cargo run -p bindings
cargo build --release -F ffi
cargo build --release --features ffi
working-directory: ./safe-stage

- name: Publish Service Application
- name: Build Service App
run: |
dotnet publish
working-directory: ./service-app
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/safe-stage-miri.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Check Safe Stage Safety
name: Safe Stage - Check Safety
on:
push:
branches: [$default-branch]
branches: [ main ]
paths:
- "safe-stage/src/*"
- "safe-stage/src/**"
pull_request:
branches: [$default-branch]
branches: [ main ]
paths:
- "safe-stage/src/*"
- "safe-stage/src/**"

env:
CARGO_TERM_COLOR: always
Expand Down
68 changes: 28 additions & 40 deletions .github/workflows/safe-stage.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,20 @@
name: Check Safe Stage
name: Safe Stage - Checks
on:
push:
branches: [$default-branch]
branches: [ main ]
paths:
- "safe-stage/*"
- "safe-stage/**"
pull_request:
branches: [$default-branch]
branches: [ main ]
paths:
- "safe-stage/*"
- "safe-stage/**"

env:
CARGO_TERM_COLOR: always
MSRV: 1.86.0

jobs:
safe-stage-build:
runs-on: ubuntu-latest
strategy:
matrix:
FEATURES: ["--all", "-F ffi"]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./safe-stage/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Check Formatting
run: cargo fmt --all --check
working-directory: ./safe-stage

- name: Build with Features "${{ matrix.FEATURES }}"
run: cargo build --locked ${{ matrix.FEATURES }}
working-directory: ./safe-stage

- name: Run clippy with Features "${{ matrix.FEATURES }}"
run: cargo clippy --locked ${{ matrix.FEATURES }} -- -D warnings
working-directory: ./safe-stage

safe-stage-test:
safe-stage:
runs-on: ubuntu-latest
permissions:
checks: write
Expand All @@ -51,8 +23,6 @@ jobs:
PROFILE_FEATURES:
[
"ci-default;--all",
"ci-features-serde;--all -F serde",
"ci-features-linear;-p collisions --no-default-features -F rayon-bvh-linear",
"ci-features-ffi;-F ffi",
]
steps:
Expand All @@ -67,9 +37,6 @@ jobs:
./safe-stage/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Add nextest
uses: taiki-e/install-action@nextest

- name: Extract Profile and Features
id: extraction
run: |
Expand All @@ -85,6 +52,27 @@ jobs:
echo "profile=$PROFILE" >> "$GITHUB_OUTPUT"
echo "features=$FEATURES" >> "$GITHUB_OUTPUT"

- name: Install Rust with MSRV
uses: taiki-e/github-actions/install-rust@main
with:
toolchain: ${{ env.MSRV }}
component: rustfmt,clippy

- name: Check Formatting
run: cargo fmt --all --check
working-directory: ./safe-stage

- name: Build with Features "${{ steps.extraction.outputs.features }}"
run: cargo build --locked ${{ steps.extraction.outputs.features }}
working-directory: ./safe-stage

- name: Run clippy with Features "${{ steps.extraction.outputs.features }}"
run: cargo clippy --locked ${{ steps.extraction.outputs.features }} -- -D warnings
working-directory: ./safe-stage

- name: Add nextest
uses: taiki-e/install-action@nextest

- name: Run Documentation Tests with Profile "${{ steps.extraction.outputs.profile }}"
run: cargo test --locked --doc ${{ steps.extraction.outputs.features }}
working-directory: ./safe-stage
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/service-app.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Build Service Application
name: Service App - Build
on:
push:
branches: [$default-branch]
branches: [ main ]
pull_request:
branches: [$default-branch]
branches: [ main ]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -36,10 +36,10 @@ jobs:
- name: Build Safe Stage
run: |
cargo run -p bindings
cargo build -F ffi
cargo build --release --features ffi
working-directory: ./safe-stage

- name: Build Service Application
- name: Build Service App
run: |
dotnet build
working-directory: ./service-app
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Only Windows and .NET runtime are needed to run a compiled binary of the service

### Building

- installed Rust with version 1.83 or newer
- installed Rust with version 1.86 or newer
- As of 18/12/2024, the *Nightly* version of the Rust toolchain results in a slightly better performance and is therefore recommended
- installed .NET SDK 8 or newer
- installed `cargo-expand` or selected nightly chain (run `cargo install cargo-expand` to install) - required for generating bindings
Expand All @@ -38,7 +38,7 @@ Only Windows and .NET runtime are needed to run a compiled binary of the service

### MSRV (Minimum Supported Rust Version)

- `1.83.0` - due to stabilization of floats in `const` context
- `1.86.0` - floats in `const` context, trait upcasting coercion


## Building
Expand Down
20 changes: 0 additions & 20 deletions safe-stage/.nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ path = "junit-report.xml"
store-success-output = true
store-failure-output = true

[profile.ci-features-serde]
fail-fast = false

[profile.ci-features-serde.junit]
report-name = "nextest-features-serde"
path = "junit-report.xml"
store-success-output = true
store-failure-output = true

[profile.ci-features-linear]
fail-fast = false

[profile.ci-features-linear.junit]
report-name = "nextest-features-linear"
path = "junit-report.xml"
store-success-output = true
store-failure-output = true

[profile.ci-features-ffi]
fail-fast = false

[profile.ci-features-ffi.junit]
report-name = "nextest-features-ffi"
Expand Down
12 changes: 4 additions & 8 deletions safe-stage/collisions/src/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
//! Composite data structures for accelerating collision detection.
//!
//! Differences:
//! - [BvhTree] - boxes for bounding volumes, slower transformations, tighter bounds,
//! any `Collider` composites, during rotation, AABBs are converted to OBBs
//! - [BvhRecursive] - generic bounding volume hierarchy,
//! recommended to use with [AlignedBoxCollider]
//! - [BvhSphereLinear] - bounding sphere hierarchy, implemented with Vec as node storage,
//! very fast transformations slower collision detection
//! - [BvhSphereRecursive] - bounding sphere hierarchy, variant of [BvhRecursive] but optimized
//! for [SphereCollider] as the bounding shape
//! - [BvhTree] - boxes for bounding volumes, slower transformations, tighter bounds, any `Collider` composites, during rotation, AABBs are converted to OBBs
//! - [BvhRecursive] - generic bounding volume hierarchy, recommended to use with [AlignedBoxCollider]
//! - [BvhSphereLinear] - bounding sphere hierarchy, implemented with Vec as node storage, very fast transformations slower collision detection
//! - [BvhSphereRecursive] - bounding sphere hierarchy, variant of [BvhRecursive] but optimized for [SphereCollider] as the bounding shape

use crate::collides_group_impl;
use crate::complex::bvh_recursive::BvhRecursive;
Expand Down
8 changes: 4 additions & 4 deletions safe-stage/models/src/assembly/thesis/chamber.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::immovable::Immovable;
use crate::loader::load_stl_from_bytes;
use crate::parts::chamber::Chamber;
use collisions::common::Translation;
use collisions::complex::group::ColliderGroup;
use collisions::{collider_group, PrimaryCollider};
use maths::Vector3;

Expand All @@ -21,19 +21,19 @@ pub struct ThesisChamber {
}

impl Chamber for ThesisChamber {
fn full(&self) -> ColliderGroup<PrimaryCollider> {
fn full(&self) -> Immovable {
collider_group!(
self.pole_piece.clone(),
self.walls.clone(),
self.door.clone()
)
}

fn less_obstructive(&self) -> ColliderGroup<PrimaryCollider> {
fn less_obstructive(&self) -> Immovable {
collider_group!(self.pole_piece.clone(), self.walls.clone())
}

fn non_obstructive(&self) -> ColliderGroup<PrimaryCollider> {
fn non_obstructive(&self) -> Immovable {
collider_group!(self.pole_piece.clone())
}
}
Expand Down
6 changes: 3 additions & 3 deletions safe-stage/models/src/assembly/thesis/equipment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::immovable::Immovable;
use crate::loader::load_stl_from_bytes;
use crate::parts::equipment::Equipment;
use collisions::complex::group::ColliderGroup;
use collisions::{collider_group, PrimaryCollider};

const DETECTOR_ALPHA: &[u8] = include_bytes!("./models/Detector Alpha.stl");
Expand All @@ -17,7 +17,7 @@ impl Default for ThesisDetectorAlpha {
}

impl Equipment for ThesisDetectorAlpha {
fn collider(&self) -> ColliderGroup<PrimaryCollider> {
fn collider(&self) -> Immovable {
collider_group!(self.0.clone())
}
}
Expand All @@ -33,7 +33,7 @@ impl Default for ThesisDetectorBeta {
}

impl Equipment for ThesisDetectorBeta {
fn collider(&self) -> ColliderGroup<PrimaryCollider> {
fn collider(&self) -> Immovable {
collider_group!(self.0.clone())
}
}
4 changes: 2 additions & 2 deletions safe-stage/models/src/assembly/thesis/holders.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::immovable::Immovable;
use crate::loader::load_stl_from_bytes;
use crate::parts::holder::Holder;
use collisions::common::{Rotation, Translation};
use collisions::complex::group::ColliderGroup;
use collisions::{collider_group, PrimaryCollider};
use maths::{Quaternion, Vector3};
use std::sync::LazyLock;
Expand Down Expand Up @@ -38,7 +38,7 @@ macro_rules! thesis_holder_impl {
Box::new(self.clone())
}

fn collider(&self) -> ColliderGroup<PrimaryCollider> {
fn collider(&self) -> Immovable {
if let Some(sample) = &self.sample {
collider_group!(self.body.clone(), sample.clone())
} else {
Expand Down
6 changes: 3 additions & 3 deletions safe-stage/models/src/assembly/thesis/retract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::immovable::Immovable;
use crate::loader::load_stl_from_bytes;
use crate::movable::Movable;
use crate::parts::retract::Retract;
use crate::position::linear::LinearState;
use collisions::common::Translation;
use collisions::complex::group::ColliderGroup;
use collisions::{collider_group, PrimaryCollider};
use maths::Vector3;
use std::sync::Arc;
Expand All @@ -22,7 +22,7 @@ pub struct ThesisRetract {
}

impl Retract for ThesisRetract {
fn as_arc(&self) -> Arc<dyn Movable<LinearState> + Send + Sync> {
fn as_movable(&self) -> Arc<dyn Movable<LinearState>> {
Arc::new(self.clone())
}
}
Expand All @@ -44,7 +44,7 @@ impl Default for ThesisRetract {
}

impl Movable<LinearState> for ThesisRetract {
fn move_to(&self, position: &LinearState) -> ColliderGroup<PrimaryCollider> {
fn move_to(&self, position: &LinearState) -> Immovable {
match position {
LinearState::None => collider_group!(self.entry.clone(), self.retracted.clone()),
LinearState::Full => collider_group!(self.entry.clone(), self.inserted.clone()),
Expand Down
5 changes: 3 additions & 2 deletions safe-stage/models/src/assembly/thesis/stage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::immovable::Immovable;
use crate::loader::load_stl_from_bytes;
use crate::movable::Movable;
use crate::parts::holder::Holder;
Expand Down Expand Up @@ -36,7 +37,7 @@ impl Clone for ThesisStage {
}

impl Stage for ThesisStage {
fn as_arc(&self) -> Arc<dyn Movable<SixAxis> + Send + Sync> {
fn as_movable(&self) -> Arc<dyn Movable<SixAxis>> {
Arc::new(self.clone())
}
fn swap_holder(&mut self, holder: Option<Box<dyn Holder>>) {
Expand Down Expand Up @@ -67,7 +68,7 @@ impl Default for ThesisStage {
}

impl Movable<SixAxis> for ThesisStage {
fn move_to(&self, coords: &SixAxis) -> ColliderGroup<PrimaryCollider> {
fn move_to(&self, coords: &SixAxis) -> Immovable {
let offset = coords.pos + STAGE_POSITION;
let tilt = Quaternion::from_euler(&Vector3::new(0.0, coords.rot.y(), 0.0));
let rotation = Quaternion::from_euler(&Vector3::new(0.0, 0.0, coords.rot.z()));
Expand Down
4 changes: 4 additions & 0 deletions safe-stage/models/src/immovable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use collisions::complex::group::ColliderGroup;
use collisions::PrimaryCollider;

pub type Immovable = ColliderGroup<PrimaryCollider>;
1 change: 1 addition & 0 deletions safe-stage/models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! Focused on modeling the parts of an electron microscope.

pub mod assembly;
pub mod immovable;
pub mod loader;
pub mod movable;
pub mod parts;
Expand Down
7 changes: 3 additions & 4 deletions safe-stage/models/src/movable.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use collisions::complex::group::ColliderGroup;
use collisions::PrimaryCollider;
use crate::immovable::Immovable;

/// Entity can be moved to position `P` where it is represented as `C`.
pub trait Movable<P> {
pub trait Movable<P>: Send + Sync {
/// Get the representation of the entity at the given position.
fn move_to(&self, position: &P) -> ColliderGroup<PrimaryCollider>;
fn move_to(&self, position: &P) -> Immovable;
}
Loading