Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait until connect of the PoulpeRemoteClient (error after 2s) + … #104

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions orbita2d_controller/examples/poulpe2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,16 @@ fn main() -> Result<(), Box<dyn Error>> {
// let target_yaw_mat=conversion::intrinsic_roll_pitch_yaw_to_matrix(0.0, 0.0, s);
// let target=conversion::rotation_matrix_to_quaternion(target_yaw_mat);

let fb = controller.set_target_orientation_fb([s, 0.0]);
let axis = controller.get_axis_sensors();
match fb {
Ok(fb) => {
log::info!("Feedback: {:?}", fb);
println!(
"{:?} {:?} {:?} {:?} {:?} {:?}",
t as f64, s, fb.orientation[0], fb.orientation[1], axis[0], axis[1]
);
}
Err(e) => log::error!("Error: {}", e),
}
let fb = controller.set_target_orientation_fb([s, 0.0]).unwrap();
let axis = controller.get_axis_sensors().unwrap();

log::info!("Feedback: {:?}", fb);
log::info!("Axis: {:?}", axis);
println!(
"{:?} {:?} {:?} {:?} {:?} {:?}",
t as f64, s, fb.orientation[0], fb.orientation[1], axis[0], axis[1]
);


thread::sleep(Duration::from_millis(1));
}
Expand Down
13 changes: 13 additions & 0 deletions orbita2d_controller/src/poulpe_ethercat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ impl Orbita2dController {
return Err("Error while connecting to the PoulpeRemoteClient".into());
}
};

// wait for the connection to be established
let mut trials = 20; // 2s
while io.get_state(id).is_err() {
thread::sleep(Duration::from_millis(100));
if trials == 0 {
log::error!("Error: Timeout while connecting to the Orbita2d PoulpeRemoteClient with id {}", id);
return Err("Error: Timeout while connecting to the Orbita2d PoulpeRemoteClient".into());
}
trials -= 1;
}
log::info!("Connected to Orbita2d PoulpeRemoteClient with id {}", id);


// set the initial velocity and torque limit to 100%
io.set_velocity_limit(id, [1.0; 2].to_vec());
Expand Down
Loading