Unable to find console.h from ros folder ROS Melodic

asked 2020-01-08 05:28:04 -0600

Hi All,

I have a cpp file with some source code and 2 #includes of ROS

#include "ros/ros.h"
#include "ros/console.h"

I am trying to convert this file to python. I am successfully able to do it, but it is unable to find console.h which is #included. My problem looks similar to a post which is addressed here referred question linked here, which suggests a problem with cmake file. But in contrast with the suggested solution, my cmake also looks fine. It aligns with the suggested solution. But still gives me error. Inside ros folder it has ros.h, console.h.. But it is unable to link. I work on ROS melodic and not kinetic in Ubuntu 18.04. Am I missing on something?

CmakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project( arduino_lib)

find_package(catkin REQUIRED COMPONENTS
    roscpp
    std_msgs
    message_generation
    ) 
add_message_files(
  FILES
 ....
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
  CATKIN_DEPENDS message_runtime
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

add_subdirectory(src)

Package.xml:

<?xml version="1.0"?>
<package format="2">
  <name>aadc_arduino</name>
  <version>0.0.0</version>
  <description>The arduino_lib package</description>

  <maintainer email="drl@todo.todo">drl</maintainer>


  <license>TODO</license>

 <exec_depend>message_runtime</exec_depend>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>std_msgs</exec_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

Goal :

My main aim is to convert a cpp file which has ros included files to python and can be imported as a library.

Error :

>  ImportError: /home/anaconda3/lib/python3.7/site-packages/arduino_lib.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3ros7console13g_initializedE

I understand from this error that it is unable to find ros-console. But when I check inside my ROS folder, console.h file is present.

Any suggestions on what am I missing is much appreciated.

edit retag flag offensive close merge delete

Comments

Not sure if that is the root cause of your problem, but using an alternative python interpreter over the System standard on is highly discouraged. As there is anaconda on your path, this might be the cause of error here. Please try if the works with the apt installed standard python distribution for 18.04.

There are quite a lot of related questions, e.g. #q301850 (though not a full duplicate).

mgruhler gravatar imagemgruhler ( 2020-01-08 06:27:50 -0600 )edit