Python3 binding with NodeHandle and roscpp_init

asked 2020-06-19 08:35:59 -0500

azerila gravatar image

updated 2020-06-19 08:43:58 -0500

I have made a python3 binding with a c++ class that uses node-handle. In the ros python binding documentation about python binding it is mentioned that one should add the following two lines before instantiating the python class:

from moveit_ros_planning_interface._moveit_roscpp_initializer import roscpp_init
roscpp_init('node_name', [])

However. since I use python3, doing so has brought the following error:

    from moveit_ros_planning_interface._moveit_roscpp_initializer import roscpp_init
ImportError: dynamic module does not define module export function (PyInit__moveit_roscpp_initializer)

which is because of python3 incompatibility. Does anyone know any solution for this issue? And can I already have the node instantiated in the c++ class when I instantiate its python one?

In addition, initially my class looked like the following for construct:

ROBOTInterface::ROBOTInterface(ros::NodeHandle& nh) : nh_(nh) { 
       state_sub     = nh_.subscribe( ....

and in main:

int main(int argc, char** argv)
    ros::init(argc, argv, "remote_hardware_interface");
    ros::NodeHandle nh;
    ROBOTInterface ROBOT(nh);
    return 0;

which I had removed it's node handle argument without being sure if it's right:

ROBOTHardwareInterface::ROBOTHardwareInterface() { 
edit retag flag offensive close merge delete