Ask Your Question

error getMD5Sum in customized message type

asked 2019-10-22 02:18:59 -0600

richardz03 gravatar image

updated 2019-10-24 18:03:56 -0600

Hi everyone, I am a newbie trying to create a customized message type but it always ends up with this error. I will appreciate greatly if someone can help out. I spent hours on this and don't know where is the error.

error msg is at the end.

Photos of my simple files are posted in this link:

Edit: Here is everything in text:


cmake_minimum_required(VERSION 2.8.3)
find_package(catkin REQUIRED COMPONENTS



CATKIN_DEPENDS roscpp sensor_msgs message_runtime std_msgs


add_executable(hola src/getdata.cpp)
target_link_libraries(hola ${catkin_LIBRARIES})

my header file in hola/include/ParsedPointCloud.h:

#include <vector>

namespace hola{

    class PPC{
        std::vector<float> dist;
        std::vector<float> angle;

ParsedPointCloud.msg in msg directory:

float32[] dist  
float32[] angle


<?xml version="1.0"?>
<package format="2">
  <description>The hola package</description>
  <maintainer email="richard@todo.todo">richard</maintainer>


  <!-- The export tag contains other, unspecified, tags -->
    <!-- Other tools can request additional information be placed here -->


Finally my code:

 #include <ros/ros.h> 
  #include <vector>
  #include <sensor_msgs/LaserScan.h>
  #include <hola/ParsedPointCloud.h>

  hola::PPC pc; 

  void parsefunc(const sensor_msgs::LaserScan &msg){
    float min = msg.range_min;
    float max = msg.range_max;

    for(int i = 0; i < 1081; i++){ //270*4+1 = 1081  #points on one plane.

        //limiting measurement to range_min and range_max
        float tempdist = min;
        if(msg.ranges[4*i] > max) tempdist = max;
        else if(msg.ranges[4*i] < max && msg.ranges[4*i] > min) tempdist = msg.ranges[4*i];

        pc.dist[i] = tempdist;
        pc.angle[i] = -135+(i*0.25);

  int main(int argc, char **argv){


    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("scan",1000,&parsefunc);
    ros::Publisher pub = nh.advertise<hola::PPC>("parsedPC",1000);  


Error message:

In file included from /opt/ros/melodic/include/ros/serialization.h:37:0,
                 from /opt/ros/melodic/include/ros/publisher.h:34,
                 from /opt/ros/melodic/include/ros/node_handle.h:32,
                 from /opt/ros/melodic/include/ros/ros.h:45,
                 from /home/richard/new_ws/src/hola/src/getdata.cpp:1:
/opt/ros/melodic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = hola::PPC]’:
/opt/ros/melodic/include/ros/message_traits.h:255:102:   required from ‘const char* ros::message_traits::md5sum(const M&) [with M = hola::PPC]’
/opt/ros/melodic/include/ros/publisher.h:112:7:   required from ‘void ros::Publisher::publish(const M&) const [with M = hola::PPC]’
/home/richard/new_ws/src/hola/src/getdata.cpp:36 ...
edit retag flag offensive close merge delete


Photos of my simple files are posted in this link: ...

please just copy-paste all that text into your question. Terminals contain text, just as text editors do. You should be able to copy-paste it into your question.

gvdhoorn gravatar imagegvdhoorn ( 2019-10-22 02:22:50 -0600 )edit

I still need help on this if anyone can kindly do so. Thank in advance.

richardz03 gravatar imagerichardz03 ( 2019-10-22 18:11:26 -0600 )edit

2 Answers

Sort by » oldest newest most voted

answered 2019-10-26 03:11:31 -0600

richardz03 gravatar image

updated 2019-10-26 04:36:21 -0600

gvdhoorn gravatar image

Okay I finally found the solution to generate .h files.

In my Cmakelist.txt file,

#INCLUDE_DIRS include 
#DEPENDS system_lib

If I uncomment #INCLUDE_DIRS include, then I have to create a folder called "include" in my src/pkg_name. Once I did that, you could compile it but the header file still wouldnt appear there. Apparently, it is built inside devel/include/hola. (I didnt know that) So I just left the INCLUDE_DIRS include part commented.

To compile it, I had to do #include <hola/ParsedPointCloud.h> and instantiate it with hola::ParsedPointCloud obj1; to be able to use it.

Thank you gvdhoorn for letting me know that these header files are generated and shouldn't be created by the user.

edit flag offensive delete link more


I'm glad you figured things out.

Just to point out this is actually described and documented: see the first few lines of Creating a ROS msg and srv:

1.1 Introduction to msg and srv

  • msg: msg files are simple text files that describe the fields of a ROS message. They are used to generate source code for messages in different languages.

it then goes on to explain how to create .msg files, how to update your CMakeLists.txt and package.xml and finally in the next tutorial shows you how to #include the generated headers in your nodes.

gvdhoorn gravatar imagegvdhoorn ( 2019-10-26 04:39:31 -0600 )edit

answered 2019-10-22 04:13:53 -0600

I wondered that the class file is duplicated the name of this custom message you've created in msg folder ?

Because after the message generation is complete you also have the hola::ParsePointCloud as well as the file in screenshot which is duplicate ._.'

try to Rename the class in the screenshot , clean and rebuild the workspace and then try again

edit flag offensive delete link more


hi c3mx thanks for responding! Aren't we suppose to name the header file the same as the name of this custom message? I will try changing the class name different from the header file name then. edit: well I tried giving another class name it still give the same error

richardz03 gravatar imagerichardz03 ( 2019-10-22 10:02:36 -0600 )edit

It's very likely that @C3MX is correct: because you've used identical names for your .msg and your class, the compiler tries to use your class (instead of the message) as the message type. That isn't going to work.

You have two options (among many others):

  1. place your class in a namespace
  2. rename either your class or your .msg file

Aren't we suppose to name the header file the same as the name of this custom message?

The name of the generated class for your custom message will be taken from the name of the .msg file. You don't name C++ message types yourself.

But what you probably shouldn't do is create a C++ class with the same name as the (eventual) message C++ class. That will cause collisions.

gvdhoorn gravatar imagegvdhoorn ( 2019-10-23 02:43:35 -0600 )edit

Hi gvdhoorn, I have changed the name of my class to PPC and the same error occurs. Please see my edited post for the new changes I did. In short I edited class name to PPC and made related changes in .cpp

richardz03 gravatar imagerichardz03 ( 2019-10-24 17:30:34 -0600 )edit

Not sure if this would be the problem, but why do you call header files generated files? I notice it in ros message tutorial as well. I created it myself but even if I delete the file, and build the package, it still doesnt automatically generate it. Not sure if I am missing a step that creates the header file on its own or what I did is right.

richardz03 gravatar imagerichardz03 ( 2019-10-24 18:07:20 -0600 )edit

but why do you call header files generated files?

because ROS messages (ie: .msg, .srv and .action) are not the code you include in your program. Those files get processed by the message_generation package (which ultimately uses gencpp, genpy and a set of other code generators to generate the actual.h and .py files that you do include in your program.

So if you create a .h that declares and defines an identical class (in an identical namespace), that will cause problems.

if I delete the file, and build the package, it still doesnt automatically generate it. Not sure if I am missing a step that creates the header file on its own or what I did is right.

it should be generated, so if that doesn't happen, something is not right.

Can you remove your own header, remove your build and devel (and potentially the install) folders from ...(more)

gvdhoorn gravatar imagegvdhoorn ( 2019-10-25 03:32:35 -0600 )edit

Hi gvdhoorn, thanks for everything I finally solved the problem but hopefully you can help me with this last question I have. I usually see header files being generated on include/pkg_name/ inside the package folder, no inside devel/include/pkg_name/. For some reason mine does the latter. Is this normal?

richardz03 gravatar imagerichardz03 ( 2019-10-26 03:22:53 -0600 )edit

I usually see header files being generated on include/pkg_name/ inside the package folder,

I would be very surprised if that happens. If "inside the package folder" actually means "inside the src/<package> folder that is.

The source space is essentially read-only during the build phase, so headers must not be generated there.

gvdhoorn gravatar imagegvdhoorn ( 2019-10-26 04:41:53 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-10-22 02:18:59 -0600

Seen: 37 times

Last updated: Oct 26