Robotics StackExchange | Archived questions

Boost error when creating custom InteractiveMarkerServer callback

I am working on a piece of code to be ran in rviz that takes code from the following two tutorials:

https://github.com/ros-visualization/visualization_tutorials/blob/indigo-devel/interactive_marker_tutorials/src/basic_controls.cpp (from the void makeChessPieceMarker as well as alignMarker functions)

https://wiki.ros.org/rviz/Tutorials/Interactive%20Markers%3A%20Writing%20a%20Simple%20Interactive%20Marker%20Server (I used code from this as the skeleton for my code)


include ros/ros.h
include interactivemarkers/interactivemarkerserver.h
include tf/tf.h
//the includes in my actual code have # and <> but I couldn't get it to format for this post
using namespace visualizationmsgs;
void processFeedback(
    const InteractiveMarkerFeedbackConstPtr &feedback ){
  ROSINFOSTREAM( feedback->markername << " is now at "
      << feedback->pose.position.x << ", " << feedback->pose.position.y
      << ", " << feedback->pose.position.z );
}
void alignMarker( const InteractiveMarkerFeedbackConstPtr &feedback, interactivemarkers::InteractiveMarkerServer &server ){
  geometrymsgs::Pose pose = feedback->pose;
  pose.position.x = round(pose.position.x-0.5)+0.5;
  pose.position.y = round(pose.position.y-0.5)+0.5;
  ROSINFOSTREAM( feedback->markername << ":"
      << " aligning position = "
      << feedback->pose.position.x
      << ", " << feedback->pose.position.y
      << ", " << feedback->pose.position.z
      << " to "
      << pose.position.x
      << ", " << pose.position.y
      << ", " << pose.position.z );
  server.setPose( feedback->markername, pose );
  server.applyChanges(); 
}
void createCube(const tf::Vector3 &position,interactivemarkers::InteractiveMarkerServer &server){
   // create an interactive marker for our server
  InteractiveMarker intmarker;
  intmarker.header.frameid = "baselink";
  intmarker.header.stamp=ros::Time::now();
  intmarker.name = "mymarker";
  intmarker.description = "Simple 1-DOF Control";
  // create a grey box marker
  Marker boxmarker;
  boxmarker.type = Marker::CUBE
  boxmarker.scale.x = 0.45;
  boxmarker.scale.y = 0.45;
  boxmarker.scale.z = 0.45;
  boxmarker.color.r = 0.5;
  boxmarker.color.g = 0.5;
  boxmarker.color.b = 0.5;
  boxmarker.color.a = 1.0;
  // create a non-interactive control which contains the box
  visualizationmsgs::InteractiveMarkerControl boxcontrol;
  boxcontrol.alwaysvisible = true;
  boxcontrol.orientation.w = 1;
  boxcontrol.orientation.x = 0;
  boxcontrol.orientation.y = 1;
  boxcontrol.orientation.z = 0; 
  boxcontrol.interactionmode = InteractiveMarkerControl::MOVEPLANE;
  boxcontrol.markers.pushback( boxmarker );
  // add the control to the interactive marker
  intmarker.controls.pushback( boxcontrol );
  // add the interactive marker to our collection &
  // tell the server to call processFeedback() when feedback arrives for it
  server.insert(intmarker);
  server.setCallback(intmarker.name, &processFeedback);
  server.setCallback(intmarker.name, &alignMarker, InteractiveMarkerFeedback::POSEUPDATE); 
 //Problem occurs on this line ^^^^^^^^^^^^^^
}
int main(int argc, char** argv){
  ros::init(argc, argv, "simplemarker");
  // create an interactive marker server on the topic namespace simplemarker
  interactivemarkers::InteractiveMarkerServer server("simplemarker");
  tf::Vector3 position;
  position = tf::Vector3(0,0,0);
  createCube(position, server);
  // 'commit' changes and send to all clients
  server.applyChanges();
  // start the ROS main loop
  ros::spin();
}
My problem occurs on the line
 server.setCallback(intmarker.name, &alignMarker, InteractiveMarkerFeedback::POSEUPDATE); 

The error message I get is:

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/melodic/include/ros/forwards.h:40,
                 from /opt/ros/melodic/include/ros/common.h:37,
                 from /opt/ros/melodic/include/ros/ros.h:43,
                 from /home/slanderkin/catkin_ws/src/pathfinding/src/stick_marker.cpp:1:
/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 (*)(const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&, interactive_markers::InteractiveMarkerServer&); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’:
/usr/include/boost/function/function_template.hpp:925:38:   required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (*)(const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&, interactive_markers::InteractiveMarkerServer&); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:716:7:   required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type) [with Functor = void (*)(const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&, interactive_markers::InteractiveMarkerServer&); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type = int]’
/usr/include/boost/function/function_template.hpp:1061:16:   required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type) [with Functor = void (*)(const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&, interactive_markers::InteractiveMarkerServer&); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&; typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type = int]’
/home/slanderkin/catkin_ws/src/pathfinding/src/stick_marker.cpp:79:91:   required from here
/usr/include/boost/function/function_template.hpp:118:11: error: too few arguments to function
           BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
           ^
pathfinding/CMakeFiles/stick_marker.dir/build.make:62: recipe for target 'pathfinding/CMakeFiles/stick_marker.dir/src/stick_marker.cpp.o' failed
make[2]: *** [pathfinding/CMakeFiles/stick_marker.dir/src/stick_marker.cpp.o] Error 1
CMakeFiles/Makefile2:3339: recipe for target 'pathfinding/CMakeFiles/stick_marker.dir/all' failed
make[1]: *** [pathfinding/CMakeFiles/stick_marker.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

I'm very new to ROS and only somewhat familiar with c++ so I apologize if this is a simple fix - I could not find a fix in the googling that I did.

Asked by Slanderkin on 2020-08-05 19:21:00 UTC

Comments

Answers