Skip to content

Commit

Permalink
change command
Browse files Browse the repository at this point in the history
  • Loading branch information
WT-MM committed Oct 9, 2024
1 parent 54abd55 commit 81c6776
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actuator/rust/robstride/src/bin/stand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> Result<(), Box<dyn Error>> {

// Create Motors instances with the port names
let mut motors_1 = Motors::new("/dev/ttyCH341USB0", motors_map_1)?;
let mut motors_2 = Motors::new("/dev/ttyCH341USB1", motors_map_2)?;
// let mut motors_2 = Motors::new("/dev/ttyCH341USB1", motors_map_2)?;

// Function to initialize motors
let initialize_motors = |motors: &mut Motors| -> Result<(), Box<dyn Error>> {
Expand All @@ -53,7 +53,7 @@ fn main() -> Result<(), Box<dyn Error>> {

let set_location = |motors: &mut Motors, location: f32| -> Result<(), Box<dyn Error>> {
for id in 1..=5 {
motors.send_set_location(id, location)?;
motors.send_position_control(id, location, 5.0)?;
std::thread::sleep(Duration::from_millis(50));
}
motors.read_all_pending_responses()?;
Expand All @@ -62,21 +62,21 @@ fn main() -> Result<(), Box<dyn Error>> {

// Initialize both groups of motors
initialize_motors(&mut motors_1)?;
initialize_motors(&mut motors_2)?;
// initialize_motors(&mut motors_2)?;

println!("Motors initialized and set to stand position.");

// Wait until interrupted
while running.load(Ordering::SeqCst) {
std::thread::sleep(Duration::from_millis(50));
set_location(&mut motors_1, 0.0)?;
set_location(&mut motors_2, 0.0)?;
// set_location(&mut motors_2, 0.0)?;
}

// Reset motors on exit
for id in 1..=5 {
motors_1.send_reset(id)?;
motors_2.send_reset(id)?;
// motors_2.send_reset(id)?;
std::thread::sleep(Duration::from_millis(50));
}

Expand Down

0 comments on commit 81c6776

Please sign in to comment.