I’m using the ODrive Python library and was curious why the properties for odrv0 are not being predictively filled, or recognized at all for that matter. After some digging, I found that these properties seem to be locked behind the odrive_private package that can only be accessed with the interactive shell. Is there a way to actually install/ import this package in other code? Or another solution that would allow users to see the properties? Thanks.
Hi! Oh interesting – I think that may just be referring to some developer tools for low-level debugging. At least on my system, even in the ODrive Python package (no ODrivetool), I’m able to query device endpoints:
>>> import odrive
>>> odrv = odrive.find_any()
>>> odrv.__dict__
{'_refcount': 1, '_children': {read(obj: object_ref) -> value: uint32, pos_estimate: 0.0 (float)
status: 13 (uint8)
vel_estimate: 0.0 (float), config:
mode: 0 (uint8)
raw: 0.0 (float)
raw32: 0 (uint32)
status: 10 (uint8), control_loop_checks:
end_time: 0 (uint32)
length: 0 (uint32)
max_length: 376 (uint32)
.....
Output truncated because it’s a few hundred lines long
I’m guessing by “predicatively filled” you’re referring to e.g. tab-complete in an IDE? The ODrive endpoints (barring enums, e.g. AxisState.CLOSED_LOOP_CONTROL
) are dynamically read from the ODrive on connection, instead of being baked into ODrivetool / the ODrive library. This way, the ODrive library will function properly even if you’re using an ODrive with newer firmware than at the point of the library release, a new prototype ODrive, etc. For additional clarity on this design choice, each endpoint mapping file is about 80KB – across four products and ten firmware revisions, that’s a 3.2MB payload to package with the library, and would only increase in size in the future!
As such, I agree that your IDE will almost certainly not be able to infer the endpoints. However, for a given ODrive and firmware release, you can find the complete endpoint list on the firmware releases page as flat_endpoints.json
– this lists every available endpoint on the device, as well as the data type of said endpoint. I think it should be possible to turn this into a .pyi
file for your IDE’s code completion/typechecking purposes.
Ah ok, thank you for explaining the design philosophy and sharing the release page, this is exactly what I was looking for! I will definitely consider converting the endpoints json into a .pyi file