I have a hoverboard setup by following the instructions on https://docs.odriverobotics.com/hoverboard.html I can set the desired velocity.
In python, how would I read the actual velocity and torque of the motors at each instant? Thank you!
I have a hoverboard setup by following the instructions on https://docs.odriverobotics.com/hoverboard.html I can set the desired velocity.
In python, how would I read the actual velocity and torque of the motors at each instant? Thank you!
Hi Moorage
The best place to start would be having a look at odrive_demo.py. If you have trouble running the script directly you can try running it through an Anaconda Prompt window by navigating to your odrive tools directory and then entering python odrive_demo.py
.
Any command that works in odrivetool will work in odrive_demo.py with the only difference being that you replace your normal odrv0.axis1...
with my_drive.axis1...
.
The number of encoder counts read per second is given by my_odrive.axis0.encoder.pll_vel
and so to obtain your velocity in RPM for an 8192 count per rotation encoder you would use axis0RPM = my_odrive.axis0.encoder.pll_vel)/8192)*60
.
The odrive can not measure torque directly, but instead measures current. If you know the KV of your motor then you can estimate the torque using the following relationship: axis0Torque = 8.27*my_odrive.axis0.motor.current_control.Iq_setpoint/150) * 100), # Torque [N.cm] = (8.27 * Current [A] / KV) * 100 ])
. If you don’t know the KV of your motor you can try estimating it using this guide or one like it.
It looks like the current documentation does not mention odrive_demo.py in any way so it might be time that we change that. When you become more comfortable using odrive_demo.py would you consider adding a few words about it to the odrive docs under the odrivetool subheading?
Good luck and let us know if you are still having trouble
From @madcowswe on discord:
(remember you can find out by getting odrv0.axis0.motor.config.pole_pairs
)
Thank you indeed, @Richard_Parsons ! From the torque perspective, I see that there was a similar post How to read the torque of the motor? as well. I’m trying to understand the constants in this equation, and I see from the Google Sheet Motor Guide that 8.27 is from cell B28
: =(3/2)/(sqrt(3)*(1/60)*2*PI())
. Is there a description for this equation, I can read up on?
And I’m guessing the last * 100
in the equation above is to convert from N.m
to N.cm
, right? Thank you!
And I’m guessing the last
* 100
in the equation above is to convert fromN.m
toN.cm
, right?
Yes thats right.
Regarding the torque equation check out the wiki page on motor torque constant.