I'm trying to visualize a 3d robot simulation on a web browser and I'm currently using the ros3djs library (not sure if this is the best choice yet).
Some days ago I managed to visualize correctly the PR2 robot as shown in this tutorial, and then I replaced it with my robot meshes and urdf. The meshes were visible but the relations between links and joints weren't correct and the robot seemed just hit by a truck.
Suddenly, yesterday, the meshes of my robot stopped being visualized in the browser and I realized that the the HTTP request of the meshes (sent by the ROS3D.UrdfClient function) are not made anymore.
I tried to remove and update the ros3d.js file but didn't work.
I don't have any idea of where the problem could be.
The only comment I can make is that yesterday I was trying to solve the problem of the meshes (related to the tf2_web_republisher) node and I added a new node aiming to republish the messages from the /tf topic to the /tf2_web_republish/goal. That didn't even work and I don't think that this can be the cause, but who knows.
This is the code that I'm using to visualize the 3D simulation.
async function init(){
var ros = new ROSLIB.Ros({
url : 'ws://localhost:9090'
});
ros.on('connection', function() {
console.log('Connected to websocket server.');
});
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error);
});
ros.on('close', function() {
console.log('Connection to websocket server closed.');
});
// Create the main viewer.
var rosViewer = new ROS3D.Viewer({
divID : 'urdf',
width : 800,
height : 600,
antialias : true,
});
// Add a grid.
rosViewer.addObject(new ROS3D.Grid());
// Setup a client to listen to TFs.
var tfClient = new ROSLIB.TFClient({
ros : ros,
angularThres : 0.01,
transThres : 0.01,
rate : 10.0
});
//// Setup the URDF client.
//var urdfClient = new ROS3D.UrdfClient({
// ros : ros,
// tfClient : tfClient,
// path: 'https://raw.githubusercontent.com/PR2/pr2_common/melodic-devel/',
// rootObject : rosViewer.scene,
//});
var urdfClient = new ROS3D.UrdfClient({
ros : ros,
tfClient : tfClient,
path: 'static/',
rootObject : rosViewer.scene,
});
}
</script>
And this is the launch file that I made and used to work:
<launch>
<arg name="model" default="h2017"/>
<arg name="ns" default="dsr01"/>
<arg name="gui" default="True" />
<arg name="remap" default="False"/>
<arg name="color" default="white"/>
<arg name="gripper" default="none"/>
<arg name="rviz" default="True"/>
<param name="robot_description" command="$(find xacro)/xacro '$(find dsr_description)/xacro/$(arg model).urdf.xacro' '--inorder' 'namespace:=$(arg ns)' color:=$(arg color) gripper:=$(arg gripper)"/>
<node name="ros_bridge_websocket_name" pkg="rosbridge_server" type="rosbridge_websocket" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" /> <param name="use_gui" type="bool" value="true" /> <!-- this next node gives control over the joints
--> <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" /> <node name="tf2_web_republisher" pkg="tf2_web_republisher" type="tf2_web_republisher" /> <node name="map_server" pkg="map_server" type="map_server" args="/home/dario/maps/rail_maps/ilab.pgm 0.05" />
<!-- Show in Rviz -->
<group if="$(eval arg('rviz') == True)">
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find dsr_description)/rviz/default.rviz"/>
</group>
</launch>
I'm using ROS Noetic on Ubuntu 20.04.
I hope I wrote all the relevant informations. Thanks to everyone that may help.