Ask Your Question
0

undefined reference to KDL::Rotation::Quaternion

asked 2018-03-12 07:28:01 -0600

dinesh gravatar image

updated 2018-03-12 23:57:52 -0600

I am using orocos toolchain 2.9, ros kinetic, ubunt u16.

CMakeFiles/localisation-component.dir/src/localisation-component.cpp.o: In function `Localisation::updateHook()':
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0xd3): undefined reference to `KDL::Rotation::Quaternion(double, double, double, double)'
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0xe6): undefined reference to `KDL::epsilon'
localisation-component.cpp:(.text._ZN12Localisation10updateHookEv[_ZN12Localisation10updateHookEv]+0x10b): undefined reference to `KDL::Rotation::GetRotAngle(KDL::Vector&, double) const'
collect2: error: ld returned 1 exit status
youbot-controller/CMakeFiles/localisation-component.dir/build.make:133: recipe for target '/home/robot/youbot_catkin_ws/devel/lib/orocos/gnulinux/youbot-controller/liblocalisation-component-gnulinux.so' failed
make[2]: *** [/home/robot/youbot_catkin_ws/devel/lib/orocos/gnulinux/youbot-controller/liblocalisation-component-gnulinux.so] Error 1
CMakeFiles/Makefile2:1273: recipe for target 'youbot-controller/CMakeFiles/localisation-component.dir/all' failed
make[1]: *** [youbot-controller/CMakeFiles/localisation-component.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

My CmakeLists.txt file is:

cmake_minimum_required(VERSION 2.8.3)
project(youbot-controller)

### ROS Dependencies ###
# Find the RTT-ROS package (this transitively includes the Orocos CMake macros)
find_package(catkin REQUIRED COMPONENTS
  rtt_ros

  rtt_tf
  # ADDITIONAL ROS PACKAGES
  )

find_package(orocos_kdl)
find_package(kdl_parser)

include_directories(${catkin_INCLUDE_DIRS})

### Orocos Dependencies ###
# Note that orocos_use_package() does not need to be called for any dependency
# listed in the package.xml file

include_directories(${USE_OROCOS_INCLUDE_DIRS})

### Orocos Targets ###

orocos_component(localisation-component src/localisation-component.cpp)
target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_library(my_library src/my_library.cpp)
# target_link_libraries(my_library ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_service(my_service src/my_service.cpp)
# target_link_libraries(my_service ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_plugin(my_plugin src/my_plugin.cpp)

# target_link_libraries(my_plugin ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

# orocos_typekit(my_typekit src/my_typekit.cpp)
# target_link_libraries(my_typekit ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

### Orocos Package Exports and Install Targets ###

# Generate install targets for header files

orocos_install_headers(DIRECTORY include/${PROJECT_NAME})

# Export package information (replaces catkin_package() macro) 
orocos_generate_package(
  INCLUDE_DIRS include
  DEPENDS rtt_ros
  )

the src file is:

#ifndef OROCOS_LOCALISATION_COMPONENT_HPP
#define OROCOS_LOCALISATION_COMPONENT_HPP

#include <rtt/RTT.hpp>
#include <iostream>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/TransformStamped.h>
#include <kdl/frames.hpp>

class Localisation
    : public RTT::TaskContext
{
    geometry_msgs::TransformStamped tfs;
    RTT::OutputPort<geometry_msgs::Pose2D> outpose;
 public:
    Localisation(std::string const& name)
        : TaskContext(name, PreOperational)
    {
        addPort("pose", outpose).doc("Contains latest Youbot Pose.");
    }

    bool configureHook() {
        /** Check in here that we can call rtt_tf */
        return false;
    }

    void updateHook() {
        try {
            /* tfs = ...call rtt_tf and query the transform /odom to /base_footprint ... ; */
        } catch (...) {
            return;
        }
        geometry_msgs::Pose2D pose;
        pose.x = tfs.transform.translation.x;
        pose.y = tfs.transform.translation.y;
        geometry_msgs::Quaternion qu = tfs.transform.rotation;
        KDL::Rotation rot = KDL::Rotation::Quaternion(qu.x, qu.y, qu.z, qu.w);
        KDL::Vector v;
        pose.theta = rot.GetRotAngle(v);
        outpose.write(pose);
    }
};

#endif
edit retag flag offensive close merge delete

Comments

So where do you link against kdl_parser libraries? Just find_package(..)ing that package is not enough.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-12 09:23:45 -0600 )edit

i tried like that also but still the same error. something problem with api version mismatch?

dinesh gravatar imagedinesh ( 2018-03-12 23:56:04 -0600 )edit

i tried like that also

you tried what? As always: show what you did.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-13 01:51:57 -0600 )edit

i've edited above question in CmakeLists.txt file. by adding find_package(orocos_kdl) find_package(kdl_parser) and target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})

dinesh gravatar imagedinesh ( 2018-03-13 06:09:18 -0600 )edit

I'm not too familiar with what ${USE_OROCOS_LIBRARIES} does exactly, but unless it automatically pulls in the libraries of kdl_parser and orocos_kdl, I would expect to still see linker errors.

Note also that this doesn't seem like a ROS question. At best one to ask of the OROCOS devs.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-13 06:14:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-03-14 07:25:52 -0600

The orocos_kdl_LIBRARIES are not picked up by catkin or orocos, so they are not part of ${catkin_LIBRARIES} or ${USE_OROCOS_LIBRARIES}. you need to add them to your target_link_libraries statement:

target_link_libraries(localisation-component ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES} ${orocos_kdl_LIBRARIES}),

your probably should do something similar for the include directories:

include_directories(${catkin_INCLUDE_DIRS} ${orocos_kdl_INCLUDE_DIRS}

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-12 07:28:01 -0600

Seen: 256 times

Last updated: Mar 14 '18