(Solved) Motor Current Monitoring with live plotter

Hi All,

Does anyone know how I can run the start_liveplotter alongside a python code?

Because when I run the liveplotter in odrivetool, my python code cannot connect to the odrive with odrive.find_any() and I cannot run my code to perform motor movements and track the real time motor current supplied to the motor at the same time…

Thanks in advance

Ok so Oskar replied me on discord and i guess I will paste his reply here.

“You could launch your script while in the interactive odrivetool prompt using the %run command.
You can just cd to the correct folder that contains your script first, then run odrivetool in that folder, then it should just be %run yourscript.py”

I Tried doing this but it returns me a name error “odrv0 not defined” which is weird since the odrivetool has already connected to my odrive as odrv0, why can’t it define it?

Solution:

  1. in ur python code type this in -> from odrive.utils import start_liveplotter
  2. create a function that calls the start_liveplotter
  3. Profit$
3 Likes

Hi @Thisnbk

Could you show some example code?
i try to do this code.
it show error that “name ‘odrv0’ is not defined.”

import odrive
from odrive.utils import start_liveplotter

def liveplot():
start_liveplotter(lambda: [
odrv0.axis0.controller.vel_setpoint,
odrv0.axis0.encoder.vel_estimate,
odrv0.axis0.motor.current_control.Iq_setpoint,
odrv0.axis0.motor.current_control.Iq_measured])

liveplot()

and…

What is this meaning?

Thanks!