Ask Your Question

Revision history [back]

MoveIt undefined reference when declared inside the function

Hello,

When I create a move group interface in my main it builds (catkin_make) all good. However, the same thing if I have in my callBack it throws error. I have checked other posts and examples. I have added the headers correctly and hopefully my Cmakelist and package XML.

Using ROS Kinetic, Ubuntu 16.04.

Implementation:

static const std::string PLANNING_GROUP = "right_arm";
moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);

Error:

/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::MoveGroupInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<tf::Transformer> const&, ros::WallDuration const&)'
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()'
collect2: error: ld returned 1 exit status
sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/build.make:179: recipe for target '/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node' failed
make[2]: *** [/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node] Error 1
CMakeFiles/Makefile2:7765: recipe for target 'sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all' failed
make[1]: *** [sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

MoveIt undefined reference when declared inside the function

Hello,

When I create a move group interface in my main it builds (catkin_make) all good. However, the same thing if I have in my callBack it throws error. I have checked other posts and examples. I have added the headers correctly and hopefully my Cmakelist and package XML.

Using ROS Kinetic, Ubuntu 16.04.

Implementation:

static const std::string PLANNING_GROUP = "right_arm";
moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);

Basically checking the tutorial here

Error:

/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::MoveGroupInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<tf::Transformer> const&, ros::WallDuration const&)'
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()'
collect2: error: ld returned 1 exit status
sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/build.make:179: recipe for target '/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node' failed
make[2]: *** [/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node] Error 1
CMakeFiles/Makefile2:7765: recipe for target 'sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all' failed
make[1]: *** [sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

MoveIt undefined reference when declared inside the function

Hello,

When I create a move group interface in my main it builds (catkin_make) all good. However, the same thing if I have in my callBack it throws error. I have checked other posts and examples. I have added the headers correctly and hopefully my Cmakelist and package XML.

I am using Using ROS Kinetic, Ubuntu 16.04.

Implementation:16.04. I try to create a variable of MoveGroupInterface in my class as:

static const std::string PLANNING_GROUP = "right_arm";
moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);
right_arm;

Basically checking It throws me the tutorial herefollowing error. I suspected its a linking error, however, I checked my CmakeLists.txt and I guess it looks fine:

Error:

/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::MoveGroupInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<tf::Transformer> const&, ros::WallDuration const&)'
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()'
collect2: error: ld returned 1 exit status
sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/build.make:179: recipe for target '/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node' failed
make[2]: *** [/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node] Error 1
CMakeFiles/Makefile2:7765: recipe for target 'sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all' failed
make[1]: *** [sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

CmakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(sawyer_interface)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

find_package(catkin REQUIRED COMPONENTS

  moveit_core 
  moveit_ros_planning 
  moveit_ros_planning_interface 
  moveit_visual_tools
  intera_core_msgs
  geometry_msgs
  cmake_modules
  roscpp
  rospy
  std_msgs
  message_generation

)

find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED system thread)

catkin_package(
   CATKIN_DEPENDS roscpp rospy std_msgs moveit_ros_planning  moveit_ros_planning_interface moveit_core trajectory_msgs   
   INCLUDE_DIRS include 
   LIBRARIES tcp_comms

)

include_directories(include
  ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIR} 
  ${EIGEN3_INCLUDE_DIRS}
)

add_library(sw_lib
  src/sw.cpp
)

add_dependencies(sw_lib ${catkin_EXPORTED_TARGETS})


add_executable(sw_node src/sw_node.cpp)
add_dependencies(sw_node ${catkin_EXPORTED_TARGETS} sw_lib)
target_link_libraries(sw_node ${catkin_LIBRARIES} sw_lib)


install(TARGETS sw_lib sw_node
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(
  DIRECTORY include/${PROJECT_NAME}
  DESTINATION include
)


install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
  PATTERN ".svn" EXCLUDE)


if(CATKIN_ENABLE_TESTING)
    find_package(rostest REQUIRED)

endif()

MoveIt undefined reference when declared inside the function

Hello,

I am using Using ROS Kinetic, Ubuntu 16.04. I try to create a variable of MoveGroupInterface in my class as:

#include <moveit/move_group_interface/move_group_interface.h>

Class Test{
private:
    moveit::planning_interface::MoveGroupInterface right_arm;
right_arm;    
}

It throws me the following error. I suspected its a linking error, however, I checked my CmakeLists.txt and I guess it looks fine:

Error:

/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::MoveGroupInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<tf::Transformer> const&, ros::WallDuration const&)'
/home/artc/catkin_ws/devel/lib/libsw_lib.so: undefined reference to `moveit::planning_interface::MoveGroupInterface::~MoveGroupInterface()'
collect2: error: ld returned 1 exit status
sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/build.make:179: recipe for target '/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node' failed
make[2]: *** [/home/artc/catkin_ws/devel/lib/sawyer_interface/sw_node] Error 1
CMakeFiles/Makefile2:7765: recipe for target 'sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all' failed
make[1]: *** [sawyer_robot/sawyer_interface/CMakeFiles/sw_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

CmakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(sawyer_interface)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

find_package(catkin REQUIRED COMPONENTS

  moveit_core 
  moveit_ros_planning 
  moveit_ros_planning_interface 
  moveit_visual_tools
  intera_core_msgs
  geometry_msgs
  cmake_modules
  roscpp
  rospy
  std_msgs
  message_generation

)

find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED system thread)

catkin_package(
   CATKIN_DEPENDS roscpp rospy std_msgs moveit_ros_planning  moveit_ros_planning_interface moveit_core trajectory_msgs   
   INCLUDE_DIRS include 
   LIBRARIES tcp_comms

)

include_directories(include
  ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIR} 
  ${EIGEN3_INCLUDE_DIRS}
)

add_library(sw_lib
  src/sw.cpp
)

add_dependencies(sw_lib ${catkin_EXPORTED_TARGETS})


add_executable(sw_node src/sw_node.cpp)
add_dependencies(sw_node ${catkin_EXPORTED_TARGETS} sw_lib)
target_link_libraries(sw_node ${catkin_LIBRARIES} sw_lib)


install(TARGETS sw_lib sw_node
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(
  DIRECTORY include/${PROJECT_NAME}
  DESTINATION include
)


install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
  PATTERN ".svn" EXCLUDE)


if(CATKIN_ENABLE_TESTING)
    find_package(rostest REQUIRED)

endif()