Hello, I have Odrive 3.6V with 0.5.4 firmware. I used python odrive API to control motors. I am using motors in Closed Loop and giving speed with controller.input_vel. The Problem when I lost connection with PC and Odrive , robot is going with last input speed. How to fix this issue, I need to calibrate odrive that if no input vel in some seconds i need to give 0 vel automaticallly from odrive itself. Who can fix it?
To automatically stop the motors if there is no input velocity for some time, you can implement a timeout feature in your code that sets the velocity to zero if no new input is received within a specified time period.
In Python, you can do this by using a timer that continuously checks the elapsed time since the last input velocity was set and if the elapsed time exceeds a certain threshold, set the velocity to zero.
Here’s an example of how you could implement this in Python:
pythonCopy code
import time
# Set the timeout threshold in seconds
timeout = 5
# Get the current time
start_time = time.time()
# Continuously check for new inputs
while True:
# Get the current time
current_time = time.time()
# Check if the elapsed time since the last input velocity is set exceeds the timeout threshold
if current_time - start_time > timeout:
# Set the velocity to zero if the elapsed time exceeds the timeout threshold
odrv.axis0.controller.input_vel = 0
else:
# Get the new input velocity
new_input_vel = #...
# Update the start time and set the new input velocity
start_time = time.time()
odrv.axis0.controller.input_vel = new_input_vel
This code will continuously check for new input velocities and set the velocity to zero if no new input is received within the specified timeout period.
This may help !
Thanks for help. I got your solution. But what happens if connection with controller and driver lost?
Is driver has some timeout function ? Like if no input commands in some elapsed time it gives 0 vel automatically.
Thanks
Use the integrated watchdog. See the API docs for help