0

I'm totally out of ideas. In short:

>>> franka_o80.function_using_mode(o80.Mode.QUEUE)
TypeError: dummy3(): incompatible function arguments. The following argument types are supported:
    1. (arg0: o80::Mode) -> None
Invoked with: Mode.QUEUE

In details:

  1. There is a software o80, it has C++ enum Mode, and it is compiled into o80.so. There are also pybind11 bindings, exporting enum Mode into o80.Mode in o80_python.so.
  2. There is a toy example o80_example with correspondent o80_example.so and o80_example_python.so. I can do:
import o80
import o80_example
o80_example.function_accepting_mode(o80.Mode.QUEUE)
  1. There is my project, where I am doing same stuff, but I get what I pasted above. It seems like pybind finds no relations between Mode in o80_python.so and o80::Mode in code. I can even do pybind11::class_<o80::Mode>("OtherMode");, and then pass OtherMode in my function_using_mode - pybind sees no troubles. Functions from o80 are generally working, the problem is only in types.

Also as a symptom: This is normal: (arg0: o80.Mode) -> None This is what I have: (arg0: o80::Mode) -> None

What I tried:

  1. Playing with typedef and unsing namespace
  2. Checking that typeid().hash_code and typeid().name are the same in o80 and franka_o80 - they are the same
  3. Putting files in same directories as original - no help
  4. Looking at compile instructions:
o80_example:
/usr/bin/c++ -fPIC  -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic  -shared -Wl,-soname,libo80_example.so -o libo80_example.so CMakeFiles/o80_example.dir/src/driver_in.cpp.o CMakeFiles/o80_example.dir/src/driver_out.cpp.o CMakeFiles/o80_example.dir/src/standalone.cpp.o CMakeFiles/o80_example.dir/src/driver.cpp.o  -Wl,-rpath,/home/franka_panda/o80/install/lib::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /home/franka_panda/o80/install/lib/libo80.so /home/franka_panda/o80/install/lib/libsynchronizer.so /home/franka_panda/o80/install/lib/libtime_series.so /home/franka_panda/o80/install/lib/libshared_memory.so /usr/lib/x86_64-linux-gnu/librt.so /home/franka_panda/o80/install/lib/libreal_time_tools.so /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread -lpthread -ledit -lcurses -lnsl -lglut -lGL -lGLU -lX11 -lXmu -lm /home/franka_panda/o80/install/lib/libsignal_handler.so 

/usr/bin/c++  -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DRT_PREEMPT -DUSING_pybind11 -Do80_example_py_EXPORTS -I/home/franka_panda/o80/src/o80_example/include -I/home/franka_panda/o80/src/o80_example/SYSTEM -isystem /usr/include/python3.8 -isystem /home/franka_panda/o80/install/include -isystem /usr/include/eigen3  -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -fPIC   -fvisibility=hidden -std=gnu++17 -o CMakeFiles/o80_example_py.dir/srcpy/wrappers.cpp.o -c /home/franka_panda/o80/src/o80_example/srcpy/wrappers.cpp

/usr/bin/c++ -fPIC  -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic -Wl,--no-as-needed -Wall -Wextra -Wpedantic  -shared  -o o80_example.cpython-38-x86_64-linux-gnu.so CMakeFiles/o80_example_py.dir/srcpy/wrappers.cpp.o  -Wl,-rpath,/home/franka_panda/o80/build/o80_example:/home/franka_panda/o80/install/lib:::::::::::::::: /usr/lib/x86_64-linux-gnu/libpython3.8.so libo80_example.so /home/franka_panda/o80/install/lib/libo80.so /home/franka_panda/o80/install/lib/libsynchronizer.so /home/franka_panda/o80/install/lib/libtime_series.so /home/franka_panda/o80/install/lib/libshared_memory.so /usr/lib/x86_64-linux-gnu/librt.so /home/franka_panda/o80/install/lib/libreal_time_tools.so /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread -lpthread -ledit -lcurses -lnsl -lglut -lGL -lGLU -lX11 -lXmu -lm /home/franka_panda/o80/install/lib/libsignal_handler.so

franka_o80:
/usr/bin/c++ -fPIC  -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib -shared -Wl,-soname,libfranka_o80_cpp.so -o libfranka_o80_cpp.so CMakeFiles/franka_o80_cpp.dir/src/driver.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/kinematics.cpp.o CMakeFiles/franka_o80_cpp.dir/src/standalone.cpp.o CMakeFiles/franka_o80_cpp.dir/src/states.cpp.o CMakeFiles/franka_o80_cpp.dir/src/state.cpp.o   -L/opt/ros/noetic/lib  -Wl,-rpath,/opt/ros/noetic/lib -lfranka -lpinocchio /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 -lrt -lpthread /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread 

/usr/bin/c++  -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"franka_o80\" -DRT_PREEMPT -DUSING_pybind11 -Dfranka_o80_EXPORTS -I/opt/ros/noetic/include -I/opt/ros/noetic/include/libfranka -I/opt/ros/noetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -I/usr/include/eigen3 -isystem /usr/include/python3.8  -fPIC   -fvisibility=hidden -Wl,--no-as-needed -std=gnu++17 -o CMakeFiles/franka_o80.dir/src/wrappers.cpp.o -c /home/franka_panda/franka_o80/src/wrappers.cpp

/usr/bin/c++ -fPIC  -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib -shared -Wl,-soname,libfranka_o80_cpp.so -o libfranka_o80_cpp.so CMakeFiles/franka_o80_cpp.dir/src/driver.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_input.cpp.o CMakeFiles/franka_o80_cpp.dir/src/driver_output.cpp.o CMakeFiles/franka_o80_cpp.dir/src/kinematics.cpp.o CMakeFiles/franka_o80_cpp.dir/src/standalone.cpp.o CMakeFiles/franka_o80_cpp.dir/src/states.cpp.o CMakeFiles/franka_o80_cpp.dir/src/state.cpp.o   -L/opt/ros/noetic/lib  -Wl,-rpath,/opt/ros/noetic/lib -lfranka -lpinocchio /usr/lib/x86_64-linux-gnu/libboost_system.so.1.71.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0 -lrt -lpthread /usr/lib/x86_64-linux-gnu/libboost_atomic.so.1.71.0 -lpthread 

I can't see where the dark magic happens.

My CMakeLists.txt:

# franka_o80_cpp
add_library(franka_o80_cpp SHARED ..........)
target_include_directories(franka_o80_cpp PUBLIC ${franka_control_INCLUDE_DIRS})
target_include_directories(franka_o80_cpp PUBLIC ${pinocchio_INCLUDE_DIRS})
target_include_directories(franka_o80_cpp PUBLIC ${EIGEN3_INCLUDE_DIRS})
target_link_directories(franka_o80_cpp PUBLIC ${franka_control_LIBRARY_DIRS})
target_link_libraries(franka_o80_cpp PUBLIC franka)
target_link_libraries(franka_o80_cpp PUBLIC pinocchio)
target_link_libraries(franka_o80_cpp PUBLIC Boost::system Boost::thread)
target_link_libraries(franka_o80_cpp PUBLIC rt pthread)
target_compile_options(franka_o80_cpp PUBLIC -Wl,--no-as-needed)
target_link_options(franka_o80_cpp PUBLIC -Wl,--no-as-needed /usr/local/lib/libreal_time_tools.so /usr/local/lib/libshared_memory.so /usr/local/lib/libsignal_handler.so /usr/local/lib/libsynchronizer.so /usr/local/lib/libtime_series.so /usr/local/lib/libo80.so -Wl,-rpath,/usr/local/lib)
# franka_o80
if (pybind11_FOUND)
    add_library(franka_o80 MODULE src/wrappers.cpp)
    target_compile_definitions(franka_o80 PRIVATE USING_pybind11)
    target_link_libraries(franka_o80 PRIVATE pybind11::module)
    target_link_libraries(franka_o80 PRIVATE ${PYTHON_LIBRARIES})
    target_link_libraries(franka_o80 PRIVATE franka_o80_cpp)
    set_target_properties(franka_o80 PROPERTIES PREFIX "")
endif()

Code, rather boring:

pybind11::module::import("o80");
m.def("fucntion_using_mode", [](o80::Mode){});

Same things happen with all other types, Mode is just for simplicity. Ubuntu 20.04, g++ 9.3.0. Please help. o80 has overengineered ecosystem, it will take weeks to integrate with it. I'll provide all logs I can. Thank you.

UPD: changed lnking options from -lo80 to o80.so, still doesn't work.

1 Answer 1

1

For pybind11 to treat two classes as the same, not only their name should be equal, but also the file. o80's bindings were compiled with path_to_sources/install/include included, but my bindings were compiled with /usr/local/include included, so Python did not recognize them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.