flexivrobotics/flexiv_rdk

[FEATURE] Catch exception by type in pyhton

Closed this issue · 4 comments

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

@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.

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

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

Ok, will do, thank you