Rosanswers logo

Hi all,

I am trying to create a web interface for a robot, and would like to publish a message of type:


Thus in my code I have the following statement to create the message:

var msg = new ROSLIB.Message({
  data : [1 , 2, 3]

However, when I attempt to publish that in my browser I see a Javascript error of type 'cannot read property of undefined.'

I suspect it has to do with the way I am trying to set the message data, but cannot find an example of the proper way to do so. Has anyone had any luck with this?


Originally posted by aak2166 on ROS Answers with karma: 593 on 2015-05-14

Post score: 1


1 Answer 1


Rosanswers logo

Dear aak2166, I used roslibjs for publishing a geometry_msgs/PoseArray and it seems to work

This the code used:

var pose = new ROSLIB.Message({
                    position : {
                      x : 0.1,
                      y : 0.2,
                      z : 0.2
                    orientation : {
                      x : 0.0,
                      y : 0.0,
                      z : 0.0,
                      w : 1.0
var pose_array = new ROSLIB.Message({
            poses : [pose, pose]    

var pose_array_topic = new ROSLIB.Topic({
        ros : ros,
        name : '/test_pose_array',
        messageType : 'geometry_msgs/PoseArray'


Originally posted by Rahndall with karma: 133 on 2016-08-30

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.