ros3djs
ros3djs copied to clipboard
Laser scan visualization with wrong tf
Hi guys,
I try to visualize laser scan data on my web interface using Turtlebot3 simulations packages. But it seemed like I got wrong displaying laser tf (figure attached below). I created a tfClient with fixed frame is /odom that subscribes from /base_scan frame of the Turtlebot3. I can make sure that I ran the tf2_web_republisher node. I still stuck here so I need helps from you guys. Please tell me where I did wrong? Thank you guys alot.
Here is my following code: ` // VISUALIZE LASER SCAN var laser_listener = new window.ROSLIB.Topic({ ros: this.state.ros, name: '/scan', messageType: 'sensor_msgs/LaserScan', //throttle_rate: 100 });
var tfClient = new window.ROSLIB.TFClient({
ros: this.state.ros,
fixedFrame : 'odom',
angularThres : 0.01,
transThres : 0.01
});
var lasertf = { x: 0, y: 0, rotation: 0 };
tfClient.subscribe('base_scan', function(tf) {
lasertf.x = tf.translation.x;
lasertf.y = tf.translation.y;
lasertf.rotation = viewer.scene.rosQuaternionToGlobalTheta(tf.rotation);
});
var maptf = { x: 0, y: 0, rotation: 0 };
tfClient.subscribe('map', function(tf) {
maptf.x = tf.translation.x;
maptf.y = tf.translation.y;
maptf.rotation = viewer.scene.rosQuaternionToGlobalTheta(tf.rotation);
});
var laserDisplay = new ROS2D.LaserDraw({
pointColor: 'green'
});
var delayTime = 0;
laser_listener.subscribe(function(msg) {
delayTime++;
if (delayTime < 1) { return };
delayTime = 0;
laserDisplay.setScanMsg(msg);
laserDisplay.rotation = lasertf.rotation;
laserDisplay.x = lasertf.x;
laserDisplay.y = -lasertf.y;
});
viewer.scene.addChild(laserDisplay);`
I think this applies to ROS2D, not ROS3D.
I am not that familiar with these classes yet. So I can't help you right away. Please check the documentation first.
Also to be sure. Does it show correctly in rviz?
Stale