Closed robofoundry closed 2 years ago
Hello!
Thanks for bringing up this issue. I'm curious, when you installed jupyter-ros from source, did you follow the instructions on the main README or the ones in the documentation? The documentation is more up to date than the README. However, the installation instructions are intended for ROS1 but the only difference would be how the environment is created.
mamba create -n ros2_env jupyterlab jupyter-packaging nodejs=15 ros-humble-desktop -c conda-forge -c robostack-humble
We are working under the assumption that users will only have one ROS distro installed in each environment. So whenever you import jupyros, it will check if ROS2 is installed otherwise it'll default to ROS1. And yes, you can change the default to ROS2 with the changes that you made. But ideally, that will be automatic if the environment has one ROS2 installed.
As you mentioned, it looks like the paths are conflicting with your foxy installation. Do you have anything in your .bashrc file which automatically activates Foxy? When you activate your ROS2 environment, do the environment variables get set correctly?
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_DISTRO=humble
And another suggestion which could be easily overlooked, JupyterLab needs to be launched from the ROS2 humble environment itself.
Hopefully this helps. And one more drastic suggestion would be to uninstall Foxy from your main computer, but that would be last resort.
Thanks so much for looking into the details and making all these suggestions. I'll probably start fresh by creating a new env as you suggested, unset the env variables in main computer bashrc file and set the ones within the env and then install everything. Hopefully everything will work, eager to make it all work from jupyter labs because it will make writing tutorials and other things in future much easy for people to follow without having to be comfortable with terminal commands for ROS.
Its finally working well from jupyter-lab with ROS2 humble and the example notebook!!! Thanks so much, here is what I had to do based on your suggestions to get it all working. And I didn't have to reinstall anything, so somehow I must have followed the right steps :)
This is pretty awesome. I'll document the steps in another blog article. Thanks @ihuicatl so much for all your help in getting around this issues.
Logging an issue to describe details of errors to answer question from Gitter thread. I tried to run the notebook named - Ros2 Pub_Sub_Communication.ipynb from pre-release https://github.com/RoboStack/jupyter-ros/tree/v0.6.0a0/notebooks and got following errors. It may be some issue with the way I installed the package and extensions. I tried to follow instructions from here to install from source.
I have an env named ros_env which has ROS2 humble installation with full desktop version of humble installed and it works correctly. I also tried to set ROS_DISTRO=humble in the terminal within jupyter-labs to see if it will make any difference but it didn't help.
I also have another env named ros2_foxy where ROS2 foxy is installed and main computer where ROS2 foxy is installed as well with ROS_DISTRO=foxy for main computer. I can see that in the error description it is still trying to look in the paths under /opt/ros/foxy even though I am running in humble so may be that's the main issue somehow.
Please suggest any options as I'm willing to try to get it to work with ROS2 in jypyter-labs. It will be a big help for community overall if I can document how to get it working.
I did make a change in the ~/mambaforge/envs/ros_env/jupyter-ros-0.6.0a0/jupyros/init.py file to change the ros version to 2 and name to humble like this, I thought this was necessary to use ROS2 but I could be wrong:
While running following block of code in jupyter-labs:
Two main errors received - one saying jupyros not found and the other with context problem related to rp.init()