update devkit server and model files
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use crate::serial_core::codecs::tactile_a::{
|
||||
export_recording_csv, TactileACodec, TactileACsvImporter, TactileAHandler,
|
||||
export_recording_csv, TactileACodec, TactileACsvImporter, TactileADataPacket, TactileAHandler,
|
||||
};
|
||||
use crate::serial_core::error::SerialError;
|
||||
use crate::serial_core::model::HudSpatialForce;
|
||||
#[cfg(feature = "multi-dim")]
|
||||
use crate::serial_core::multi_dim_force::PztProcessor;
|
||||
use crate::serial_core::record::CsvImporter;
|
||||
use crate::serial_core::serial::{PollMode, TactileAPollRequester};
|
||||
use crate::serial_core::{serial, TactileARecording};
|
||||
@@ -44,6 +47,7 @@ pub struct SerialExportResponse {
|
||||
pub struct SerialImportFrame {
|
||||
pub data: Vec<i32>,
|
||||
pub dts_ms: u64,
|
||||
pub spatial_force: Option<HudSpatialForce>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -322,13 +326,7 @@ pub fn serial_import_csv(
|
||||
|
||||
let channel_count = packets.first().map(|item| item.data.len()).unwrap_or(0);
|
||||
let frame_count = packets.len();
|
||||
let frames = packets
|
||||
.into_iter()
|
||||
.map(|packet| SerialImportFrame {
|
||||
data: packet.data,
|
||||
dts_ms: packet.dts_ms,
|
||||
})
|
||||
.collect();
|
||||
let frames = build_import_frames(packets);
|
||||
|
||||
Ok(SerialImportResponse {
|
||||
file_name,
|
||||
@@ -353,6 +351,44 @@ pub fn serial_import_csv_from_path(file_path: String) -> Result<SerialImportResp
|
||||
serial_import_csv(file_name, csv_content)
|
||||
}
|
||||
|
||||
fn build_import_frames(packets: Vec<TactileADataPacket>) -> Vec<SerialImportFrame> {
|
||||
#[cfg(feature = "multi-dim")]
|
||||
let mut pzt_processor = PztProcessor::new();
|
||||
|
||||
packets
|
||||
.into_iter()
|
||||
.map(|packet| {
|
||||
#[cfg(feature = "multi-dim")]
|
||||
let spatial_force = replay_spatial_force(&mut pzt_processor, &packet.data);
|
||||
|
||||
#[cfg(not(feature = "multi-dim"))]
|
||||
let spatial_force = None;
|
||||
|
||||
SerialImportFrame {
|
||||
data: packet.data,
|
||||
dts_ms: packet.dts_ms,
|
||||
spatial_force,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(feature = "multi-dim")]
|
||||
fn replay_spatial_force(processor: &mut PztProcessor, values: &[i32]) -> Option<HudSpatialForce> {
|
||||
let pzt_values = values.iter().map(|value| *value as f32).collect::<Vec<f32>>();
|
||||
let analysis = processor.get_pzt_analysis(&pzt_values).ok()?;
|
||||
|
||||
if !PztProcessor::should_report(&analysis) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(HudSpatialForce {
|
||||
angle_deg: analysis.angle_deg,
|
||||
magnitude: analysis.magnitude,
|
||||
confidence: analysis.confidence,
|
||||
})
|
||||
}
|
||||
|
||||
fn resolve_record_for_export(
|
||||
state: &State<'_, SerialConnectionState>,
|
||||
) -> Result<SharedTactileRecording, SerialError> {
|
||||
|
||||
Reference in New Issue
Block a user