How to use MarkerArrayClient in ros3djs

asked 2020-07-27 08:06:12 -0500

chi0225 gravatar image

updated 2022-03-04 06:57:33 -0500

lucasw gravatar image

I am trying to display "/trajectory_node_list" 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?

edit retag flag offensive close merge delete

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/Tutorial... :

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'
});
Solrac3589 gravatar image Solrac3589  ( 2020-07-28 06:01:49 -0500 )edit

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",
});
chi0225 gravatar image chi0225  ( 2020-07-28 21:10:04 -0500 )edit

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

Solrac3589 gravatar image Solrac3589  ( 2020-07-29 04:51:27 -0500 )edit

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.

chi0225 gravatar image chi0225  ( 2020-07-29 05:04:26 -0500 )edit

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).

Solrac3589 gravatar image Solrac3589  ( 2020-07-29 06:15:29 -0500 )edit

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

chi0225 gravatar image chi0225  ( 2020-07-29 06:23:09 -0500 )edit

No idea then, sorry :(

Solrac3589 gravatar image Solrac3589  ( 2020-07-29 07:34:58 -0500 )edit

No worries, thanks for helping

chi0225 gravatar image chi0225  ( 2020-07-29 20:48:25 -0500 )edit