rostopic echo /chatter doesnt work

asked 2018-07-25 08:01:30 -0500

elia gravatar image

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

edit retag flag offensive close merge delete

Comments

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...

marcoarruda gravatar image marcoarruda  ( 2018-07-27 09:23:35 -0500 )edit