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.
Originally posted by teddybouch on ROS Answers with karma: 320 on 2012-08-16
Post score: 2
Original comments
Comment by teddybouch on 2012-08-16:
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.
Comment by joq on 2012-08-16:
You gotta love those opaque C++ error messages. Don't feel bad. You should post that comment as an answer (below).