How to Pull Odometry Data from Robot using Rosbridge
This is currently the piece of code in my rosbridge file that is to subscribe to /odom on my robot:
listener_Odom = new ROSLIB.Topic ({
ros : ros,
name : '/odom',
messageType : 'nav_msgs/Odometry'
});
let odomPosition = {xPos : 0, yPos : 0};
listener_Odom.subscribe('/odom', function(message){
console.log(`Received message on ${listener_Odom.name} : ${message.pose}`);
let odomPosition = {
xPos : message.pose.pose.position.x,
yPos : message.pose.pose.position.y
};
updatePosition(odomPosition); //update position of tracker, ie. a canvas shape
});
The browser console does not even display my console.log message, neither do my xPos and yPos ever change after I launch the rosbridge websocket. Any observances on what I am doing wrong?
(The end goal is to make my JS canvas shape move in the same way as the robot being used.)
Asked by S K on 2019-07-29 15:51:45 UTC
Comments