Robotics StackExchange | Archived questions

How to use MarkerArrayClient in ros3djs

I am trying to display "/trajectorynodelist" on a web application using ros3djs, but nothing is displayed, I want to display some lines like in rviz or webviz. Can someone give me an example how to use MarkerArrayClient in ros3djs?

Asked by chi0225 on 2020-07-27 08:06:12 UTC

Comments

Never did that but generally ros3djs seems quite easy when you get used to read the main file.

Let's gonna a try something. Based on https://wiki.ros.org/ros3djs/Tutorials/VisualizingAMarkerTopic :

Do exactly the same, but instead of

var markerClient = new ROS3D.MarkerClient({
  ros : ros,
  tfClient : tfClient,
  topic : '/visualization_marker',
  rootObject : viewer.scene
});

Do:

var markerArrayClient = new ROS3D.MarkerArrayClient({
  ros : ros,
  tfClient : tfClient,
  topicName : '/you_r_name_topic', //check the difference here. instead of topic, topicName
  rootObject : viewer.scene
});

if you want to add an specific mesh:

var markerArrayClient = new ROS3D.MarkerArrayClient({
  ros : ros,
  tfClient : tfClient,
  topicName : '/you_r_name_topic', 
  rootObject : viewer.scene,
  path: 'path_to_mesh'
});

Asked by Solrac3589 on 2020-07-28 06:01:49 UTC

Hi @Solrac3589 I did exactly the same, the line is not displayed on the viewer

  this.tfClient = this._ros.TFClicent({
  angularThres: 0.01,
  transThres: 0.01,
  rate: 5.0,
  fixedFrame: "/base_link",
});

this.markerArrayClient = new ROS3D.MarkerArrayClient({
  ros: this._ros.ros,
  rootObject: this.viewer.scene,
  tfClient: this.tfClient,
  topic: "/trajectory_node_list",
});

Asked by chi0225 on 2020-07-28 21:10:04 UTC

Can you tell me is there is any debug information in the browser?

Asked by Solrac3589 on 2020-07-29 04:51:27 UTC

No errors show up in the console, but there's an adjustment in the marker, I just changed the size property to lineWidth to adjust the THREE library, and the sceneNode showed it has children [Marker] which has children [Line], the geometry is correct, have no idea why the viewer didn't display them. This topic is working on Webviz, but it is not working in ros3djs.

Asked by chi0225 on 2020-07-29 05:04:26 UTC

Just to be sure. Did you checked in the browser? (not the terminal).

Sometimes my urdf problem not being show was caused by localhost in

var ros = new ROSLIB.Ros({
  url : 'ws://localhost:9090'
});

just try to change localhost by your IP (yes, it does not make sense, but sometimes worked for me).

Asked by Solrac3589 on 2020-07-29 06:15:29 UTC

The websocket is fine, I can see ros3djs generated the markers using the topic, but there's no markers and lines displayed on the viewer. If the websocket url is wrong or not connected, it will print an error message in the console

Asked by chi0225 on 2020-07-29 06:23:09 UTC

No idea then, sorry :(

Asked by Solrac3589 on 2020-07-29 07:34:58 UTC

No worries, thanks for helping

Asked by chi0225 on 2020-07-29 20:48:25 UTC

Answers