Run scripts in Setup.py
Hello,
Today (after hours of debugging), I figured out that the "xacro" command outputs the comments in the urdf.
The problem is that when loading an urdf file in a launch file, it will fail if your comment has a ":" in it, since it's read as a yaml string.
The only way around this is to run a script that builds the XML file without comments. This can be done in the launch file, but it would be beneficial to run it during colcon build.
In the setup.py, you can define the data files to use, but it would be better to generate data files. So that in the "share" folder, you won't have all the different xacro and urdf files, but instead the one urdf file that defines the robot. It could also help for other configuration files, like combining yaml files for specific configurations, etc.
So, is there a way to run scripts in the setup.py file to generate files?
So isn't the real problem here that "urdf file[s] [..] are read as a yaml string"? The title seems to be about something else.
Yes and no.
Sorry, I'm not at my computer right now, so the formatting is bad. I'll make a new comment tomorrow.
The original problem was that I ran this code:
And when I added it as a parameter to a node it gave an error. Something about an yaml parser that failed.
Looking into it, I noticed the error came from a ":" I had in the comment of the urdf file.
And it's because the xacro executable prints a long string including the comments.
I don't know exactly what Command object does, but you can't have ":" in urdf files.
Removing all the ":"s from the urdf comments made everything run smoothly.
The only solution I could think of is to run the urdf through a script to remove ...(more)