mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
debugging, starting to pull commands into another module (not done)
This commit is contained in:
1 parent
a352e9450f
commit
31532633bf
3 files changed
+72
-4
No files matched your search
+4
-4
@@ -115,7 +115,7 @@ fn main() -> AnyhowResult<()> {
|
||||
packet_number += 1;
|
||||
},
|
||||
MessagingState::GrabPointCloud => {
|
||||
println!("Grabbing another frame...");
|
||||
//println!("Grabbing another frame...");
|
||||
color = get_time_based_color();
|
||||
points = get_point_cloud(&device, &xy_table, color)?;
|
||||
|
||||
@@ -142,7 +142,7 @@ fn get_point_cloud(device: &Device, xy_table: &Image, color: Color) -> AnyhowRes
|
||||
let mut points =
|
||||
calculate_point_cloud2(&depth_image, &xy_table, color)?;
|
||||
|
||||
println!("Points: {}", points.len());
|
||||
//println!("Points: {}", points.len());
|
||||
|
||||
Ok(points)
|
||||
}
|
||||
@@ -162,10 +162,10 @@ fn encode_point_data(points: &mut Vec<Point>, is_beginning: bool) -> Vec<u8> {
|
||||
let mut buf = Vec::with_capacity(4 + point_bytes);
|
||||
|
||||
if is_beginning {
|
||||
println!("begin");
|
||||
//println!("begin");
|
||||
buf.write_u32::<LittleEndian>(POINT_DATA_BEGIN_PAYLOAD_COMMAND); // COMMAND #
|
||||
} else {
|
||||
println!("continue");
|
||||
//println!("continue");
|
||||
buf.write_u32::<LittleEndian>(POINT_DATA_CONTINUE_PAYLOAD_COMMAND); // COMMAND #
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
use crate::zeromq::point::Point;
|
||||
use byteorder::{WriteBytesExt, LittleEndian};
|
||||
use std::io::Write;
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/// Denotes the command that sends the variable-length data
|
||||
const POINT_DATA_BEGIN_PAYLOAD_COMMAND : u32 = 2;
|
||||
|
||||
/// Denotes the command that sends the variable-length data
|
||||
const POINT_DATA_CONTINUE_PAYLOAD_COMMAND : u32 = 3;
|
||||
|
||||
/// The maximum number of points to send per ZeroMQ "packet".
|
||||
/// This is also defined in C++, so it needs to be adjusted in multiple places.
|
||||
const MAX_SEND_POINTS_PER_PACKET : usize = 3000;
|
||||
|
||||
/// Streaming points
|
||||
struct StreamingPointsPacket {
|
||||
is_first_point_packet: bool,
|
||||
points: Vec<Point>,
|
||||
}
|
||||
|
||||
impl StreamingPointsPacket {
|
||||
fn from_all_points(points: Vec<Point>) -> Self {
|
||||
Self {
|
||||
is_first_point_packet: true,
|
||||
points,
|
||||
}
|
||||
}
|
||||
|
||||
/// Over the wire, this looks like:
|
||||
///
|
||||
/// | command | 4 bytes (u32) |
|
||||
/// | point_count | 4 bytes (u32) |
|
||||
/// | points[] ... | [16 bytes] ... |
|
||||
///
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
let point_bytes = Point::size_bytes() * MAX_SEND_POINTS_PER_PACKET;
|
||||
|
||||
let mut buf = Vec::with_capacity(4 + point_bytes);
|
||||
|
||||
if self.is_first_point_packet {
|
||||
buf.write_u32::<LittleEndian>(POINT_DATA_BEGIN_PAYLOAD_COMMAND); // COMMAND #
|
||||
} else {
|
||||
buf.write_u32::<LittleEndian>(POINT_DATA_CONTINUE_PAYLOAD_COMMAND); // COMMAND #
|
||||
}
|
||||
|
||||
//let subset = if points.len() > MAX_SEND_POINTS_PER_PACKET {
|
||||
// points.drain(0..MAX_SEND_POINTS_PER_PACKET).collect::<Vec<Point>>()
|
||||
//} else {
|
||||
// points.drain(0..points.len()).collect::<Vec<Point>>()
|
||||
//};
|
||||
|
||||
buf.write_u32::<LittleEndian>(self.points.len() as u32); // LENGTH
|
||||
|
||||
for point in self.points.iter() {
|
||||
let bytes = point.to_bytes();
|
||||
buf.write_all(&bytes);
|
||||
}
|
||||
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod calculate_point_cloud;
|
||||
pub mod color;
|
||||
pub mod debug;
|
||||
pub mod message;
|
||||
pub mod point;
|
||||
pub mod xy_table;
|
||||
Reference in new issue
Block a user