flexivrobotics / flexiv_rdk

RDK (robotic development kit) for Flexiv robots. Supports C++ and Python. Compatible with Linux, macOS, and Windows.
Apache License 2.0
58 stars 18 forks source link

[FEATURE] Catch exception by type in pyhton #69

Closed skyrimax closed 1 month ago

skyrimax commented 1 month ago

Is your feature request related to a problem? Please describe. I cannot catch exceptions by type in python, python's generic RuntimeError is thrown instead.

Describe the solution you'd like I would like to be able to catch exceptions by the types defined in the C++ RDK, like this:

import flexivrdk

robot_ip = '192.168.1.100
local_ip = '192.168.1.101

try:
    flexivrdk.robot(robot_ip, local_ip)
except flexivrdk.InitException as e:
    # do some stuff
except flexivrdk.CompatibilityException:
    exit(1)
except flexivrdk.CommException:
    # do some other stuff

Describe alternatives you've considered I thought about parsing the exception's message string, but that required access to the source code to make sure all cases are covered, but I assume that is not possible

Additional context I am using python 3.10 on both x86_64 as well as arm64 machines I installed the corresponding .so libraries in /usr/local/lib/python3.10/site-packages/ on both machines

pzhu-flexiv commented 1 month ago

@skyrimax You can do this in RDK v1.4, which will be released by the end of this week. The mapping between RDK exceptions and Python exceptions can be found here.

skyrimax commented 1 month ago

@pzhu-flexiv will we have to update the robot's firmware? We use a Rizon10, not a 10s.

pzhu-flexiv commented 1 month ago

@skyrimax Yes, you will have to upgrade to Flexiv Software Package v3.6. You can contact your sales rep and request the upgrade.

skyrimax commented 1 month ago

Ok, will do, thank you