0
$\begingroup$

Rosanswers logo

Hello there!

I am having trouble with a ros project that thows curious errors when trying to catkin_make it. here is the error:

In file included from /usr/include/boost/function/detail/maybe_include.hpp:18:0,
             from /usr/include/boost/function/detail/function_iterate.hpp:14,
             from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
             from /usr/include/boost/function.hpp:64,
             from /opt/ros/indigo/include/ros/forwards.h:40,
             from /opt/ros/indigo/include/ros/common.h:37,
             from /opt/ros/indigo/include/ros/ros.h:43,
             from /**"my cpp file in the line where i include <ros/ros.h>"**
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void 
boost::detail::function::void_function_invoker1<FunctionPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionPtr = void (*)(); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’:
/usr/include/boost/function/function_template.hpp:934:38:   required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (*)(); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:722:7:   required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (*)(); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/usr/include/boost/function/function_template.hpp:1069:16:   required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (*)(); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
**"my cpp file"**.cpp:239:48:   required from here
/usr/include/boost/function/function_template.hpp:112:11: error: too many arguments to function
           BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));

What i also don't get is that the error is first leading to the includes, but then the actual error aims into one of my files. The line targeted is as such (where server is a boost::shared_ptr<interactive_markers::InteractiveMarkerServer>):

server->insert(inter_marker, &functionName);

and a similar error on:

In file included from /usr/include/boost/function/detail/maybe_include.hpp:18:0,
                 from /usr/include/boost/function/detail/function_iterate.hpp:14,
                 from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
                 from /usr/include/boost/function.hpp:64,
                 from /opt/ros/indigo/include/ros/forwards.h:40,
                 from /opt/ros/indigo/include/ros/common.h:37,
                 from /opt/ros/indigo/include/ros/ros.h:43,
                 from **"my other cpp file where i include ros.h"**
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::void_function_invoker1<FunctionPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionPtr = void (*)(std::basic_string<char>); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’:
/usr/include/boost/function/function_template.hpp:934:38:   required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (*)(std::basic_string<char>); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:722:7:   required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (*)(std::basic_string<char>); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/usr/include/boost/function/function_template.hpp:1069:16:   required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (*)(std::basic_string<char>); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
**"my other cpp file"**.cpp:149:59:   required from here
/usr/include/boost/function/function_template.hpp:112:11: error: could not convert ‘a0’ from ‘const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >’ to ‘std::basic_string<char>’
           BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));

where by similar i mean that the error also points to "BOOST_FUNCTION_RETURN", what differs is that in this case, the line in my code is (where menu_handler is an interactive_markers::MenuHandler):

menu_handler.insert("string", &functionName);

It might be helpful to mention that a similar use of the functions has worked when the variables were still defined in the same file, but i outsourced them into a header, which shouldn't really cause a problem, but seemingly does for reasons i dont understand.

I am using ros indigo (as i am updating an older project). Might be helpful to mention that the project also contains an rviz panel plugin, but that isn't where the error occurs. My CMakeLists.txt looks like this (i guess and hope that this is where the error is):

cmake_minimum_required(VERSION 2.8.3)
project(heika_panel)

find_package(catkin REQUIRED COMPONENTS rviz)
catkin_package(INCLUDE_DIRS include)
include_directories(include ${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})

set(CMAKE_AUTOMOC ON)

if(rviz_QT_VERSION VERSION_LESS "5")
  message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
  include(${QT_USE_FILE})
else()

message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
  set(QT_LIBRARIES Qt5::Widgets)
endif()

add_definitions(-DQT_NO_KEYWORDS)

set(SRC_FILES
  src/heika_panel.cpp
  src/heika_display_path.cpp
  src/heika_radius.cpp
)

add_library(${PROJECT_NAME} ${SRC_FILES})

target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})

install(TARGETS


     ${PROJECT_NAME}
      ARCHIVE DESTINATION ${CATKI

N_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(FILES
  plugin_description.xml

  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

install(DIRECTORY media/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/media)

install(DIRECTORY icons/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/icons)

Thank you in advance and please tell me if you need any more information to diagnose this!


Originally posted by G on ROS Answers with karma: 46 on 2017-06-21

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

There is something wrong with your function prototypes for the functions that you're trying to use as interactive marker callbacks.

The compiler isn't able to convert a function with that function signature into the type required by the interactive marker server and the menu handler. Since this was working in a pervious version, I would double-check that your function signatures are exactly the same, and that the interactive markers API is still the same. It's possible that the interactive markers server is expecting a new callback type on newer versions of ROS.


Originally posted by ahendrix with karma: 47576 on 2017-06-24

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by G on 2017-06-25:
Thanks for your reply! Pittily, the only difference in the concerned code is that the variable definitions are outsourced in a header file. All includes are equal to the older version of the project, and that older project works fine on the same machine. Can it be the header or did i miss anything?

$\endgroup$
0
$\begingroup$

Rosanswers logo

Sorry for stealing your time, but i am completely refactoring the related code so i won't be able to further diagnose this situation.

If anyone encounters something similar, the only advice i have is that i think this was all caused by inept use of "extern" in headers.

If you have trouble with global variables in ros, consider "rosparam" as an option, it has multiple advantages.

Thanks to everyone who read this anyway


Originally posted by G with karma: 46 on 2017-06-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by G on 2017-08-06:
later enountered a similar problem after the mentioned refactor, posted it on "stack overflow" as it was more about c++ in general after all. In case anyone else ever has this issue: https://stackoverflow.com/questions/45103622/refer-to-a-function-that-is-member-of-a-class

$\endgroup$

Your Answer

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