Skip to content

Commit

Permalink
feat: batch (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat authored Apr 9, 2024
1 parent 87e25cb commit 845957b
Show file tree
Hide file tree
Showing 128 changed files with 11,590 additions and 7,751 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7]
target: [x86_64, aarch64, armv7]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
22 changes: 7 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[workspace]
members = [
"crates/sophus_tensor",
"crates/sophus_calculus",
"crates/sophus",
"crates/sophus_core",
"crates/sophus_lie",
"crates/sophus_pyo3",
"crates/sophus_image",
"crates/sophus_sensor",
"crates/sophus_opt",
"crates/sophus",
]
resolver = "2"

Expand All @@ -25,14 +24,14 @@ version = "0.4.0"

[workspace.dependencies]
sophus = {path = "crates/sophus", version = "0.4.0"}
sophus_calculus = {path = "crates/sophus_calculus", version = "0.4.0"}
sophus_core = {path = "crates/sophus_core", version = "0.4.0"}
sophus_image = {path = "crates/sophus_image", version = "0.4.0"}
sophus_lie = {path = "crates/sophus_lie", version = "0.4.0"}
sophus_opt = {path = "crates/sophus_opt", version = "0.4.0"}
sophus_pyo3 = {path = "crates/sophus_pyo3", version = "0.4.0"}
sophus_sensor = {path = "crates/sophus_sensor", version = "0.4.0"}
sophus_tensor = {path = "crates/sophus_tensor", version = "0.4.0"}

approx = {version = "0.5.1"}
approx = "0.5.1"
as-any = "0.3.1"
assertables = "7.0.1"
async-trait = "0.1.77"
Expand All @@ -47,23 +46,16 @@ hollywood = "0.5.0"
image = {version = "0.25", features = [
"jpeg",
"png",
"tga",
"gif",
"ico",
"bmp",
"hdr",
"tiff",
"avif",
"webp",
]}
log = "0.4.14"
nalgebra = {version = "0.32", features = ["rand"]}
ndarray = {version = "0.15.4", features = ["approx-0_5"]}
num-traits = "0.2.15"
numpy = "0.20"
numpy = "0.21"
png = "0.17.11"
rand = "0.8.5"
simba = "0.8.1"
sleef = "0.3.2"
tokio = {version = "1", features = ["full"]}
typenum = {version = "1.17.0", features = ["const-generics"]}
wgpu = "0.19"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
4 changes: 2 additions & 2 deletions crates/sophus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ repository.workspace = true
version.workspace = true

[dependencies]
sophus_calculus.workspace = true
sophus_core.workspace = true
sophus_image.workspace = true
sophus_lie.workspace = true
sophus_opt.workspace = true
sophus_pyo3.workspace = true
sophus_sensor.workspace = true
sophus_tensor.workspace = true

approx.workspace = true
assertables.workspace = true
Expand Down
23 changes: 13 additions & 10 deletions crates/sophus/examples/pose_graph.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
use hollywood::actors::egui::EguiActor;

use hollywood::actors::egui::Stream;
pub use hollywood::compute::Context;
pub use hollywood::core::*;
use hollywood::macros::*;
use sophus::calculus::types::vector::IsVector;
use sophus::calculus::types::VecF64;
use sophus::image::image_view::ImageSize;
use sophus::lie::isometry2::Isometry2;
use sophus::lie::isometry3::Isometry3;
use sophus::lie::traits::IsTranslationProductGroup;
use sophus::opt::example_problems::pose_circle::PoseCircleProblem;
use sophus::sensor::perspective_camera::KannalaBrandtCamera;
use sophus::viewer::actor::run_viewer_on_main_thread;
use sophus::viewer::actor::ViewerBuilder;
use sophus::viewer::actor::ViewerCamera;
use sophus::viewer::actor::ViewerConfig;
use sophus::viewer::renderable::*;
use sophus::viewer::scene_renderer::interaction::WgpuClippingPlanes;
use sophus::viewer::SimpleViewer;
use sophus_core::linalg::vector::IsVector;
use sophus_core::linalg::VecF64;
use sophus_lie::groups::isometry2::Isometry2;
use sophus_lie::groups::isometry3::Isometry3;
use sophus_sensor::camera_enum::perspective_camera::KannalaBrandtCamera;
use sophus_sensor::camera_enum::perspective_camera::PerspectiveCameraEnum;
use sophus_sensor::dyn_camera::DynCamera;

#[actor(ContentGeneratorMessage)]
type ContentGenerator = Actor<
Expand Down Expand Up @@ -47,7 +48,7 @@ pub struct ContentGeneratorOutbound {
pub packets: OutboundChannel<Stream<Vec<Renderable>>>,
}

fn make_axes(world_from_local_poses: Vec<Isometry2<f64>>) -> Vec<Line3> {
fn make_axes(world_from_local_poses: Vec<Isometry2<f64, 1>>) -> Vec<Line3> {
let zero_in_local = VecF64::<2>::zeros();
let x_axis_local = VecF64::<2>::new(1.0, 0.0);
let y_axis_local = VecF64::<2>::new(0.0, 1.0);
Expand Down Expand Up @@ -124,7 +125,7 @@ impl InboundMessageNew<f64> for ContentGeneratorMessage {

pub async fn run_viewer_example() {
// Camera / view pose parameters
let intrinsics = KannalaBrandtCamera::<f64>::new(
let intrinsics = KannalaBrandtCamera::<f64, 1>::new(
&VecF64::<8>::from_array([600.0, 600.0, 320.0, 240.0, 0.0, 0.0, 0.0, 0.0]),
ImageSize {
width: 640,
Expand All @@ -137,7 +138,9 @@ pub async fn run_viewer_example() {
far: 1000.0,
};
let camera = ViewerCamera {
intrinsics,
intrinsics: DynCamera::<f64, 1>::from_model(PerspectiveCameraEnum::KannalaBrandt(
intrinsics,
)),
clipping_planes,
scene_from_camera,
};
Expand All @@ -157,7 +160,7 @@ pub async fn run_viewer_example() {
);
// 3. The viewer actor
let mut viewer =
EguiActor::<Vec<Renderable>, (), Isometry3<f64>>::from_builder(context, &builder);
EguiActor::<Vec<Renderable>, (), Isometry3<f64, 1>>::from_builder(context, &builder);

// Pipeline connections:
timer
Expand Down
35 changes: 17 additions & 18 deletions crates/sophus/examples/viewer_ex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ pub use hollywood::core::request::RequestHub;
pub use hollywood::core::*;
use hollywood::macros::*;
use nalgebra::SVector;
use sophus::calculus::types::vector::IsVector;
use sophus::calculus::types::VecF64;
use sophus::image::image_view::ImageSize;
use sophus::lie::isometry3::Isometry3;
use sophus::lie::traits::IsTranslationProductGroup;
use sophus::sensor::perspective_camera::KannalaBrandtCamera;

use sophus::image::arc_image::ArcImage4F32;
use sophus::image::image_view::ImageSize;
use sophus::viewer::actor::run_viewer_on_main_thread;
use sophus::viewer::actor::ViewerBuilder;
use sophus::viewer::actor::ViewerCamera;
use sophus::viewer::actor::ViewerConfig;
use sophus::viewer::renderable::*;
use sophus::viewer::scene_renderer::interaction::WgpuClippingPlanes;
use sophus::viewer::SimpleViewer;
use sophus_core::linalg::vector::IsVector;
use sophus_core::linalg::VecF64;
use sophus_lie::groups::isometry3::Isometry3;
use sophus_lie::traits::IsTranslationProductGroup;
use sophus_sensor::dyn_camera::DynCamera;

#[actor(ContentGeneratorMessage)]
type ContentGenerator = Actor<
Expand All @@ -38,13 +37,13 @@ type ContentGenerator = Actor<
pub enum ContentGeneratorMessage {
/// in seconds
ClockTick(f64),
SceneFromCamera(ReplyMessage<Isometry3<f64>>),
SceneFromCamera(ReplyMessage<Isometry3<f64, 1>>),
}

/// Request of the simulation actor.
pub struct ContentGeneratorRequest {
/// Check time-stamp of receiver
pub scene_from_camera_request: RequestChannel<(), Isometry3<f64>, ContentGeneratorMessage>,
pub scene_from_camera_request: RequestChannel<(), Isometry3<f64, 1>, ContentGeneratorMessage>,
}

impl RequestHub<ContentGeneratorMessage> for ContentGeneratorRequest {
Expand Down Expand Up @@ -78,16 +77,16 @@ impl Activate for ContentGeneratorRequest {
pub struct ContentGeneratorState {
pub counter: u32,
pub show: bool,
pub intrinsics: KannalaBrandtCamera<f64>,
pub scene_from_camera: Isometry3<f64>,
pub intrinsics: DynCamera<f64, 1>,
pub scene_from_camera: Isometry3<f64, 1>,
}

impl Default for ContentGeneratorState {
fn default() -> Self {
ContentGeneratorState {
counter: 0,
show: false,
intrinsics: KannalaBrandtCamera::<f64>::new(
intrinsics: DynCamera::new_kannala_brandt(
&VecF64::<8>::from_array([600.0, 600.0, 320.0, 240.0, 0.0, 0.0, 0.0, 0.0]),
ImageSize {
width: 640,
Expand Down Expand Up @@ -422,15 +421,15 @@ impl InboundMessageNew<f64> for ContentGeneratorMessage {
}
}

impl InboundMessageNew<ReplyMessage<Isometry3<f64>>> for ContentGeneratorMessage {
fn new(_inbound_name: String, scene_from_camera: ReplyMessage<Isometry3<f64>>) -> Self {
impl InboundMessageNew<ReplyMessage<Isometry3<f64, 1>>> for ContentGeneratorMessage {
fn new(_inbound_name: String, scene_from_camera: ReplyMessage<Isometry3<f64, 1>>) -> Self {
ContentGeneratorMessage::SceneFromCamera(scene_from_camera)
}
}

pub async fn run_viewer_example() {
// Camera / view pose parameters
let intrinsics = KannalaBrandtCamera::<f64>::new(
let intrinsics = DynCamera::new_kannala_brandt(
&VecF64::<8>::from_array([600.0, 600.0, 320.0, 240.0, 0.0, 0.0, 0.0, 0.0]),
ImageSize {
width: 640,
Expand All @@ -443,7 +442,7 @@ pub async fn run_viewer_example() {
far: 1000.0,
};
let camera = ViewerCamera {
intrinsics,
intrinsics: intrinsics.clone(),
clipping_planes,
scene_from_camera,
};
Expand All @@ -462,13 +461,13 @@ pub async fn run_viewer_example() {
ContentGeneratorState {
counter: 0,
show: false,
intrinsics,
intrinsics: intrinsics.clone(),
scene_from_camera,
},
);
// 3. The viewer actor
let mut viewer =
EguiActor::<Vec<Renderable>, (), Isometry3<f64>>::from_builder(context, &builder);
EguiActor::<Vec<Renderable>, (), Isometry3<f64, 1>>::from_builder(context, &builder);

// Pipeline connections:
timer
Expand Down
5 changes: 3 additions & 2 deletions crates/sophus/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pub use sophus_calculus as calculus;
#![feature(portable_simd)]

pub use sophus_core as core;
pub use sophus_image as image;
pub use sophus_lie as lie;
pub use sophus_opt as opt;
pub use sophus_sensor as sensor;
pub use sophus_tensor as tensor;

pub mod viewer;

Expand Down
35 changes: 17 additions & 18 deletions crates/sophus/src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ pub mod pixel_renderer;
pub mod renderable;
pub mod scene_renderer;

use eframe::egui::load::SizedTexture;
use eframe::egui::Image;
use eframe::egui::Sense;
use eframe::egui::{self};
use eframe::egui_wgpu::Renderer;
use eframe::epaint::mutex::RwLock;
use hollywood::actors::egui::EguiAppFromBuilder;
use hollywood::actors::egui::Stream;
use hollywood::compute::pipeline::CancelRequest;
use hollywood::core::request::RequestMessage;
use std::sync::Arc;

use self::actor::ViewerBuilder;
use self::offscreen::OffscreenTexture;
use self::pixel_renderer::PixelRenderer;
Expand All @@ -26,14 +14,25 @@ use self::scene_renderer::SceneRenderer;
use crate::image::arc_image::ArcImage4U8;
use crate::image::image_view::ImageSize;
use crate::image::image_view::IsImageView;
use crate::lie::isometry3::Isometry3;
use crate::sensor::perspective_camera::KannalaBrandtCamera;
use crate::tensor::view::IsTensorLike;
use crate::viewer::pixel_renderer::LineVertex2;
use crate::viewer::pixel_renderer::PointVertex2;
use crate::viewer::scene_renderer::line::LineVertex3;
use crate::viewer::scene_renderer::mesh::MeshVertex3;
use crate::viewer::scene_renderer::point::PointVertex3;
use eframe::egui::load::SizedTexture;
use eframe::egui::Image;
use eframe::egui::Sense;
use eframe::egui::{self};
use eframe::egui_wgpu::Renderer;
use eframe::epaint::mutex::RwLock;
use hollywood::actors::egui::EguiAppFromBuilder;
use hollywood::actors::egui::Stream;
use hollywood::compute::pipeline::CancelRequest;
use hollywood::core::request::RequestMessage;
use sophus_core::tensor::tensor_view::IsTensorLike;
use sophus_lie::groups::isometry3::Isometry3;
use sophus_sensor::dyn_camera::DynCamera;
use std::sync::Arc;

#[derive(Clone)]
pub struct ViewerRenderState {
Expand Down Expand Up @@ -88,13 +87,13 @@ impl BackgroundTexture {
pub struct SimpleViewer {
state: ViewerRenderState,
offscreen: OffscreenTexture,
cam: KannalaBrandtCamera<f64>,
cam: DynCamera<f64, 1>,
pixel: PixelRenderer,
scene: SceneRenderer,
background_image: Option<ArcImage4U8>,
background_texture: Option<BackgroundTexture>,
message_recv: std::sync::mpsc::Receiver<Stream<Vec<Renderable>>>,
request_recv: std::sync::mpsc::Receiver<RequestMessage<(), Isometry3<f64>>>,
request_recv: std::sync::mpsc::Receiver<RequestMessage<(), Isometry3<f64, 1>>>,
cancel_request_sender: tokio::sync::mpsc::Sender<CancelRequest>,
}

Expand All @@ -111,7 +110,7 @@ impl EguiAppFromBuilder<ViewerBuilder> for SimpleViewer {
Box::new(SimpleViewer {
state: render_state.clone(),
offscreen: OffscreenTexture::new(&render_state, &builder.config.camera.intrinsics),
cam: builder.config.camera.intrinsics,
cam: builder.config.camera.intrinsics.clone(),
pixel: PixelRenderer::new(&render_state, &builder, depth_stencil.clone()),
scene: SceneRenderer::new(&render_state, &builder, depth_stencil),
message_recv: builder.message_recv,
Expand Down
13 changes: 6 additions & 7 deletions crates/sophus/src/viewer/actor.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::lie::isometry3::Isometry3;
use crate::sensor::perspective_camera::KannalaBrandtCamera;
use crate::viewer::scene_renderer::interaction::WgpuClippingPlanes;
use crate::viewer::Renderable;
use crate::viewer::ViewerRenderState;

use eframe::egui;
use hollywood::actors::egui::EguiAppFromBuilder;
use hollywood::actors::egui::GenericEguiBuilder;
use hollywood::core::request::RequestMessage;
use sophus_lie::groups::isometry3::Isometry3;
use sophus_sensor::dyn_camera::DynCamera;

pub struct ViewerCamera {
pub intrinsics: KannalaBrandtCamera<f64>,
pub intrinsics: DynCamera<f64, 1>,
pub clipping_planes: WgpuClippingPlanes,
pub scene_from_camera: Isometry3<f64>,
pub scene_from_camera: Isometry3<f64, 1>,
}

pub struct ViewerConfig {
Expand All @@ -23,7 +22,7 @@ pub struct ViewerConfig {
#[derive(Clone, Debug)]
pub enum ViewerMessage {
Packets(Vec<Renderable>),
RequestViewPose(RequestMessage<(), Isometry3<f64>>),
RequestViewPose(RequestMessage<(), Isometry3<f64, 1>>),
}

impl Default for ViewerMessage {
Expand All @@ -33,7 +32,7 @@ impl Default for ViewerMessage {
}

pub type ViewerBuilder =
GenericEguiBuilder<Vec<Renderable>, RequestMessage<(), Isometry3<f64>>, ViewerConfig>;
GenericEguiBuilder<Vec<Renderable>, RequestMessage<(), Isometry3<f64, 1>>, ViewerConfig>;

pub fn run_viewer_on_main_thread<
Builder: 'static,
Expand Down
Loading

0 comments on commit 845957b

Please sign in to comment.