rostopic echo /chatter doesnt work
I created a message file and tried to publish it by the publisher file and also i created a subscriber in another file to get it.
the sum.msg is located in msg folder and looks like this: i
int32 a
int32 b
the publisher file is like this :
pub = rospy.Publisher('chatter', sum, queue_size=10)
msg = sum()
msg.a= 1
msg.b= 2
rospy.loginfo(msg)
pub.publish(msg)
time.sleep(5)
rospy.spin()
and the subscriber is like this:
def callback(data):
print (" i'm in callback!")
global a
global b
a=data.a
b=data.b
ros_info("a: %d, b: %d",a,b)
.
.
.
def main():
rospy.Subscriber("chatter", sum, callback)
rospy.spin()
also i added the sum.msg file to my CMakelist.txt file.
but the problem is that when i run rostopic echo /chatter
i get this error:
[WARN] [WallTime: 1532522302.936274] Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
So can anyone help me to fix it ..
I'm using ubuntu 14.04 and ros indigo and used python
I believe the problem is that you are trying to publish just once in your publisher node. Take a look at this question: https://answers.ros.org/question/2671...