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

Revision history [back]

click to hide/show revision 1
initial version

I'm posting an answer as I found how to modify the code to have it building and running to do what you want but I am not totally sure why there is an error in the first place.

The issue is with this function (I took the one for MD5Sum but it 's the same for DataType and Defintion too) :

        static const char* value(const MyVector3& m)
        {
            return MD5Sum<geometry_msgs::Vector3>::value(m);
        }

From Vector3.h, you can see the prototype of the function returned is :

 static const char* value(const ::geometry_msgs::Vector3_<ContainerAllocator>&) { return value(); }

What I understand is that the definition of this function forces you to specify the type signature but you can't actually use an argument.

Now if you simply comment your function I thought it would compile but when you do :

chatter_pub.publish(Variance);

It will call the function const char* ros::message_traits::md5sum(const M&), since you didn't specified the function for M = MyVector3 the compiler returns an error. So the work around is not to comment the function but simply change it to (again don't forget to do it for Definition and DataType too) :

     static const char* value(const MyVector3&)
    {
        return MD5Sum<geometry_msgs::Vector3>::value();
    }

NB : I'm not actually sure about the explanation of the error so if I am wrong or mistaken I would be pleased to be corrected.

I'm posting an answer as I found how to modify the code to have it building and running to do what you want but I am not totally sure why there is an error in the first place.

The issue is with this function (I took the one for MD5Sum but it 's the same for DataType and Defintion too) :

 static const char* value(const MyVector3& m)
 {
     return MD5Sum<geometry_msgs::Vector3>::value(m);
 }

From Vector3.h, you can see the prototype of the function returned is :

 static const char* value(const ::geometry_msgs::Vector3_<ContainerAllocator>&) { return value(); }

What I understand is that the definition of this function forces you to specify the type signature but you can't actually use an argument.

Now if you simply comment your function I thought it would compile but when you do :

chatter_pub.publish(Variance);

It will call the function const char* ros::message_traits::md5sum(const M&), since you didn't specified the function for M = MyVector3 the compiler returns an error. So the work around is not to comment the function but simply change it to (again don't forget to do it for Definition and DataType too) :

 static const char* value(const MyVector3&)
 {
     return MD5Sum<geometry_msgs::Vector3>::value();
 }

NB : I'm not actually sure about the explanation of the error so if I am wrong or mistaken I would be pleased to be corrected.