Ask Your Question
0

[roslibjs,rosbridgesuite] How to get data back from the robot in turtleSim

asked 2016-11-17 18:29:20 -0500

nerdyTurtle gravatar image

updated 2016-11-18 00:38:00 -0500

gvdhoorn gravatar image

According to the roslibjs documentation, we should be able to get the data back from the robot by using a listener:

// Publish the Topic
var cmdVel = new ROSLIB.Topic({
    ros: ros,
    name: '/turtle1/cmd_vel',
    messageType: 'geometry_msgs/Twist'
});

// Subscribe to the Topic
var listener = new ROSLIB.Topic({
    ros: ros,
    name: '/listener',
    messageType: 'std_msgs/String'
});

listener.subscribe(function (message) {
    console.log("Recieved Message on: " + listener.name + ": " + message.data);
});

However, when I tried to use this, there was a compilation error that said property 'data does not exist on type 'message'.

I really need to get the turtle-robot data back to my web browser, any help with this matter would be highly appreciated.

Many thanks!

edit retag flag offensive close merge delete

Comments

1

Could you please use the Preformatted Text button next time when copy-pasting console text, source code, etc? It's the one with 101010 on it. That will make things much easier to read.

Thanks.

gvdhoorn gravatar imagegvdhoorn ( 2016-11-18 00:38:43 -0500 )edit

@gvdhoorn will do!

nerdyTurtle gravatar imagenerdyTurtle ( 2016-11-28 11:21:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-11-29 08:53:28 -0500

nerdyTurtle gravatar image

I was using Typescript, so I had to do add the following to the Typings file:

data:{
    ros: Ros,
    name: string,
    serviceType: string
}
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

1 follower

Stats

Asked: 2016-11-17 18:29:20 -0500

Seen: 195 times

Last updated: Nov 29 '16