RobotWebTools / ros3djs

3D Visualization Library for use with the ROS JavaScript Libraries
https://robotwebtools.github.io/ros3djs
Other
362 stars 215 forks source link

ros3djs is not loading my urdf. #231

Open msjulio00 opened 6 years ago

msjulio00 commented 6 years ago

Hello, I have a urdf file for an ABB Irb140 robot, I sucesfully displayed it using rviz but when I tried to follow the "Visualizing a URDF" tutorial ( http://wiki.ros.org/ros3djs/Tutorials... ) the html doesn't show anything. I have tried a lot of things reading a lot of answers about the issue but I can't get it work (I'm a newby in the topic).

The important parts of my urdf.html code are the headers, I don't know if I'm using them right, and the URDF client part:

script src="https://static.robotwebtools.org/threejs/current/three.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/STLLoader.js"></script>
<script src="https://static.robotwebtools.org/EventEmitter2/current/eventemitter2.js"></script>
<script src="https://static.robotwebtools.org/ros3djs/0.18.0/ColladaLoader.js"></script>
<script src="https://static.robotwebtools.org/ColladaAnimationCompress/current/ColladaLoader2.js"></script>
<script src="https://static.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="https://static.robotwebtools.org/ros3djs/current/ros3d.min.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/ColladaLoader.min.js"></script>
<script src="../build/roslib.js"></script>

var urdfClient = new ROS3D.UrdfClient({ 
     ros : ros, 
     tfClient : tfClient, 
     path : 'http://localhost:80/',
     rootObject : viewer.scene, 
     loader : ROS3D.COLLADA_LOADER
     });

I have tried using both the ROS3D.COLLADA_LOADER and ROS3D.COLLADA_LOADER_2.

I'm also using apache 2 and I have there the urdf.html and the meshes but the html code simply can't load them. In other hand I launch these files.

1.- roslaunch abb_irb140_support nodos.launch

<launch>
<arg name="KINECT1" default="$(optenv KINECT1 false)" />
<arg name="KINECT2" default="$(optenv KINECT2 false)" />

<group>
        <param name="robot_description" command="$(find xacro)/xacro '$(find abb_irb140_support)/urdf/irb140.urdf' --inorder KINECT1:=$(arg KINECT1) KINECT2:=$(arg KINECT2)" />
</group>
    <param name="use_gui" value="true" />
    <node name="robot_state_publiher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="joint_state_publiher" pkg="joint_state_publisher" type="joint_state_publisher" />   
    <node name="tf2_web_republiher"   pkg="tf2_web_republisher"   type="tf2_web_republisher" /> 
</launch>

2.-roslaunch rosbridge_server rosbridge_websocket.launch

Both of them work perfectly well and show the robot model in rviz. One thing that I don't know is if I need to launch the file from inside the apache server.

Inside the urdf file the filename is something like this:

"package://robot_description/meshes/irb140/visual/base_link.dae" The meshes are in /var/www/html/robot_description/meshes/irb140/visual/ and if I write http://localhost/robot_description/me... they can be accesed but again the files are not loaded in the html.

I hope someone could help me with this, I have been stucked with this problem several days now. Thank you I will appreciate any help.

tianyueping commented 5 years ago

Hello, I have a urdf file for an ABB Irb140 robot, I sucesfully displayed it using rviz but when I tried to follow the "Visualizing a URDF" tutorial ( http://wiki.ros.org/ros3djs/Tutorials... ) the html doesn't show anything. I have tried a lot of things reading a lot of answers about the issue but I can't get it work (I'm a newby in the topic).

The important parts of my urdf.html code are the headers, I don't know if I'm using them right, and the URDF client part:

script src="https://static.robotwebtools.org/threejs/current/three.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/STLLoader.js"></script>
<script src="https://static.robotwebtools.org/EventEmitter2/current/eventemitter2.js"></script>
<script src="https://static.robotwebtools.org/ros3djs/0.18.0/ColladaLoader.js"></script>
<script src="https://static.robotwebtools.org/ColladaAnimationCompress/current/ColladaLoader2.js"></script>
<script src="https://static.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="https://static.robotwebtools.org/ros3djs/current/ros3d.min.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/ColladaLoader.min.js"></script>
<script src="../build/roslib.js"></script>

var urdfClient = new ROS3D.UrdfClient({ 
     ros : ros, 
     tfClient : tfClient, 
     path : 'http://localhost:80/',
     rootObject : viewer.scene, 
     loader : ROS3D.COLLADA_LOADER
     });

I have tried using both the ROS3D.COLLADA_LOADER and ROS3D.COLLADA_LOADER_2.

I'm also using apache 2 and I have there the urdf.html and the meshes but the html code simply can't load them. In other hand I launch these files.

1.- roslaunch abb_irb140_support nodos.launch

<launch>
<arg name="KINECT1" default="$(optenv KINECT1 false)" />
<arg name="KINECT2" default="$(optenv KINECT2 false)" />

<group>
        <param name="robot_description" command="$(find xacro)/xacro '$(find abb_irb140_support)/urdf/irb140.urdf' --inorder KINECT1:=$(arg KINECT1) KINECT2:=$(arg KINECT2)" />
</group>
    <param name="use_gui" value="true" />
    <node name="robot_state_publiher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="joint_state_publiher" pkg="joint_state_publisher" type="joint_state_publisher" />   
    <node name="tf2_web_republiher"   pkg="tf2_web_republisher"   type="tf2_web_republisher" /> 
</launch>

2.-roslaunch rosbridge_server rosbridge_websocket.launch

Both of them work perfectly well and show the robot model in rviz. One thing that I don't know is if I need to launch the file from inside the apache server.

Inside the urdf file the filename is something like this:

"package://robot_description/meshes/irb140/visual/base_link.dae" The meshes are in /var/www/html/robot_description/meshes/irb140/visual/ and if I write http://localhost/robot_description/me... they can be accesed but again the files are not loaded in the html.

I hope someone could help me with this, I have been stucked with this problem several days now. Thank you I will appreciate any help.

have you solved this issue?

J-Rojas commented 5 years ago

It would be helpful if you looked at the web console and reported any errors there. You should also double check the network activity in the web developer tools to confirm if the mesh files were fetched properly from your web server.

simonbogh commented 5 years ago

I am experiencing the same issue. First error encountered when looking at the console is that https://static.robotwebtools.org/ColladaAnimationCompress/current/ColladaLoader2.js gives Access Denied.

Adding only the .js files from the readme will let me run my own model on my local webserver, however, nothing is visualized.

Chrome console output:

THREE.WebGLRenderer 89
favicon.ico:1 GET http://localhost/favicon.ico 404 (Not Found)
6ros3d.min.js:1 THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 0.385986328125ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 1.87109375ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 1.800048828125ms
ros3d.min.js:1 THREE.ColladaLoader: 6.006103515625ms
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 0.566162109375ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 0.8310546875ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 0.498779296875ms
ros3d.min.js:1 THREE.ColladaLoader: 3.011962890625ms
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 8.576904296875ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 36.6337890625ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 10.490966796875ms
ros3d.min.js:1 THREE.ColladaLoader: 56.48291015625ms
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 4.488037109375ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 25.200927734375ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 5.575927734375ms
ros3d.min.js:1 THREE.ColladaLoader: 35.941162109375ms
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 3.4443359375ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 10.873779296875ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 2.388916015625ms
ros3d.min.js:1 THREE.ColladaLoader: 17.489990234375ms
ros3d.min.js:1 THREE.ColladaLoader: DOMParser: 136.486083984375ms
ros3d.min.js:1 THREE.ColladaLoader: File version 1.4.1
ros3d.min.js:1 THREE.ColladaLoader: Parse: 319.914306640625ms
ros3d.min.js:1 THREE.ColladaLoader: Build: 71.3369140625ms
ros3d.min.js:1 THREE.ColladaLoader: 528.805908203125ms
ros3d.min.js:1 [Violation] 'load' handler took 529ms

HTML from the example folder with the following script imports

<script src="https://static.robotwebtools.org/threejs/current/three.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/ColladaLoader.js"></script>
<script src="https://static.robotwebtools.org/threejs/current/STLLoader.js"></script>
<script src="https://static.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="https://static.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="../build/ros3d.js"></script>
<script src="js/ColladaLoader.js"></script>

The URDF loading fine in rviz and gazebo. The DAE+STL files have been put on the webserver as well. What do you think could be the issue?

J-Rojas commented 5 years ago

@simonbogh based on the console output, it appears the collada models within the urdf have loaded. I believe the models are not visualized until there is a TF update that specifies where the models are positioned based on their frame id. Have you republished the TF messages using tf2_web_republisher node?

simonbogh commented 5 years ago

That is it, I was missing the tf2_web_republisher node. Everything is working now, thank you :)

marcoarruda commented 4 years ago

Same problem as @simonbogh , actually there is a topic about it on the official tutorial (https://wiki.ros.org/ros3djs/Tutorials/VisualizingAURDF), topic 1.4

Solved everything with a single launch file

<launch>
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
    </node>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    </node>
    <node name="tf2_web_republisher" pkg="tf2_web_republisher" type="tf2_web_republisher">
    </node>
</launch>

Thanks @J-Rojas !

mmsbruno commented 2 years ago

I have the same problem here, the website doesn't display any image (I'm working with an UR3 urdf). Screenshot from 2022-06-13 15-15-38

MatthijsBurgh commented 2 years ago

I can only say, don't use the static file from robotwebtools.org anymore. These are outdated.

nakai-omer commented 2 years ago

tf2_web_republisher is not maintained anymore, and has no porting to latest ros2 versions. So basically, urdf view isn't supported in latest versions.