On ros3djs, how can I stop markers dispearing?
I publish markers onto a web GUI using the code below. I'd like all markers to remain on the viewer but it seems that my code only displays the latest marker rather than the latest marker as well as all markers that have been published before it. Note that the markers are defined with the default lifetime parameter of 0 meaning that they should exist forever (this works well when viewing on RViz
) even though they disappear when viewing the on a web browser using the code below.
Any ideas how to make the markers persist?
new Vue({
el: '#vueApp',
data: {
ros: null,
connected: false,
pubInterval: null
},
methods: {
init: function () {
// ROSBridge Connection Object
this.ros = new ROSLIB.Ros({
url: 'ws://' + window.location.hostname + ':9090'
})
// ROSBridge Connection Object Callbacks
this.ros.on('connection', () => {
this.connected = true
console.log('Connection to ROSBridge established')
this.pubInterval = setInterval(this.publish, 100)
})
this.ros.on('error', (error) => {
console.log('Something went wrong when trying to connect')
console.log(error)
})
this.ros.on('close', () => {
this.connected = false
console.log('Connection to ROSBridge was closed')
clearInterval(this.pubInterval)
})
// Visualisation
let viewer = new ROS3D.Viewer({
divID : 'map',
width : 600,
height : 400,
antialias : true,
});
// TF Client
let tfClient = new ROSLIB.TFClient({
ros : this.ros,
angularThres : 0.01,
transThres : 0.01,
rate : 10.0,
fixedFrame : '/map'
});
// Marker Data Acquisition
let markerClient = new ROS3D.MarkerClient({
ros : this.ros,
tfClient : tfClient,
topic : '/visualization_marker',
rootObject : viewer.scene
});
}
}
})
I think the problem is that marker client is exclusive to only one marker.. If you want several markers you should do more than one markerclient or a MarkerArrayClient.
I do no0t know why, but i think a good good idea for your case should be to create a topic which send info when a new marker is created (backend) and then, put a subscriber in your js code. Inside a subscriver, generate a new marker client.
Dunno, worked on that few years ago so I am not quite sure which should be the optimal way to work on it.
I've not got this to work but are you suggesting a function like this:
Anyone got any more ideas on this? I've posted this question to provide more info and try to get to the bottom of this.
I just made some adjustments and got the above code snippet to work so that whenever a new marker message is received a new marker client is created to visualise it. This produces the same results and does not solve the initial problem, i.e. needing to visualise the sequence of markers. Also, it seems that using the
MarkerArrayClient
also does not work given that all markers are the same pose in relation to thebase_link
frame. See here for more info.