Closed spacey-sooty closed 1 year ago
Can you give some more information about what you tried? My first ideas would be:
In my attempt to fix the example code I used these values
Can you post your code? Then I can try to check for bugs in the library on the weekend.
main.rs
extern crate ev3dev_lang_rust;
use ev3dev_lang_rust::Ev3Result;
use ev3dev_lang_rust::motors::{LargeMotor, MotorPort};
fn main() -> Ev3Result<()> {
let large_motor = LargeMotor::get(MotorPort::OutA)?;
large_motor.set_speed_sp(300)?;
large_motor.set_time_sp(1000)?;
large_motor.run_timed(Some(std::time::Duration::from_secs(10)))?;
Ok(())
}
I also tried using large_motor.run_forever()?;
Sorry for the late reply, but I couldn't reproduce your problem. After I started this sample program, the A
motor spun for 10 seconds. As you mentioned, the program didn't wait for the motor to finish. At the moment I can only guess that there is a service that automatically stops all motors after the program finishes (to prevent unintentional movements). To test this, you could try adding a wait time at the end. Or you could explicitly wait until the motor finishes spinning with “large_motor.wait_until_not_moving(None);”.
Regardless, the run_timed
and run_forever
commands seem to work as expected. As a minor node: The duration parameter of run_timed
overrides the set_time_sp
call. So in your example the motor ignores the time setpoint of 1000 ms and runs for 10 seconds.
Right thank you for the help I will see if I can figure this out over the week
I have compiled the example code and downloaded it on my EV3 and it doesn't move the motor. I have tried to use other methods of moving the motors but it is not working.