ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

CMakeList.txt

asked 2018-06-04 06:06:34 -0500

JonasG gravatar image

Hey, I want to include so moveit headers in my CMakeList.txt, because when I run catkin_make this error comes up

CMkeFiles/inv_node.dir/src/inv_node.cpp.o: In function 'main':
inv_node.cpp:(.text+0x33f): undefined reference to 'rdf_loader::RDFLoader::RDFLoader(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: ld returned 1 exit status
make[2]: *** [/home/youbot/catkin_wsj/devel/lib/inv_node/inv_node] Error 1
make[1]: *** [inv_node/CMakeFiles/inv_node.dir/all] Error 2
make: *** [all] Error2

Can anyone say me what I have to writte in my CMakeList.txt that it works?

That would be grade.

Thanks.

this is a part of my code:

#include <ros/ros.h>
#include <fstream>
#include <sstream>
#include <urdf/model.h>

// MoveIt!
#include <moveit/robot_model/robot_model.h>
#include <moveit/robot_state/robot_state.h>
#include <moveit/rdf_loader/rdf_loader.h>

int main(int argc, char **argv)
{
  ros::init(argc, argv, "inv_node");
  ros::AsyncSpinner spinner(1);
  spinner.start();

 ros::NodeHandle nh;

// Convert urdf file in a string
  std::ifstream u("youbot_arm.urdf");
  std::stringstream su;
  su << u.rdbuf();

// upload the urdf to the parameter server
  nh.setParam("robot_description", su.str());

  // Convert srdf file in a string
  std::ifstream s("youbot.srdf");
  std::stringstream ss;
  ss << s.rdbuf();

// upload the srdf to the parameter server
  nh.setParam("robot_description_semantic", ss.str());


// Initialize the robot model
// Objekt robot_model wird initialisiert durch Konstruktor der Klasse
  rdf_loader::RDFLoader::RDFLoader robot_model(su.str(), ss.str());

ros::shutdown();
return 0;
}

my CMakeList.txt:

cmake_minimu_required(VERSION 2.8.3)
project(inv_node)

find_package(catkin REQUIRED COMPONENTS
  moveit_core
  roscpp
  rospy
  urdf
)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES inv_node
  CATKIN_DEPENDS moveit_core roscpp rospy urdf
  DEPENDS system_lib
)

include_directories(
  ${catkin_INCLUDE_DIRS}
  opt/hydro/include/moveit/rdf_loader/rdf_loader.h
)

add_executable(inv_node src/inv_node.cpp)
target_link_libraries(inv_node ${catkin_LIBRARIES})
add_dependencies(inv_node inv_node_gencpp)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-06-04 08:04:09 -0500

mgruhler gravatar image

you need to find_package moveit_ros_planning (this is where the rdf_loader is located) and add it as a dependency in the package.xml.

This finds the library (what you have is a linker error) and populates the catkin_LIBRARIES variable (amongst others) accordingly. This also alows you to get rid of the ugly hard-coded path in the include_directories section.

Lastly, I'll highly recommend to upgrade to a more up-to-date ROS distro, as hydro is EOL. If you need a LTS, choose either kinetic (old, but everything should be available there) or melodic (brand-new, but not everything already available).

edit flag offensive delete link more

Comments

Now I have a error: No such file or directory compilation terminated. I don't know if i store the headers in the right directory. Directory opt/ros/hydro/include/moveit/rdf_loader contains the header-file rdf_loader

JonasG gravatar image JonasG  ( 2018-06-04 08:18:07 -0500 )edit

Directory opt/ros/hydro/include/moveit_ros_planning contains PlanExecutionDynamicReconfigureConfig.h, PlanningSceneMonitorDynamicReconfigureConfig.h, ...

My executable is in my workspace /home/catkin_wsj/src/inv_node/src

Is this a good way?

JonasG gravatar image JonasG  ( 2018-06-04 08:20:54 -0500 )edit

Thanks for your help :)

JonasG gravatar image JonasG  ( 2018-06-04 08:23:46 -0500 )edit
2

You shouldn't need to manually add that include directory if the rest of your CMakeLists.txt file is correct. That said, the error you are mentioning is likely because of the missing "/" at the beginning of /opt/.....

jarvisschultz gravatar image jarvisschultz  ( 2018-06-04 09:34:17 -0500 )edit

Thanks. Now it works.

JonasG gravatar image JonasG  ( 2018-06-04 09:45:43 -0500 )edit

@mig Do you have experience by using KDL PLugins for computing inverse kinematics?

JonasG gravatar image JonasG  ( 2018-06-06 03:44:30 -0500 )edit
1

@JonasG this is probably not a great place to ask this question as your KDL comment has nothing to do with the original question. If you'd like to ask something specific about IK with KDL, I'd suggest opening a new question or posting to the MoveIt! Users google group if the question is about MoveIt

jarvisschultz gravatar image jarvisschultz  ( 2018-06-07 09:21:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-04 06:06:34 -0500

Seen: 603 times

Last updated: Jun 04 '18