Why I got error "msg does not have header"?
Hi,
I try to make a custom message with header to get the timestamp because my aim is to receive data from two topics and generate a graph. After some reading, I found that I need to synchronise the topics and take both topics into a single callback. So I use rostopic delay to check the header of my rostopic. I can get the header from the first custom but no this message.
This is the error:
[ERROR] [1560803887.275108]: msg does not have header
Here are my custom message:
Header header
float32[] distance
Here is my publisher that use the custom message:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Int32
def distanceTrav():
pub = rospy.Publisher('distanceTurtleTravelled', Int32, queue_size=1000)
rospy.init_node('distanceTurtle', anonymous=True)
rate = rospy.Rate(1) # 1hz
dist = 1
while not rospy.is_shutdown():
rospy.loginfo(dist)
pub.publish(dist)
rate.sleep()
dist = dist+1
if __name__ == '__main__':
try:
distanceTrav()
except rospy.ROSInterruptException:
pass
Here is my CMakelist:
cmake_minimum_required(VERSION 2.8.3)
project(walabot)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
geometry_msgs
message_generation
)
add_message_files(
FILES
signal.msg
distanceTravelled.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
LIBRARIES walabot
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
)
include_directories(
${catkin_INCLUDE_DIRS}
)
In the future, please remove any unnecessary comments to make your question easier to read. I've done that for you here
Is this publisher the only node that you're running? I don't see that error when I run it. Also, you posted a custom message, but you're not using it
ah my bad, thank you for pointing that out
Please give all the commands and nodes you run to produce that error output.
If you are trying to synchronise an
Int32
message, then it won't work. The std_msgs/Int32 message does not have a header. What messages are you trying to synchronise?