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

Unable to open urdf or xacro with CROSS #4

Open
ARLunan opened this issue Nov 25, 2023 · 19 comments
Open

Unable to open urdf or xacro with CROSS #4

ARLunan opened this issue Nov 25, 2023 · 19 comments
Labels
help wanted Extra attention is needed

Comments

@ARLunan
Copy link

ARLunan commented Nov 25, 2023

After installation in FreeCAD 21.1 on both MAC VM Ubuntu 22.04 aarch64 ROS 2 Humble & on native MAC M1 arm64 OS 17.1:
On MAC VM running g FreeCAD error message there is a "no module named "urdf_parser_py"
ON native MAC, while the Addon Manager reports installed and no error messages.

But in both cases, unable to open .urdf or .xacro files .

@ARLunan
Copy link
Author

ARLunan commented Nov 26, 2023

Also the installation instructions url in the FreeCAD Custom Repository should be :
https://github.com/galou/freecad.cross

@galou
Copy link
Owner

galou commented Nov 28, 2023

Importing a URDF or xacro file requires ROS (i.e. calling source /opt/ros/humble/setup.bash, for example, and launching FreeCAD from the same terminal).

What do you mean with he FreeCAD Custom Repository?

@ARLunan
Copy link
Author

ARLunan commented Nov 28, 2023 via email

@ARLunan
Copy link
Author

ARLunan commented Nov 29, 2023

I corrected the urdf_parser_py error by installing $ sudo apt install ros-humble-urdfom-py. I also copied the freeCAD launch file into /.appImage , i.e. "/.appImage/FreeCAD_0.21.1-Linux-aarch64.AppImage . I can run freeCAD from anywhere with this path. SO where exactly in the ros sourced terminal that shows my ros2_ws workspace that contains my ros2 robot_description with urdf and xacro files do I run freCAD ?

@galou
Copy link
Owner

galou commented Nov 29, 2023

Launch the AppImage from the terminal is also working. It doesn't matter from which directory you launch FreeCAD, the required Python modules and ROS packages are found from some environment variables. There's no need to copy any FreeCAD launch file (which I don't know what it is) anywhere.

CROSS uses the $ROS_WORKSPACE environment variable but this is optional, at least I think. Try setting this variable and report.

@ARLunan
Copy link
Author

ARLunan commented Nov 29, 2023

Even after sourcing the ~/mtc_ws workspace, there is no ROS_WORKSPACE variable. SO I executed $ export ROS_WORKSPACE=/home/ubuntbc/mtc_ws , which sets it.

I tried your suggestion on my Ubuntu 22.04 ~/mtc_ws workspace which contains the "description" package urdf and xacro files.I sourced this mtc_ws workspace in the terminal from $ mtc_ws/ . install/setup.bash" . I can display the description package name with the "$ ros2 pkg list|grep description" command. So I launch freeCAD that has the CROSS Addon installed in this terminal. If I Open & browse to the workspace src/...urdf directory or the workspace install/share ... urdf directory I cannot open a .xacro or .urdf file. Attached is a capture of the freeCAD Open dialog noteing there is no .xacro or urdf is avaialnle to open in this list:
freeCAD-cross-supported-formats.pdf

@galou
Copy link
Owner

galou commented Nov 30, 2023

You cannot open any URDF or xacro file this way (I mean through FreeCAD's "Open..." command), you have to use the dedicated button in CROSS's toolbar. I know, the documentation is lacking (help welcome).

The reason for this (for now) is precisely the requirement that ROS must be sourced and the appropriate environment variables available in FreeCAD.

@galou galou added the help wanted Extra attention is needed label Nov 30, 2023
@ARLunan
Copy link
Author

ARLunan commented Nov 30, 2023

After launching FreeCAD p[rogram (./FreeCAD_0.21.1-Linux-aarch64.AppImag ) from a ROS sourced Terminal, navigating to Menu Bar>View>Workbench>CROSS able to open a xacro file in a sourced linorobot2_ws robot workspace. Thank you as this should be very useful. I will create a "FeeCAD-CROSS Install & Run Cheatsheet". for my use and forward to you.

@galou
Copy link
Owner

galou commented Dec 1, 2023

Great, thanks for this document in advance.

@ARLunan
Copy link
Author

ARLunan commented Dec 2, 2023

I edited my previous post because I realized that freeCAD-CROSS generated errors because I believe it can only import a "description package" urdf or xacro xml file that has no xml syntax errors and either that or a referenced file contains a "base_link" and correct paths to other necessary xacros that define the other structures in the robot. I added missing other referenced xacros.

After installing these binary (sudo apt install ros-humble-irobot-create-descrption and -irobot-create-control ) packages into /opt/ros/humble/share, imported create3.urdf.xacro , successfully displayed the URDF and its structure. I also verfiied the freeCAD.CROSS Addon with another robot description package that I have (linorobot2_descripton) with suacess too. This i s a good test of the freeCAD.CROSS Addon

New problem: Installed binary sudo apt install ros-humble-turtlebot4_description package in my Ubuntu 22.04/ROS 2 machine, importing the urdf/lite/turtlebot4.urdf.xacro gives this error: Running the Python command 'UrdfImport' failed: ..........
can only concatenate str (not "builtin_function_or_method") to str
. Maybe there is a missing " str" function? The xacro files in both irobot-create and turtlebot4 packages contains stl & dae and many xacro files..

@galou
Copy link
Owner

galou commented Dec 6, 2023

Eventually, the issue was in the turtlebot4_description package.

@jetdillo
Copy link

I am having a similar problem.
Running FreeCAD 0.21.2 on Ubuntu 20.04, ROS Noetic.
I've cloned the repo here, installed:

ros-noetic-urdfdom-py
urdf-parser-py (via pip) 

and followed the install instructions.
I still get
No module named 'urdf_parser_py'

When starting FreeCAD and then when I try to load in a .xacro file:

Running the Python command 'UrdfImport' failed:
Traceback (most recent call last):
  File "/home/armadilo/.local/share/FreeCAD/Mod/freecad.cross/freecad/cross/ui/command_robot_from_urdf.py", line 37, in Activated
    urdf_robot = UrdfLoader.load_from_file(filename)

name 'UrdfLoader' is not defined

I have ROS Noetic installed and source my workspace from my .bashrc.

I can import urdf_parser_py from the REPL:
`(base) armadilo@roadrunner:~/projects/freecad.cross$ python
Python 3.10.9 (main, Mar 1 2023, 18:23:06) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import urdf_parser_py
dir(urdf_parser_py)
['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec']
`

I'm pretty new to FreeCAD, but quite familiar with ROS.
I think there's a lot of promise to this and would really like to use it to help with a Gazebo project I'm currently working on.

@galou
Copy link
Owner

galou commented Jan 16, 2024

ROS1 is not supported.

@SimeonOA
Copy link

SimeonOA commented Jun 17, 2024

Hi @galou,

I am having this same issue when trying to load a urdf file.

Here are my setup details:
Computer: Ubuntu 22.04
ROS Version: Humble

When I run ./FreeCAD.AppImage --appimage-extract-and-run, the image below is my result:

Screenshot from 2024-06-16 17-40-44

When I try to import the urdf file, I get this error:

Screenshot from 2024-06-16 17-41-19

I have tried pip install urdfpy, pip install urdf-parser-py and sudo pip install urdf-parser-py.
I have also tried adding ~/.local/lib/python3.10/site-packages to the PYTHONPATH.
None of these work.
Do you have any suggestion on what I could do?
Thanks

@galou
Copy link
Owner

galou commented Jun 17, 2024

Did you try to source a ROS workspace?

@SimeonOA
Copy link

Yes. I sourced my ROS workspace. Also after running colcon build, I sourced the install/setup.bash.

I am still having the error.

@galou
Copy link
Owner

galou commented Jun 24, 2024

Can you run python -c "import urdf_parser_py" in the same terminal where you launch FreeCAD?

@drfenixion
Copy link
Contributor

drfenixion commented Jul 10, 2024

Yes. I sourced my ROS workspace. Also after running colcon build, I sourced the install/setup.bash.

I am still having the error.

Also you can try follow https://github.com/drfenixion/freecad.overcross/tree/main/docker README.md
It will run FreeCAD + CROSS inside docker container and also install needed dependencies via helper ROS package.
Or just install dependencies from that package to your system directly via "rosdep install" (see above readme).

@galou
Copy link
Owner

galou commented Aug 1, 2024

I'll close this issue in case @SimeonOA doesn't react.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants