I created a Chatter.msg, how do I refer to it in roslibjs?

asked 2016-11-29 10:29:11 -0500

nerdyTurtle gravatar image

updated 2016-11-29 11:02:47 -0500


Here's my Chatter.msg:

string message
int32 a
int32 b

Here's my javascript code:

var msgTopic = new ROSLIB.Topic({
    ros: ros,
    name: 'chatter',
    messageType: 'beginner_tutorials/Chatter'

var msg = new ROSLIB.Message({
            message: 'hello',
            a: 3,
            b: 2

The Chatter.Msg is in my catkin workspace directory. Here's the python code:

import rospy
from beginner_tutorials.msg import Chatter

def callback(msg):
    rospy.loginfo("%s has a:  %d" % (msg.message, msg.a))
    rospy.loginfo("%s has b:  %d" % (msg.message, msg.b))

def listener():
    rospy.init_node('chatter_listener', anonymous = True)
    rospy.Subscriber("chatter", Chatter, callback)

I can't get anything to publish in the terminal, using the above python code and javascript code. Am I missing something? Do I need to refer to the Chatter.msg in Javascript somehow?

I would appreciate any help with this. Thank you!

edit retag flag offensive close merge delete