Ask Your Question
0

catkin_make fails: /opt/ros/kinetic/include/std_msgs/Float32.h errors

asked 2018-02-19 20:58:49 -0500

omgrobots gravatar image

I've installed ROS Kinetic from source on Debian 9 running on the BeagleBone Blue. I can run roscore and successfully create a workspace. I'm trying to create a node/package that will control the motors of a rover. I'm using the Float32 message type in my code. after sourcing the setup.bash for both my kinetic install and workspace, I run catkin_make from the root of the workspace. The following output is printed:

[  0%] Built target roscpp_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target roscpp_generate_messages_cpp
[  0%] Built target roscpp_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target rosgraph_msgs_generate_messages_nodejs
[  0%] Built target rosgraph_msgs_generate_messages_lisp
[  0%] Built target rosgraph_msgs_generate_messages_cpp
[  0%] Built target rosgraph_msgs_generate_messages_py
[  0%] Built target roscpp_generate_messages_py
[  0%] Built target rosgraph_msgs_generate_messages_eus
[  0%] Built target roscpp_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
[ 33%] Building CXX object drive/CMakeFiles/drive.dir/src/drive.cpp.o
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/string:40,
                 from /opt/ros/kinetic/include/std_msgs/Float32.h:9,
                 from /home/rover/RoverDaemons/src/drive/src/drive.cpp:9:
/usr/include/c++/6/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
                                                        ^
In file included from /usr/include/c++/6/bits/stl_algo.h:60:0,
                 from /usr/include/c++/6/algorithm:62,
                 from /usr/include/boost/math/tools/config.hpp:18,
                 from /usr/include/boost/math/special_functions/round.hpp:13,
                 from /opt/ros/kinetic/include/ros/time.h:58,
                 from /opt/ros/kinetic/include/ros/serialization.h:34,
                 from /opt/ros/kinetic/include/std_msgs/Float32.h:14,
                 from /home/rover/RoverDaemons/src/drive/src/drive.cpp:9:
/usr/include/c++/6/bits/algorithmfwd.h:375:41: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp&, const _Tp&, _Compare);
                                         ^

The output I've included is abbreviate to include only the first 2 errors but there are many more all referencing the Float32.h file. The drive.cpp code looks like

/* drive_node.cpp
 * licence: GPLv3
 */

#include "MotorControl.hpp"
#include <rc_usefulincludes.h> 
#include <roboticscape.h>
#include <std_msgs/Float32.h>
#include <ros/ros.h>

using namespace std;
using namespace rover;

void speedCallback(const std_msgs::Float32::ConstPtr& msg, 
        MotorControl motor_control){
    /* if they differ from current values then set speed and diff to new */
    if( msg->data != motor_control.get_speed() ){
        motor_control.set_speed(msg->data);
    }

    /* publish new speed to /drive_status */

}

void diffCallback(const std_msgs::Float32::ConstPtr& msg,
        MotorControl motor_control){
    /* if they differ from current values then set speed and diff to new */
    if( msg->data != motor_control.get_diff() ){
        motor_control.set_diff(msg->data);
    }

    /* publish new diff to /drive_status */

}

int main( int argc, char** argv ) {

    MotorControl motor_control = new MotorControl();

    ros::init(argc, argv, "drive");

    ros::NodeHandle n;

    /* subscribe to /drive_speed and /drive_diff */
    ros::Subscriber speedSub = n.subscribe("drive_speed", 1000, 
        boost::bind(speedCallback, _1, motor_control));
    ros::Subscriber diffSub = n.subscribe("diff_speed", 1000, 
        boost::bind(diffCallback, _1, motor_control));

    ros::spin();

        // exit cleanly
    delete(motor_control);

        return 0 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-19 21:26:32 -0500

ahendrix gravatar image

updated 2018-02-20 01:53:43 -0500

gvdhoorn gravatar image

It looks like rc_usefulincludes.h redefines the min macro, and this is incompatible with std::min that is defined by the C++ standard library: http://www.cplusplus.com/reference/al... . When other STL libraries try to call the standard 3-argument version of min, they fail. (This is valid even for C++98, so switching C++ versions will result in the same incompatibility)

You should probably either file a bug about this with that library, or fix it yourself by removing that line from that header, and updating the library to use std::min instead.

edit flag offensive delete link more

Comments

Yes! I can't believe I missed that. I removed the reference to rc_usefulincludes.h and the errors disappeared. I will follow up with the authors of that file. Thanks!

omgrobots gravatar imageomgrobots ( 2018-02-19 21:47:37 -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

Stats

Asked: 2018-02-19 20:58:49 -0500

Seen: 349 times

Last updated: Feb 20 '18