jupyter-robotics / jupyterlab-urdf

A URDF viewer and editor extension for JupyterLab.
https://jupyterlab-urdf.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
97 stars 9 forks source link

How to properly configure the ROS environment #19

Closed zengtaiping closed 1 year ago

zengtaiping commented 2 years ago

Hi, thanks for a handy tool for URDF visualization. When I tried the example, I got the following errors: [W 2022-08-13 18:46:09.980 ServerApp] 404 GET /ros/pkgs/t12_description/meshes/Body.STL (127.0.0.1) 24.62ms referer=http://localhost:8890/lab

How to properly configure the ROS environment to access mesh '*.stl'? After I install jupyterlab-ros and jupyterlab-urdf(conda install jupyterlab-urdf -c conda-forge), the path is changed and checked by echo $ROS_PACKAGE_PATH. Even if I added the current catkin project to this variable, it also cannot access the mesh files.

How could I change the folder/ros/pkgs/ to the one I want to access?

Thanks. Best.

IsabelParedes commented 2 years ago

Hello!

I think the problem might be because you need to configure the environment before launching JupyterLab.

Let's say your environment is called ros_env where you already have jupyterlab, jupyterlab-ros, jupyterlab-urdf and ros-noetic-desktop. From a single terminal:

  1. Activate the environment conda activate ros_env
  2. Navigate to the jupyterlab-urdf/examples folder. Inside you will find a src directory so essentially examples/ is treated as a workspace.

From examples/

  1. Build the workspace with catkin build
  2. source devel/setup.bash
  3. Your $ROS_PACKAGE_PATH should now contain the paths to the robot descriptions
  4. Now you can launch JupyterLab from that same terminal with jupyter lab

Let me know if this works :)

zengtaiping commented 2 years ago

Hi, @ihuicatl thanks for the quick reply. My guess is there is a conflict between envs jupyterlab-urdf and catkin source.

When I reinstall jupyterlab-urdf, the path becomes home/*/anaconda3/envs/robostackenv/share/.

When I did catkin build and source devel/setup.bash, then I start jupyter lab the jupyter urdf is not properly started. It includes the mesh and ros path, but does not includejupyterlab-urdf, e.g. /*/jupyterlab-urdf/examples/src/ned_description:/*/jupyterlab-urdf/examples/src/spot_description:/*/jupyterlab-urdf/examples/src/t12_description:/opt/ros/noetic/share.

Then I manually used export ROS_PACKAGE_PATH to append the necessary path for both jupyter-urdf and catkin. It also did not work. It seems there are some other envs variables needed to be set.

I am looking forward to your reply.

IsabelParedes commented 2 years ago

Hi @zengtaiping!

I think the best idea would be to start with a fresh environment. Also, make sure there is nothing in your .bashrc file which could be modifying your ROS paths. Do you have noetic installed locally? It looks like one of your paths includes /opt/ros/noetic/share

  1. Create environment called ros_env (or anything else) with the required packages. All of these packages need to be installed in the same environment.
    conda create -n ros_env jupyterlab jupyterlab-urdf jupyterlab-ros ros-noetic-desktop -c conda-forge -c robostack
  2. Activate the environment
    conda activate ros_env
  3. Echo $ROS_PACKAGE_PATH. This should only contain home/*/anaconda3/envs/ros_env/share/. If this is not correct, there may be an issue with the conda configuration.
  4. Navigate to the examples folder and clean the workspace
    cd jupyterlab-urdf/examples/
    catkin clean
  5. Build the workspace again with catkin build and run source devel/setup.bash from the examples directory
  6. Check your ROS path again, and if everything looks good then you can launch JupyterLab

And just to double check, make sure you are only working with a single conda environment since you mentioned there might be a conflict between environments.

Let me know how it goes.

zengtaiping commented 2 years ago

Hi @ihuicatl ,

I am so sorry for the late response. Thanks so much for your detailed information. It works now.

zengtaiping commented 2 years ago

I am sorry for the wrong click. Please close this issue.