error getMD5Sum in customized message type
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: https://imgur.com/a/E48bRef
Edit: Here is everything in text:
Cmake.txt:
cmake_minimum_required(VERSION 2.8.3)
project(hola)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
message_generation
)
add_message_files(
FILES
ParsedPointCloud.msg
)
generate_messages(
DEPENDENCIES
sensor_msgs
std_msgs
)
catkin_package(
INCLUDE_DIRS include/${PROJECT_NAME}/
CATKIN_DEPENDS roscpp sensor_msgs message_runtime std_msgs
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
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{
public:
std::vector<float> dist;
std::vector<float> angle;
};
}
ParsedPointCloud.msg in msg directory:
float32[] dist
float32[] angle
Package.xml:
<?xml version="1.0"?>
<package format="2">
<name>hola</name>
<version>0.0.0</version>
<description>The hola package</description>
<maintainer email="richard@todo.todo">richard</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>message_runtime</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
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){
pc.dist.resize(1081);
pc.angle.resize(1081);
ros::init(argc,argv,"getdata");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("scan",1000,&parsefunc);
ros::Publisher pub = nh.advertise<hola::PPC>("parsedPC",1000);
while(ros::ok()){
ros::spinOnce();
pub.publish(pc);
}
}
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 ...
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.
I still need help on this if anyone can kindly do so. Thank in advance.