Mock Odrive in python for code tests?

Hello folks,

Has anyone worked on a mock odrive class in python that would act like an odrive without doing anything? I have a robot with four odrives and I want to build a test stand with zero odrives attached and run as much of my code as possible on it, including the motor control code.

I am going to look in to this but I thought i would ask in case anyone has already done it. Thanks!

For simulating what the motor currents do, you can check out this.
As for isolating the control code to interact with that simulation that is going to be a bit more involved, but something we also want to do at some point.

What interface do you want to use to talk to the (simulated) ODrive? Simulated USB/fibre, or something else?

1 Like

Thanks Oskar! Simulating motor currents is interesting! I will look at that down the road.

To start, I just want to simulate an odrive connected via usb/fiber. I have all this code that interacts with the python “odrv” object and I want to create an instance of a mock odrive and be able to at least interact with the object without error, and be able to extend a couple functions so my control code is happy with the responses (I only check a few things for correctness right now).

But I don’t understand fiber very well and I also don’t understand mock (if applicable) well. Do you have an idea how this might be implemented?


The easiest way may be to even skip fibre, and just make some dummy classes with some data members that mimics the tree structure you are expecting.

Yah you may be right. I’ll give that a try. Thanks!