Cannot build simple service on Melodic (getServerMD5Sum is not a member of std_msgs::Float32)
I'm having problems compiling a simple ROS service. I'm using a fresh install of Ubuntu 18.04.3 - ROS Melodic. Ive simplified down the project as much as I can to replicate the problem.
My project structure is as follows
src/
control_bridge/
src/
control_service.cpp
srv/
set_demand.srv
CMakeLists.txt
package.xml
My file content is as follows:
control_service.cpp:
#include "ros/ros.h"
#include "std_msgs/Float32.h"
bool set_demand(std_msgs::Float32 &request,std_msgs::Float32 &response)
{
return true;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "control_service");
ros::NodeHandle nh;
ros::ServiceServer service;
service = nh.advertiseService("set_demand",set_demand);
ros::spin();
return 0;
}
set_demand.srv
float32 request
---
float32 response
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(control_bridge)
find_package(catkin REQUIRED COMPONENTS
roscpp
genmsg
std_msgs
)
## Generate services in the 'srv' folder
add_service_files(
FILES
set_demand.srv
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs # Or other packages containing msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES control_bridge
CATKIN_DEPENDS roscpp std_msgs message_runtime
# DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
add_executable(ControlService src/control_service.cpp)
add_dependencies(ControlService control_bridge_generate_messages_cpp)
## Specify libraries to link a library or executable target against
target_link_libraries(ControlService
${catkin_LIBRARIES}
)
package.xml
<?xml version="1.0"?>
<package format="2">
<name>control_bridge</name>
<version>0.1.0</version>
<description>The control_bridge package</description>
<maintainer email="steve@todo.todo">steve</maintainer>
<license>Apache 2.0</license>
<build_depend>message_generation</build_depend>
<build_export_depend>message_generation</build_export_depend>
<exec_depend>message_runtime</exec_depend>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<exec_depend>std_msgs</exec_depend>
<build_export_depend>roscpp</build_export_depend>
<exec_depend>roscpp</exec_depend>
<export>
</export>
</package>
When running catkin_make I get the following error:
[ 88%] Building CXX object control_bridge/CMakeFiles/ControlService.dir/src/control_service.cpp.o
[ 88%] Built target control_bridge_generate_messages
In file included from /opt/ros/melodic/include/ros/service_client.h:33:0,
from /opt/ros/melodic/include/ros/node_handle.h:35,
from /opt/ros/melodic/include/ros/ros.h:45,
from /home/steve/track-o-motor-controller/track-o_ros_bridge/src/control_bridge/src/control_service.cpp:1:
/opt/ros/melodic/include/ros/service_traits.h: In instantiation of ‘static const char* ros::service_traits::MD5Sum<M>::value() [with M = std_msgs::Float32_<std::allocator<void> >]’:
/opt/ros/melodic/include/ros/service_traits.h:79:102: required from ‘const char* ros::service_traits::md5sum() [with M = std_msgs::Float32_<std::allocator<void> >]’
/opt/ros/melodic/include/ros/advertise_service_options.h:60:25: required from ‘void ros::AdvertiseServiceOptions::init(const string&, const boost::function<bool(MReq&, MRes&)>&) [with MReq = std_msgs::Float32_<std::allocator<void> >; MRes = std_msgs::Float32_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/opt/ros/melodic/include/ros/node_handle.h:1064:5: required from ‘ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (*)(MReq&, MRes&)) [with MReq = std_msgs::Float32_<std::allocator<void> >; MRes = std_msgs::Float32_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/steve/track-o-motor-controller/track-o_ros_bridge/src/control_bridge/src/control_service.cpp:16:56: required from here
/opt/ros/melodic/include/ros/service_traits.h:47:34: error: ‘__s_getServerMD5Sum’ is not a member of ‘std_msgs::Float32_<std::allocator<void> >’
return M::__s_getServerMD5Sum().c_str();
~~~~~~~~~~~~~~~~~~~~~~^~
/opt/ros/melodic/include/ros/service_traits.h: In instantiation of ‘static const char* ros::service_traits::DataType<M>::value() [with M = std_msgs::Float32_<std::allocator<void> >]’:
/opt/ros/melodic ...