0

Rosanswers logo

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)


Originally posted by JonasG on ROS Answers with karma: 1 on 2018-06-04

Post score: 0

1 Answers1

0

Rosanswers logo

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).


Originally posted by mgruhler with karma: 12390 on 2018-06-04

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by JonasG on 2018-06-04:
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

Comment by JonasG on 2018-06-04:
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?

Comment by JonasG on 2018-06-04:
Thanks for your help :)

Comment by jarvisschultz on 2018-06-04:
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/.....

Comment by JonasG on 2018-06-04:
Thanks. Now it works.

Comment by JonasG on 2018-06-06:
@mig Do you have experience by using KDL PLugins for computing inverse kinematics?

Comment by jarvisschultz on 2018-06-07:
@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

Matthias
  • 5,805
  • 1
  • 1
  • 1