Skip to content

Commit

Permalink
safe mode flag
Browse files Browse the repository at this point in the history
  • Loading branch information
WT-MM committed Nov 3, 2024
1 parent eefe257 commit 5bf97cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion actuator/robstride/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ pub struct MotorsSupervisor {
max_update_rate: Arc<RwLock<f64>>,
actual_update_rate: Arc<RwLock<f64>>,
serial: Arc<RwLock<bool>>,
safe_mode: Arc<RwLock<bool>>,
}

impl MotorsSupervisor {
Expand All @@ -940,6 +941,7 @@ impl MotorsSupervisor {
verbose: bool,
max_update_rate: f64,
zero_on_init: bool,
safe_mode: bool,
) -> Result<Self, Box<dyn std::error::Error>> {
// Initialize Motors
let motors = Motors::new(port_name, motor_infos, verbose)?;
Expand Down Expand Up @@ -973,7 +975,7 @@ impl MotorsSupervisor {
let motor_ids: Vec<u8> = motor_infos.keys().cloned().collect();
let total_commands = 0;
let failed_commands = motor_ids.iter().map(|&id| (id, 0)).collect();

g
let controller = MotorsSupervisor {
motors: Arc::new(Mutex::new(motors)),
target_params: Arc::new(RwLock::new(target_params)),
Expand All @@ -987,6 +989,7 @@ impl MotorsSupervisor {
max_update_rate: Arc::new(RwLock::new(max_update_rate)),
actual_update_rate: Arc::new(RwLock::new(0.0)),
serial: Arc::new(RwLock::new(true)),
safe_mode: Arc::new(RwLock::new(safe_mode)),
};

controller.start_control_thread();
Expand All @@ -1007,6 +1010,7 @@ impl MotorsSupervisor {
let max_update_rate = Arc::clone(&self.max_update_rate);
let actual_update_rate = Arc::clone(&self.actual_update_rate);
let serial = Arc::clone(&self.serial);
let safe_mode = Arc::clone(&self.safe_mode);

thread::spawn(move || {
let mut motors = motors.lock().unwrap();
Expand Down

0 comments on commit 5bf97cb

Please sign in to comment.