How to display a marker sequence in ros3djs when each are defined in the base_link frame?
I publish markers at the origin of the robot base_link
frame regularly. In RViz
, a marker is therefore plotted wherever the robot is located at the time it is created, building up a sequence of markers along the robots trajectory. I achieve this by setting frame_locked = False
in the marker definition. Performance is really good with no lag observed and all of these markers persist on screen for visualisation (due to frame_locked = False
) as shown in the screenshot below.
I am trying to implement this same visualisation in a web browser using ros3djs
with the following code but it does not appear to recognise the frame_locked = False
marker option.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://static.robotwebtools.org/threejs/current/three.min.js"></script>
<script type="text/javascript" src="http://static.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script type="text/javascript" src="http://static.robotwebtools.org/roslibjs/current/roslib.min.js"></script>
<script type="text/javascript" src="http://static.robotwebtools.org/ros3djs/current/ros3d.min.js"></script>
<script type="text/javascript" type="text/javascript">
/**
* Setup all visualization elements when the page is loaded.
*/
function init() {
// Connect to ROS.
var ros = new ROSLIB.Ros({
url : 'ws://localhost:9090'
});
// Create the main viewer.
var viewer = new ROS3D.Viewer({
divID : 'markers',
width : 800,
height : 600,
antialias : true
});
// Setup a client to listen to TFs.
var tfClient = new ROSLIB.TFClient({
ros : ros,
angularThres : 0.01,
transThres : 0.01,
rate : 10.0,
fixedFrame : '/map'
});
// Setup the marker client.
var markerClient = new ROS3D.MarkerClient({
ros : ros,
tfClient : tfClient,
topic : '/my_marker',
rootObject : viewer.scene
});
}
</script>
</head>
<body onload="init()">
<h1>Simple Marker Example</h1>
<div id="markers"></div>
</body>
</html>
The problem with this code is that it displays each marker wherever the base_link
is positioned in the map
frame but does not leave the same sequence of markers for visualisation as my RViz
example does.
Maybe this is expected because each marker has the same pose with respect to the base_link
frame, which moves with the robot as it is operates. Does this suggest that RViz
is somehow able to relate/transform these marker poses in the base_link
frame to the map
frame? If so, how might I properly set this up in the above code? Or maybe there is a simpler ros3djs
setting I can use to make the markers persist on screen and respect the frame_locked = False
option?