0
$\begingroup$

Rosanswers logo

##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 

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 

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 -lboost_thread-mt -lBulletDynamics -lBulletCollision -lLinearMath -lsensor_msgs -lmessage_filters -lroscpp -lrostime -lrosconsole -lroscpp_serialization -lxmlrpcpp -Wl,-rpath,/opt/ros/fuerte/lib:~/ROS/control_toolbox/lib:/opt/ros/fuerte/stacks/geometry/tf/lib:/opt/ros/fuerte/stacks/bullet/lib 
~/ROS/control_toolbox/lib/libcontrol_toolbox.so: undefined reference to `TiXmlElement::Attribute(char const*) const'
collect2: ld returned 1 exit status
make[3]: *** [../bin/mikrokopter_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'
make: *** [all] Error 2

if we look at the c++ compilation command with all the includes. Is there maybe missing this libtinyxml library include? Maybe this undefined reference error also could point in to this direction? But I dont know how to add this include properly..

I'm grateful for all tips!


Originally posted by ajr_ on ROS Answers with karma: 97 on 2012-05-21

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

#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?


Originally posted by dornhege with karma: 31395 on 2012-05-21

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by ajr_ on 2012-05-21:
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?

Comment by dornhege on 2012-05-21:
Do you have a in your manifest? The other package should have something like

Comment by ajr_ on 2012-05-21:
I added this to manifest.xml. Rosmake gave me another error which I updated to main question. OS: Ubuntu 12.04 64bit.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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


Originally posted by ajr_ with karma: 97 on 2012-05-22

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ajr_ on 2012-05-22:
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?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.