Robotics StackExchange | Archived questions

Compiler error when trying to migrate to catkin

I'm trying to port a previous project to catkin , which has been made in rosbuild. After rewriting the CMakeLists.txt I encounter the following compiler error:

crazyflie@crazyflie-ThinkPad-T550:~/catkin_ws$ catkin_make
Base path: /home/crazyflie/catkin_ws
Source space: /home/crazyflie/catkin_ws/src
Build space: /home/crazyflie/catkin_ws/build
Devel space: /home/crazyflie/catkin_ws/devel
Install space: /home/crazyflie/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/crazyflie/catkin_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/crazyflie/catkin_ws/build"
####
[  0%] Built target roscpp_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target _crazypkg_generate_messages_check_deps_ViconData
[  0%] Built target _crazypkg_generate_messages_check_deps_ControllerOutputPackage
[  0%] Built target _crazypkg_generate_messages_check_deps_ControllerParam
[  0%] Built target _crazypkg_generate_messages_check_deps_MotorCommands
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target _crazypkg_generate_messages_check_deps_PositionSetpoint
[  0%] Built target _crazypkg_generate_messages_check_deps_SampleTimeParam
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target rosgraph_msgs_generate_messages_eus
[  0%] Built target roscpp_generate_messages_py
[  0%] Built target rosgraph_msgs_generate_messages_nodejs
[  0%] Built target roscpp_generate_messages_cpp
[  0%] Built target rosgraph_msgs_generate_messages_cpp
[  0%] Built target roscpp_generate_messages_eus
[  0%] Built target roscpp_generate_messages_lisp
[  0%] Built target rosgraph_msgs_generate_messages_py
[  0%] Built target rosgraph_msgs_generate_messages_lisp
[  4%] Built target CrazyControllers
[  6%] Building CXX object crazypkg/CMakeFiles/CrazyControl.dir/src/ControlManager.cpp.o
[ 21%] Built target crazypkg_generate_messages_py
[ 34%] Built target crazypkg_generate_messages_nodejs
[ 47%] Built target crazypkg_generate_messages_lisp
[ 60%] Built target crazypkg_generate_messages_cpp
[ 76%] Built target crazypkg_generate_messages_eus
[ 76%] Built target crazypkg_generate_messages
[ 80%] Built target ViconDataStreamSDK
[ 93%] Built target GUI
In file included from /opt/ros/kinetic/include/ros/serialization.h:37:0,
                 from /opt/ros/kinetic/include/ros/publisher.h:34,
                 from /opt/ros/kinetic/include/ros/node_handle.h:32,
                 from /opt/ros/kinetic/include/ros/ros.h:45,
                 from /home/crazyflie/catkin_ws/src/crazypkg/include/CrazyFlieInclude.h:5,
                 from /home/crazyflie/catkin_ws/src/crazypkg/src/ControlManager.cpp:1:
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = int]’:
/opt/ros/kinetic/include/ros/message_traits.h:255:102:   required from ‘const char* ros::message_traits::md5sum(const M&) [with M = int]’
/opt/ros/kinetic/include/ros/publisher.h:112:7:   required from ‘void ros::Publisher::publish(const M&) const [with M = int]’
/home/crazyflie/catkin_ws/src/crazypkg/src/ControlManager.cpp:518:69:   required from here
/opt/ros/kinetic/include/ros/message_traits.h:126:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of non-class type ‘const int’
     return m.__getMD5Sum().c_str();
                                  ^
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = int]’:
/opt/ros/kinetic/include/ros/message_traits.h:264:104:   required from ‘const char* ros::message_traits::datatype(const M&) [with M = int]’
/opt/ros/kinetic/include/ros/publisher.h:112:7:   required from ‘void ros::Publisher::publish(const M&) const [with M = int]’
/home/crazyflie/catkin_ws/src/crazypkg/src/ControlManager.cpp:518:69:   required from here
/opt/ros/kinetic/include/ros/message_traits.h:143:36: error: request for member ‘__getDataType’ in ‘m’, which is of non-class type ‘const int’
     return m.__getDataType().c_str();
                                    ^
crazypkg/CMakeFiles/CrazyControl.dir/build.make:62: recipe for target 'crazypkg/CMakeFiles/CrazyControl.dir/src/ControlManager.cpp.o' failed
make[2]: *** [crazypkg/CMakeFiles/CrazyControl.dir/src/ControlManager.cpp.o] Error 1
CMakeFiles/Makefile2:614: recipe for target 'crazypkg/CMakeFiles/CrazyControl.dir/all' failed
make[1]: *** [crazypkg/CMakeFiles/CrazyControl.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

This is the CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(crazypkg)


find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)
find_package(
  Qt5Widgets REQUIRED
  Qt5Core REQUIRED
  Qt5Gui REQUIRED
)

#-------------
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

qt5_wrap_ui(UIS_HDRS gui/untitled/mainguiwindow.ui)
qt5_wrap_cpp(SRC_HDRS gui/untitled/mainguiwindow.h)
#-------------


add_message_files(FILES
  ControllerOutputPackage.msg
  MotorCommands.msg
  SampleTimeParam.msg
  ControllerParam.msg
  PositionSetpoint.msg
  ViconData.msg
)

generate_messages(DEPENDENCIES std_msgs)

catkin_package(
  LIBRARIES
  DEPENDS
)
include_directories(
  ${catkin_INCLUDE_DIRS}
  include
)


#-------------
link_directories(${PROJECT_SOURCE_DIR}/src/ViconLibs)
#-------------

add_library(CrazyControl src/ControlManager.cpp)
add_library(CrazyControllers src/CrazyFlieControllers.cpp)

add_executable(ViconDataStreamSDK nodes/ViconDataStreamSDK.cpp)
add_executable(FlightControl nodes/FlightControl.cpp)
add_executable(GUI gui/untitled/mainguiwindow.cpp gui/untitled/main.cpp ${UIS_HDRS} ${SRC_HDRS})

add_dependencies(ViconDataStreamSDK ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_cpp_messages)
add_dependencies(FlightControl ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_cpp_messages)
add_dependencies(GUI ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_cpp_messages)


#-------------
qt5_use_modules(GUI Widgets)

#rosbuild_add_library(GUIMain gui/untitled/mainguiwindow.cpp)

target_link_libraries(FlightControl ${catkin_LIBRARIES})
target_link_libraries(FlightControl CrazyControl)
target_link_libraries(FlightControl CrazyControllers)

target_link_libraries(GUI ${catkin_LIBRARIES})
#target_link_libraries(GUI GUIMain)
target_link_libraries(GUI Qt5::Widgets)
#target_link_libraries(GUI CrazyControl)
#target_link_libraries(GUI CrazyControllers)

target_link_libraries(ViconDataStreamSDK ${catkin_LIBRARIES})
target_link_libraries(ViconDataStreamSDK libViconDataStreamSDK_CPP.so)
#-------------

And the package.xml:

<?xml version="1.0"?>
<package>
  <name>crazypkg</name>
  <version>0.0.0</version>
  <description>The crazypkg package</description>

  <!-- One maintainer tag required, multiple allowed, one person per tag --> 
  <!-- Example:  -->
  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
  <maintainer email="crazyflie@todo.todo">crazyflie</maintainer>


  <!-- One license tag required, multiple allowed, one license per tag -->
  <!-- Commonly used license strings: -->
  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
  <license>TODO</license>


  <!-- Url tags are optional, but multiple are allowed, one per tag -->
  <!-- Optional attribute type can be: website, bugtracker, or repository -->
  <!-- Example: -->
  <!-- <url type="website">http://wiki.ros.org/crazypkg</url> -->


  <!-- Author tags are optional, multiple are allowed, one per tag -->
  <!-- Authors do not have to be maintainers, but could be -->
  <!-- Example: -->
  <!-- <author email="jane.doe@example.com">Jane Doe</author> -->


  <!-- The *_depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use build_depend for packages you need at compile time: -->
  <!--   <build_depend>message_generation</build_depend> -->
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <!--   <run_depend>message_runtime</run_depend> -->
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

And some lines, that are part of the ControlManager.cpp. Including the erroneous line 518 at the end :

void CControlMgr::callbackViconData(const crazypkg::ViconData& msgViconData)
{
    if(fabs(msgViconData.x)>0.00001 && fabs(msgViconData.y)>0.00001 && fabs(msgViconData.z)>0.00001)
    {
        m_ViconDataPrev=m_ViconData;
        m_ViconData=msgViconData;
        m_ViconData.x/=1000;
        m_ViconData.y/=1000;
        m_ViconData.z/=1000;

        if(m_isCalibrating)
        {
            m_calCnt++;
            m_calRollSum+=m_ViconData.roll;
            m_calPitchSum+=m_ViconData.pitch;
        }

        m_ViconData.roll-=m_RollOffset;
        m_ViconData.pitch-=m_PitchOffset;

        m_derivativeEstimator->pushMeasurement(FullStateEstimation
                         (m_ViconData.acquiringTime, m_ViconData.x,m_ViconData.y,m_ViconData.z,
                                  m_ViconData.yaw,m_ViconData.pitch,m_ViconData.roll));

        m_SSKalmanEstimator->pushMeasurement(FullStateEstimation
                         (m_ViconData.acquiringTime, m_ViconData.x,m_ViconData.y,m_ViconData.z,
                                  m_ViconData.yaw,m_ViconData.pitch,m_ViconData.roll));

        m_fullStateEstimation=m_SSKalmanEstimator->estimateState();
        m_derivativeEstimation=m_derivativeEstimator->estimateState();




        if(m_pActiveCrazyController!=NULL)
        {
            m_pActiveCrazyController->setStateEstimation(m_fullStateEstimation);
            m_pRateController->setStateEstimation(m_fullStateEstimation);
        }

    }
    else
    {
        m_cntViconDataMissed++;
        m_pPublisherCntViconDataMissed->publish(m_cntViconDataMissed); //Line 518!!
    }
}

My guess is that somewhere in the CMakeLists.txt something is missing, but I can't find out what. All the project code compiled without errors on rosbuild, so it is correct. Thank you very much for your help.

Asked by short pants on 2017-03-09 03:44:09 UTC

Comments

The problem is actually most likely not with your build scripts, but with how you use certain pieces of ROS infrastructure. Can you show us some code around ControlManager.cpp:518?

Asked by gvdhoorn on 2017-03-09 06:24:51 UTC

Thanks for your reply!! I edited the original post. It shows the whole void CControlMgr::callbackViconData(const crazypkg::ViconData& msgViconData) which is part of ControlManager.cpp The Line 518 is at the end

Asked by short pants on 2017-03-09 07:15:24 UTC

Answers