Ask Your Question
0

Compile error with ROS. Possible bug?

asked 2017-03-07 04:59:10 -0500

mertes13 gravatar image

updated 2017-03-07 06:04:09 -0500

Hello! I have been trying to compile my project with ROS Indigo and C++ (Ubuntu 14.04) and getting an error which I do not understand. I define a class named Point2dc and in the code, it is used multiple times to create vectors etc. The (4000 line) error I get can be found below under the link:

http://pastebin.com/LWMd7j8y

The class is defined as follows:

#ifndef POINT2DC_H
#define POINT2DC_H

#include "ros/ros.h"
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>

#include <i2ease_msgs/VehicleObject.h>
#include <i2ease_msgs/Object.h>
#include <i2ease_msgs/VehicleObjectList.h>
#include <i2ease_msgs/SensorObjectList.h>

using namespace std;
using namespace ros;

class Point2dc
{
public:
    Point2dc(float pos_x, float pos_y);
    Point2dc();

    float pos_x;
    float pos_y;

    float get_polar_angle();
    float get_polar_r();
    float distance_to_point(Point2dc p);

};
#endif

The error occurs, when including "ros/ros.h" in another custom class called Vehicle.

Thanks in advance.

Edit:

This is just a small excerpt of the error I get. For the full error, please check the link above. Excuse my poor formatting :)

             from /usr/include/boost/math/tools/config.hpp:16,
             from /usr/include/boost/math/special_functions/round.hpp:13,
             from /opt/ros/indigo/include/ros/time.h:58,
             from /opt/ros/indigo/include/ros/ros.h:38,
             from /home/mertes13/catkin_ws/src/irt_visualization/include/Vehicle.h:4,
             from /home/mertes13/catkin_ws/src/irt_visualization/src/Vehicle.cpp:1:
             /usr/include/c++/4.8/bits/stl_algo.h:166:17: note:   ‘Point2dc’ is not derived from ‘conststd::_List_iterator<_Tp>’
             if (*__first == __val)
             ^
             In file included from /usr/include/c++/4.8/set:62:0,
             from /opt/ros/indigo/include/ros/forwards.h:34,
             from /opt/ros/indigo/include/ros/common.h:37,
             from /opt/ros/indigo/include/ros/ros.h:43,
             from /home/mertes13/catkin_ws/src/irt_visualization/include/Vehicle.h:4,
             from /home/mertes13/catkin_ws/src/irt_visualization/src/Vehicle.cpp:1:
             /usr/include/c++/4.8/bits/stl_multiset.h:739:5: note: template<class _Key, class _Compare, class                                 _Alloc> bool std::operator==(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)
              operator==(const multiset<_Key, _Compare, _Alloc>& __x,
              ^
              /usr/include/c++/4.8/bits/stl_multiset.h:739:5: note:   template argument deduction/substitution failed:
             In file included from /usr/include/c++/4.8/algorithm:62:0,
             from /usr/include/boost/math/tools/config.hpp:16,
             from /usr/include/boost/math/special_functions/round.hpp:13,
             from /opt/ros/indigo/include/ros/time.h:58,
             from /opt/ros/indigo/include/ros/ros.h:38,
             from /home/mertes13/catkin_ws/src/irt_visualization/include/Vehicle.h:4,
             from /home/mertes13/catkin_ws/src/irt_visualization/src/Vehicle.cpp:1:
             /usr/include/c++/4.8/bits/stl_algo.h:166:17: note:   ‘Point2dc’ is not derived from ‘const std::multiset<_Key, _Compare, _Alloc>’
              if (*__first == __val)
             ^
             In file included from /usr/include/c++/4.8/set:61:0,
             from /opt/ros/indigo/include/ros/forwards.h:34,
             from /opt/ros/indigo/include/ros/common.h:37,
             from /opt/ros/indigo/include/ros/ros.h:43,
             from /home/mertes13 ...
(more)
edit retag flag offensive close merge delete

Comments

1

Please include the error message in your question. If the pastebin link ever goes away, this question becomes useless.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-07 05:30:38 -0500 )edit

Thanks! I pasted just a small part of the error, since it is over 4000 lines. The rest is pretty similar to this. Hope this helps.

mertes13 gravatar image mertes13  ( 2017-03-07 05:49:24 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-03-07 08:56:34 -0500

lucasw gravatar image

updated 2017-03-07 09:43:22 -0500

It is usually the very first errors in the error output that are important and all you need to post- error: no match for ‘operator==’ (operand types are ‘Point2dc’ and ‘const Point2dc’) means you haven't defined the == operator for your class. If there is an operator == in your point2dc.cpp file (and it compiles until you include ros.h?) then something else is preventing it from getting compiled properly.

Possibly it is the using namespace std and ros in the header (see http://stackoverflow.com/questions/58... ).

edit flag offensive delete link more

Comments

Thank you for your answer! What causes the error was my use of "==" operator to compare points, without defining the operator for the class. This saved my day, thanks a lot :)

mertes13 gravatar image mertes13  ( 2017-03-07 09:11:43 -0500 )edit
1

Just a note:

using namespace std;
using namespace ros;

Please don't do this and for now (until you get more comfortable with C++ and understand all the implications) and just use std::string and ros::NodeHandle for now. Importing namespaces wholesale like that is asking for trouble.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-07 09:14:28 -0500 )edit

Thanks a lot for your help. I will consider the advice about the namespaces, I appreciate it. In this case, the problem was not the namespaces. I have solved it by overloading the == operator for the class Point2dc :)

mertes13 gravatar image mertes13  ( 2017-03-07 11:06:27 -0500 )edit

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: 2017-03-07 04:59:10 -0500

Seen: 191 times

Last updated: Mar 07 '17