Ask Your Question
1

roslibjs MultiArray Message

asked 2015-05-14 14:04:49 -0500

aak2166 gravatar image

Hi all,

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

std_msgs/Int32MultiArray

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?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-30 04:39:11 -0500

Rahndall gravatar image

updated 2016-08-30 05:30:39 -0500

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'
          });

pose_array_topic.publish(pose_array);
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-05-14 14:04:49 -0500

Seen: 971 times

Last updated: Aug 30 '16