-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Description
Can someone point me to an example to display the current robot position on top of the viewer?
I used the example/continuous.html and add the listener to listen to /cmd_vel, but i am not sure how to draw the robot position on top of the viewer.
var ros = new ROSLIB.Ros({
url : 'ws://<ip_address>:9090'
});
// Create the main viewer.
var viewer = new ROS2D.Viewer({
divID : 'map',
width : 800,
height : 550
});
// Setup the map client.
var gridClient = new ROS2D.OccupancyGridClient({
ros : ros,
rootObject : viewer.scene,
// Use this property in case of continuous updates
continuous: true
});
let startTime ;
// Scale the canvas to fit to the map
gridClient.on('change', function() {
startTime = new Date()
viewer.scaleToDimensions(gridClient.currentGrid.width, gridClient.currentGrid.height);
viewer.shift(gridClient.currentGrid.pose.position.x, gridClient.currentGrid.pose.position.y);
});
var vel_listener = new ROSLIB.Topic({
ros: ros,
name: '/cmd_vel',
messageType: 'geometry_msgs/Twist'
})
vel_listener.subscribe(function(vel){
let endTime = new Date();
let dt = (endTime - startTime) / 5000;
let vx = vel.linear.x;
let az = vel.angular.z;
//how to add the robot position marker on the viewer?
});
nakai-omer
Metadata
Metadata
Assignees
Labels
No labels