Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finded a way to run FreeCAD from ROS2 docker container without big overhead. #6

Closed
drfenixion opened this issue Feb 13, 2024 · 2 comments

Comments

@drfenixion
Copy link
Contributor

drfenixion commented Feb 13, 2024

Finded solution. See my second comment.

For your notation. It have dependency (rclpy) what dont mentioned in repo.

Also i think it is not be best way to direct dependency to ROS because best practice of usage ROS is in Docker. This lead to i dont have ROS in my host system (where installed freecad). Install freecad to docker ROS image will lead to big overhead.
Could you describe why u need to dependency on ROS?

CROSS Workbranch does`t appear and have error logs in report view.

12:33:25  Init: Initializing freecad.cross
12:33:25  The environment variable `ROS_DISTRO` is not set and no ROS installation was found in /opt/ros, some functionalities will be missing
12:33:25  During initialization the error "No module named 'rclpy'" occurred in freecad.cross
12:33:25  --------------------------------------------------------------------------------
12:33:25  Traceback (most recent call last):
  File "<string>", line 226, in InitApplications
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/__init__.py", line 7, in <module>
    from .wb_globals import g_ros_distro
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/wb_globals.py", line 18, in <module>
    from .ros.node import get_node_and_executor  # noqa: E402.
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/ros/node.py", line 6, in <module>
    import rclpy
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'rclpy'
12:33:25  --------------------------------------------------------------------------------
12:33:25  Init:      Initializing freecad.cross... failed
12:33:25  --------------------------------------------------------------------------------
12:33:25  Traceback (most recent call last):
  File "<string>", line 226, in InitApplications
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/__init__.py", line 7, in <module>
    from .wb_globals import g_ros_distro
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/wb_globals.py", line 18, in <module>
    from .ros.node import get_node_and_executor  # noqa: E402.
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
  File "/home/user/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/ros/node.py", line 6, in <module>
    import rclpy
  File "/tmp/.mount_FreeCAocHVXG/usr/lib/python3.10/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'rclpy'
12:33:25  --------------------------------------------------------------------------------
@drfenixion drfenixion changed the title Not described dependency Not described dependency present Feb 13, 2024
@drfenixion
Copy link
Contributor Author

drfenixion commented Feb 13, 2024

I find a way to run FreeCAD from docker ROS2 container without big overhead.

You should add FreeCAD appImage to bind volume directory. That you can do like this:

docker run -t -d --name=$ros_container_name \
    --volume=$path_to_ws/src:/home/ubuntu/$path_to_ws_relatively_user_directory/src \

You should place FreeCAD-0.21.2-Linux-x86_64.AppImage onto your host system in $path_to_ws/src dir

cp FreeCAD-0.21.2-Linux-x86_64.AppImage $path_to_ws/src/FreeCAD-0.21.2-Linux-x86_64.AppImage

Also you need bind your host $DISPLAY to container, like this:

    --env "DISPLAY=$DISPLAY" \
    --env WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
    --privileged \
    --volume="/dev/dri:/dev/dri" \
    --env QT_X11_NO_MITSHM=1 \
    --env PULSE_SERVER=$PULSE_SERVER \
    --env QT_X11_NO_MITSHM=1 \

and make other needed configuration for usage of host discrete GPU (if your integrated in proc GPU will be used and it not enough for rendering (you have lags))

After that you should run from container from ros workspace:

source /opt/ros/$ROS_DISTRO/setup.bash
source install/setup.bash

pip install urdf-parser-py #missed dependency

./src/FreeCAD-0.21.2-Linux-x86_64.AppImage --appimage-extract-and-run

And enjoy FreeCAD from ROS2 container.

If you have "segmentation fault" error use sudo. Like this:
sudo ./src/FreeCAD-0.21.2-Linux-x86_64.AppImage --appimage-extract-and-run

Btw "Segmantation fault" appear after binding docker volume with freecad.cross source to FreeCAD mod path, like this:
--volume=$path_to_ws/src/freecad.cross:/home/ubuntu/.local/share/FreeCAD/Mod/freecad.cross
because it make dir of freecad.cross as root. You can fix that by:
chown ubuntu:ubuntu /home/ubuntu/.local/share/FreeCAD/Mod/freecad.cross -R
and after that you can use
./src/FreeCAD-0.21.2-Linux-x86_64.AppImage --appimage-extract-and-run
without sudo

@drfenixion drfenixion changed the title Not described dependency present Finded a way to run FreeCAD from ROS2 docker container without big overhead. Feb 13, 2024
@drfenixion
Copy link
Contributor Author

Resolved by merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant