Skip to content
25 changes: 25 additions & 0 deletions crates/re_log_types/src/component_types/imu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::{Component, EntityPath};
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use super::{Point3D, Quaternion};

#[derive(Clone, Debug, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)]
pub struct ImuData {
pub accel: Point3D,
pub gyro: Point3D,
pub mag: Option<Point3D>,
pub orientation: Quaternion,
}

impl ImuData {
pub fn entity_path() -> EntityPath {
"imu_data".into()
}
}

impl Component for ImuData {
#[inline]
fn name() -> crate::ComponentName {
"rerun.imu".into()
}
}
5 changes: 4 additions & 1 deletion crates/re_log_types/src/component_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod class_id;
mod color;
pub mod context;
pub mod coordinates;
mod imu;
mod instance_key;
mod keypoint_id;
mod label;
Expand All @@ -48,6 +49,7 @@ pub use class_id::ClassId;
pub use color::ColorRGBA;
pub use context::{AnnotationContext, AnnotationInfo, ClassDescription};
pub use coordinates::ViewCoordinates;
pub use imu::ImuData;
pub use instance_key::InstanceKey;
pub use keypoint_id::KeypointId;
pub use label::Label;
Expand All @@ -74,7 +76,7 @@ pub use vec::{Vec2D, Vec3D, Vec4D};

lazy_static! {
//TODO(john): use a run-time type registry
static ref FIELDS: [Field; 27] = [
static ref FIELDS: [Field; 28] = [
<AnnotationContext as Component>::field(),
<Arrow3D as Component>::field(),
<Box3D as Component>::field(),
Expand Down Expand Up @@ -102,6 +104,7 @@ lazy_static! {
<Vec3D as Component>::field(),
<ViewCoordinates as Component>::field(),
<NodeGraph as Component>::field(),
<ImuData as Component>::field(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use self::component_types::AnnotationContext;
pub use self::component_types::Arrow3D;
pub use self::component_types::MsgId;
pub use self::component_types::ViewCoordinates;
pub use self::component_types::{EncodedMesh3D, Mesh3D, MeshFormat, MeshId, RawMesh3D};
pub use self::component_types::{EncodedMesh3D, ImuData, Mesh3D, MeshFormat, MeshId, RawMesh3D};
pub use self::data::*;
pub use self::data_cell::{DataCell, DataCellError, DataCellResult};
pub use self::data_row::{DataRow, DataRowError, DataRowResult};
Expand Down
24 changes: 15 additions & 9 deletions crates/re_viewer/src/depthai/depthai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ impl Default for Error {
}
}

#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, fmt::Debug)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, fmt::Debug)]
pub struct Device {
pub id: DeviceId,
// Add more fields later
}
impl Default for Device {
fn default() -> Self {
Self { id: -1 }
Self { id: "".to_string() }
}
}

Expand Down Expand Up @@ -283,13 +283,15 @@ pub struct State {
pub neural_networks: Vec<AiModel>,
}

// Kind of dangerous, IMPORTANT: Make sure all ChannelId variants are covered
fn all_subscriptions() -> Vec<ChannelId> {
vec![
ChannelId::ColorImage,
ChannelId::LeftMono,
ChannelId::RightMono,
ChannelId::DepthImage,
ChannelId::PointCloud,
ChannelId::ImuData,
]
}

Expand Down Expand Up @@ -339,6 +341,7 @@ pub enum ChannelId {
DepthImage,
PointCloud,
PinholeCamera,
ImuData,
}

use lazy_static::lazy_static;
Expand Down Expand Up @@ -392,14 +395,15 @@ impl State {
}

pub fn set_subscriptions_from_space_views(&mut self, visible_space_views: Vec<&SpaceView>) {
// If any bool in the vec is true, the channel is currently visible in the ui somewhere
let mut visibilities = HashMap::<ChannelId, Vec<bool>>::from([
(ChannelId::ColorImage, Vec::new()),
(ChannelId::LeftMono, Vec::new()),
(ChannelId::RightMono, Vec::new()),
(ChannelId::DepthImage, Vec::new()),
(ChannelId::PointCloud, Vec::new()),
]);

// Fill in visibilities
for space_view in visible_space_views.iter() {
let mut property_map = space_view.data_blueprint.data_blueprints_projected();
for entity_path in space_view.data_blueprint.entity_paths().iter() {
Expand All @@ -411,13 +415,14 @@ impl State {
}
}

// First add subscriptions that are always possible in terms of ui (no enable/disable buttons for these)
let mut possible_subscriptions = Vec::<ChannelId>::from([
ChannelId::ColorImage,
ChannelId::LeftMono,
ChannelId::RightMono,
ChannelId::ImuData,
]);

// Non default subscriptions
// Now add non default subscriptions
if self.device_config.config.depth.is_some() {
possible_subscriptions.push(ChannelId::DepthImage);
if let Some(depth) = self.device_config.config.depth {
Expand All @@ -427,6 +432,7 @@ impl State {
}
}

// Filter visibilities, include those that are currently visible and also possible (example pointcloud enabled == pointcloud possible)
let mut subscriptions = visibilities
.iter()
.filter_map(|(channel, vis)| {
Expand Down Expand Up @@ -516,7 +522,7 @@ impl State {
match error.action {
ErrorAction::None => (),
ErrorAction::FullReset => {
self.set_device(-1);
self.set_device("".into());
}
}
}
Expand All @@ -528,7 +534,7 @@ impl State {
if poll_instant.elapsed().as_secs() < 2 {
return;
}
if self.selected_device.id == -1 {
if self.selected_device.id == "" {
self.backend_comms.get_devices();
}
self.poll_instant = Some(Instant::now());
Expand All @@ -551,7 +557,7 @@ impl State {
.ws
.connected
.load(std::sync::atomic::Ordering::SeqCst)
|| self.selected_device.id == -1
|| self.selected_device.id == ""
{
return;
}
Expand All @@ -564,4 +570,4 @@ impl State {
}
}

pub type DeviceId = i64; // i64 because of serialization
pub type DeviceId = String; // i64 because of serialization
Loading