2b-t / myactuator_rmd

C++ and Python SDK for controlling actuators of the MyActuator RMD-X series, written in C++ with Python bindings
MIT License
14 stars 6 forks source link

Python bindings usage fails #7

Open TheWylieStCoyote opened 2 weeks ago

TheWylieStCoyote commented 2 weeks ago

The python bindings fail when creating new driver.

Python 3.12.3 (main, June 19 2024, 05:33:47) [GCC 13.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import myactuator_rmd_py as myactuator_rmd

In [2]: driver1 = myactuator_rmd.Driver('can0', 1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 driver1 = myactuator_rmd.Driver('can0', 1)

TypeError: myactuator_rmd_py.Driver: No constructor defined!

In [3]: dir(myactuator_rmd)
Out[3]: 
['ActuatorException',
 'ActuatorInterface',
 'CanDriver',
 'Driver',
 'ProtocolException',
 'ValueRangeException',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 'actuator_constants',
 'actuator_state',
 'can']
2b-t commented 2 weeks ago

Are you using the most up to date version of the code? You might be running your code (that is based on an old version) in combination with the latest version of this repository.

In the latest version Driver is a pure abstract base class that allows me to extend this driver from CAN to other interfaces like RS-485 in the future. The binding for Driver in this version only exists as it is used in the interface of ActuatorInterface. This way I could add an Rs485Driver and use it interchangeably. The syntax in the latest version is therefore slightly different (see the main read-me for more information):

import myactuator_rmd_py as rmd

driver = rmd.CanDriver("can0")
actuator = rmd.ActuatorInterface(driver, 1)
TheWylieStCoyote commented 2 weeks ago

I pulled in the most newest. Where should I go?

2b-t commented 2 weeks ago

The latest is perfectly fine but as said you are not running the right commands. As said try the following:

import myactuator_rmd_py as rmd

driver = rmd.CanDriver("can0")
actuator = rmd.ActuatorInterface(driver, 1)
2b-t commented 1 week ago

Hi @TheWylieStCoyote, Did this resolve your issue?

TheWylieStCoyote commented 1 week ago

Yes but, it ended up being a miss configured Python path problem is what I was having. When I would go to import myactuator_rmd_py it was returning the bindings for the old version. However now I am getting a SocketExecption: Interface 'can0' - Could not read CAN frame: Resource temporarily unavailable when ever I'm trying to communicate with the motors.

2b-t commented 1 week ago

Pretty certain that this is not related to this driver but instead a misconfiguration of the communication. The three reasons that I can think of off the top of my head: