ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Invalid Initialization of Parameter Adapter? [closed]

asked 2012-08-16 04:00:05 -0500

teddybouch gravatar image

updated 2012-08-16 04:45:16 -0500

As an exercise to familiarize myself with ROS, I'm writing what is basically a waypoint driver for the turtlesim. The file that is now giving me trouble compiling is supposed to get waypoints using a service from a separate waypoint server, then use that to navigate the turtle using the Pose and Velocity publish/subscribe interfaces. The service has been tested and works, but it looks like something that I've implemented with regard to the Pose interface is not happy. The error that I'm getting is:

In file included from /opt/ros/fuerte/include/ros/subscription_callback_helper.h:35:0,                                                                                                                                                       
                 from /opt/ros/fuerte/include/ros/subscriber.h:33,
                 from /opt/ros/fuerte/include/ros/node_handle.h:33,
                 from /opt/ros/fuerte/include/ros/ros.h:45,
                 from /home/abouchard/ros_workspace/waypoint_follower/src/wp_driver.cpp:1:
/opt/ros/fuerte/include/ros/parameter_adapter.h: In static member function ‘static ros::ParameterAdapter<M>::Parameter ros::ParameterAdapter<M>::getParameter(const Event&) [with M = turtlesim::Pose_<std::allocator<void> >&, ros::ParameterAdapter<M>::Parameter = turtlesim::Pose_<std::allocator<void> >&, ros::ParameterAdapter<M>::Event = ros::MessageEvent<const turtlesim::Pose_<std::allocator<void> > >, typename boost::remove_reference<typename boost::remove_const<M>::type>::type = turtlesim::Pose_<std::allocator<void> >]’:
/opt/ros/fuerte/include/ros/subscription_callback_helper.h:180:5:   instantiated from ‘void ros::SubscriptionCallbackHelperT<P, Enabled>::call(ros::SubscriptionCallbackHelperCallParams&) [with P = turtlesim::Pose_<std::allocator<void> >&, Enabled = void]’
/home/abouchard/ros_workspace/waypoint_follower/src/wp_driver.cpp:133:1:   instantiated from here
/opt/ros/fuerte/include/ros/parameter_adapter.h:78:30: error: invalid initialization of reference of type ‘ros::ParameterAdapter<turtlesim::Pose_<std::allocator<void> >&>::Parameter {aka turtlesim::Pose_<std::allocator<void> >&}’ from expression of type ‘const turtlesim::Pose_<std::allocator<void> >’
/opt/ros/fuerte/include/ros/parameter_adapter.h:79:3: warning: control reaches end of non-void function [-Wreturn-type]

It looks like the invalid initialization is the problem, but the line called out is the last one in the program and only contains a close bracket.

I'm running openSUSE 12.1, and I have all my dependencies and everything else from the troubleshooting checklist squared away. I think that I set the ROS_BOOST_PATH variable correctly as well, but honestly I couldn't find good instructions for that, so I could be wrong. I'm happy to share my code, but it might be a lot for this format, so here is the line where I declare the subscriber;

ros::Subscriber sub = n.subscribe("pose", 1, updatePose);

and the related callback function:

void updatePose(turtlesim::Pose &msg)
{
    veh_x = msg.x;
    veh_y = msg.y;
    theta = msg.theta;
    cout << "Updated position: (" << veh_x << "," << veh_y <<") at heading " << theta << endl;
}

I went through all the tutorials without a problem, so I know that my system configuration will support a subscriber node. Any help would be greatly appreciated.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by teddybouch
close date 2013-07-10 06:01:22

Comments

2

Boy, do I feel like an idiot. Well, in case there are more of me out there: your callback has to accept its input as a const. I had deleted it because I was having trouble with the function before and never put it back in.

teddybouch gravatar image teddybouch  ( 2012-08-16 04:48:15 -0500 )edit

You gotta love those opaque C++ error messages. Don't feel bad. You should post that comment as an answer (below).

joq gravatar image joq  ( 2012-08-16 04:53:39 -0500 )edit

1 Answer

Sort by » oldest newest most voted
7

answered 2012-09-17 06:02:57 -0500

teddybouch gravatar image

Boy, do I feel like an idiot. Well, in case there are more of me out there: your callback has to accept its input as a const. I had deleted it because I was having trouble with the function before and never put it back in.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-16 04:00:05 -0500

Seen: 999 times

Last updated: Sep 17 '12