Skip to content
Snippets Groups Projects
Commit 7f537199 authored by Robert Hedman's avatar Robert Hedman
Browse files

minor update/sync

parent 2e9c70af
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,12 @@ use serial::prelude::*; ...@@ -20,13 +20,12 @@ use serial::prelude::*;
// constants // constants
const LIDAR_ADDRESS: &str = "127.0.0.1:8080"; const LIDAR_ADDRESS: &str = "127.0.0.1:8080";
const COUNTER_SERIAL_PORT: &str = "/dev/cu.usbmodem41"; const COUNTER_SERIAL_PORT: &str = "/dev/cu.usbmodem1422";
// should the map matrix be two dim array of const size, vecs of dynamic, or what? // should the map matrix be two dim array of const size, vecs of dynamic, or what?
const ROWS: usize = 50; const ROWS: usize = 50;
const COLS: usize = 100; const COLS: usize = 100;
static mut vec = vec![vec![0; COLS]; ROWS];
fn main() { fn main() {
// dummy thread for replacing lidar // dummy thread for replacing lidar
...@@ -103,8 +102,8 @@ fn main() { ...@@ -103,8 +102,8 @@ fn main() {
// get encoder data from arduino and update local variables // get encoder data from arduino and update local variables
match port.read_exact(&mut serial_buf){ match port.read_exact(&mut serial_buf){
Ok(_) => { Ok(_) => {
pos.0 = freq_to_distance( ( ((serial_buf[0] as u32) << 24) + ((serial_buf[1] as u32) << 16) + ((serial_buf[2] as u32) << 8) + (serial_buf[3] as u32) ) as i32); pos.0 += freq_to_distance( ( ((serial_buf[0] as u32) << 24) + ((serial_buf[1] as u32) << 16) + ((serial_buf[2] as u32) << 8) + (serial_buf[3] as u32) ) as i32);
pos.1 = freq_to_distance( ( ((serial_buf[4] as u32) << 24) + ((serial_buf[5] as u32) << 16) + ((serial_buf[6] as u32) << 8) + (serial_buf[7] as u32) ) as i32); pos.1 += freq_to_distance( ( ((serial_buf[4] as u32) << 24) + ((serial_buf[5] as u32) << 16) + ((serial_buf[6] as u32) << 8) + (serial_buf[7] as u32) ) as i32);
print!("L: {}, ", pos.0); print!("L: {}, ", pos.0);
println!("R: {}", pos.1); println!("R: {}", pos.1);
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment