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

simple question about #include </control_toolbox/pid.h>

asked 2012-05-21 06:25:46 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

First question about includes

OS: Ubuntu 12.04 64bit ROS: Fuerte

I'm trying to use control_toolbox node as part of my ROS project. This control_toolbox node I have installed manually by svn co the source, building it with rosmake and making sure roscd can find it.

I have included in the beginning of my project header-file

#include < /control_toolbox/pid.h >

But for some reason with this include I always get error:

fatal error: /control_toolbox/pid.h: No such file or directory

On the other hand if I include the whole path to control_toolbox pid.h file

#include < /home/user/ros_workspace/control_toolbox/include/control_toolbox/pid.h >

i do not receive previous error.

Second question about implementing control_toolbox

Also as a secondary question I'm curious how to implement control_toolbox for my use. I have tried following:

  • In header mkcontrol.h
namespace project
{
    class ProjectControl
    {
        private:    
        public: 
            control_toolbox::Pid pid_vel_x;
    };
}
  • In cpp file
#include "project_control/mkcontrol.h"
using namespace project;
using namespace control_toolbox;
//{
    ProjectControl::ProjectControl(ros::NodeHandle nh):
    n(nh)
    {
    pid_vel_x.initPid( 25 , 5 , 0 , 10 , -10 );
    }

Just a simple example how i was planning to use it, but i receive following errors (by error i'm referring to these undefined reference outputs from rosmake):

  Linking CXX executable ../bin/project_control
  CMakeFiles/project_control.dir/src/control_node.o: In function `~ProjectControl':
  ~/mkcontrol.h:58: undefined reference to `control_toolbox::Pid::~Pid()'
  CMakeFiles/project_control.dir/src/mkcontrol.o: In function `ProjectControl':
  ~/mkcontrol.cpp:45: undefined reference to `control_toolbox::Pid::Pid(double, double, double, double, double)'
  ~/mkcontrol.cpp:90: undefined reference to `control_toolbox::Pid::initPid(double, double, double, double, double)'
  ~/mkcontrol.cpp:45: undefined reference to `control_toolbox::Pid::~Pid()'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/project_control] Error 1
  make[3]: Leaving directory `...'
  make[2]: *** [CMakeFiles/project_control.dir/all] Error 2
  make[2]: Leaving directory `...'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `...'

After editing manifest.xml

I receive following error while trying to rosmake my node:

  [100%] Building CXX object CMakeFiles/project_control.dir/src/mkcontrol.o
  Linking CXX executable ../bin/project_control
  /home/user/ros_workspace/control_toolbox/lib/libcontrol_toolbox.so: undefined reference to `TiXmlElement::Attribute(char const*) const'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/project_control] Error 1
  make[3]: Leaving directory `~/project_control/build'
  make[2]: *** [CMakeFiles/project_control.dir/all] Error 2
  make[2]: Leaving directory `~/project_control/build'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory `~/project_control/build'

If I run make with VERBOSE=1 flag the compilation command with all includes is visible:

Linking CXX executable ../bin/project_control
/usr/bin/cmake -E cmake_link_script CMakeFiles/project_control.dir/link.txt --verbose=1
/usr/bin/c++   -O2 -g    -Wl,-rpath,~/ROS/control_toolbox/lib -Wl,-rpath,/opt/ros/fuerte/stacks/geometry/tf/lib -Wl,-rpath,/opt/ros/fuerte/stacks/bullet/lib -pthread CMakeFiles/project_control.dir/src/control_node.o CMakeFiles/project_control.dir/src/mkcontrol.o  -o ../bin/project_control -rdynamic -L/opt/ros/fuerte/lib -L~/ROS/control_toolbox/lib -L/opt/ros/fuerte/stacks/geometry/tf/lib -L/opt/ros/fuerte/stacks/bullet/lib -lcontrol_toolbox -ltf ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-05-22 06:51:38 -0500

ajr_ gravatar image

Solved the final undefined reference error by adding this line at the END of my CMakeList.txt

target_link_libraries(${PROJECT_NAME} tinyxml)

I guess it's correct way according to ROS wiki for tinyxml

edit flag offensive delete link more

Comments

Also noted that if this is already added to control_toolbox there would not have been any errors in my rosmake. Should it perhaps be already added to control_toolbox CMakeList.txt?

ajr_ gravatar image ajr_  ( 2012-05-22 10:08:34 -0500 )edit
2

answered 2012-05-21 06:30:56 -0500

dornhege gravatar image

updated 2012-05-21 06:32:22 -0500

#include < /control_toolbox/pid.h >

Remove the first /.

For the other question you are not showing the code from the error. Is the code for pid from the other package? Are there correct export tags so that the library is linked?

edit flag offensive delete link more

Comments

The error seems to stay no matter will i remove first / or not. #include <control_toolbox/pid.h> or either with "". I haven't used export tags, I assume this is the problem. Is there possible to get example what I need to include to my manifest.xml file?

ajr_ gravatar image ajr_  ( 2012-05-21 06:38:08 -0500 )edit

Do you have a <depend package="control_toolbox"/> in your manifest? The other package should have something like <export cpp...>

dornhege gravatar image dornhege  ( 2012-05-21 06:52:16 -0500 )edit

I added this <depend package="control_toolbox"/> to manifest.xml. Rosmake gave me another error which I updated to main question. OS: Ubuntu 12.04 64bit.

ajr_ gravatar image ajr_  ( 2012-05-21 08:25:16 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-05-21 06:25:46 -0500

Seen: 1,396 times

Last updated: May 22 '12