galou / freecad.cross

CROSS CAD and ROS, an Open-Source Synergy; ROS workbench for FreeCAD
GNU Lesser General Public License v2.1
84 stars 21 forks source link

Unable to open urdf or xacro with CROSS #4

Open ARLunan opened 9 months ago

ARLunan commented 9 months ago

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 commented 9 months ago

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

galou commented 9 months ago

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 commented 9 months ago

Tnx, yes I understand the importance of the source command for any terminal instance running any ROS 2 functions. So  I include the source command in my .bashrc file. I also realize that I cannot use Freecad with your freecad.cross Addon in my native MAC as it does not have an installed ROS 2.I believe I correctly configured freecad.cross in my Ubuntu 22.04 FreeCAD .21.1 using the procedure in your https://github.com/galou/freecad.cross/tree/main Readme.The freecad.cross Addon is in Preferences/Addon Manager  and Tools/Addon Manager and appears to be installed , but gives the error “not finding urdf_parser_py package”, which is installed on my machine in the /opt/ros/humble package folder.I believe my problem is that I am unable to run Freecad (configured with freecad.cross ) as a command line executable from my ros workspace terminal root. This ver 21  Freecad is only available downloaded on a Ubuntu aarch64 machine as an AppImage file and run ./freecad.AppImage from the Download folder.I’m trying now to configure Freecad to run from a command line terminal anywhere. Any suggestions or links to helpful @. Nov 28, 2023, at 2:57 AM, Gaël Écorchard @.> wrote: 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?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

ARLunan commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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.

ARLunan commented 9 months ago

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 commented 9 months ago

Great, thanks for this document in advance.

ARLunan commented 8 months ago

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 commented 8 months ago

Eventually, the issue was in the turtlebot4_description package.

jetdillo commented 7 months ago

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 commented 7 months ago

ROS1 is not supported.

SimeonOA commented 2 months ago

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 commented 2 months ago

Did you try to source a ROS workspace?

SimeonOA commented 2 months ago

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

I am still having the error.

galou commented 2 months ago

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

drfenixion commented 1 month ago

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 commented 3 weeks ago

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