Tools for modifying URDF packages and converting URDF into well organized Xacro.
This set of tools helps you modify your URDF ROS package and streamlines the process of converting URDF files into Xacro format, making your robot modeling workflow more efficient.
- Package Renaming: Replacing matching parts in all folders, files and contents in your URDF ROS package.
- URDF Modifying: Modify URDF files with python scripts instead of manually. What you need is to create a basic URDF file first and then automatically modifying it as you wish.
- Extract intertial from a text file copied from solidworks and save to a json file.
- Use a python file to flexibly load all configs to a CONFIG dict, which will be used by the convertion tool.
- URDF to Xacro Conversion: Convert
.urdffiles to a well organized.xacroformat with ease.
Follow these simple steps to start using the URDF to Xacro tools.
ROS packages have specific naming conventions. Use the following command to rename your package:
python3 rename.py -path <path/of/your/package> -in <old_name> -out <new_name>This command will replace the old package name in all folders, files, and file contents with the new name.
Example:
If your URDF package path is ~/ws/src/BAD--name, run:
python3 rename.py -path ~/ws/src/BAD--name -in BAD--name -out new_name- Create a configuration folder that contains a python file(e.g.
urdf_config.py) and ohtter config files. - Convert links_intertial.txt that contains intertial information copied from solidworks to a json file:
python3 extract_intertial.py -in example_config/links_inertial.txt -t 1e-5 -ln base_link link1
- Modify the python file to set the desired configurations, e.g.
joints_limit,links_intertial, etc.
- Run the conversion script with the path to your URDF file:
python3 urdf_to_xacro.py -in <urdf_file_path> -cfg example_config/urdf_config.py -ml allThe conversion process includes:
- Replacing joints limit and links_intertial with values from
CONFIGdict inconfig.py. - Adding Xacro variables within the robot tag.
- Encapsulating the robot tag's content in a
xacro:macrotag with a prefix parameter. - Renaming all joints and links to incorporate the prefix, e.g.,
${prefix}joint1. - Saving the modified file as a
.xacrofile with the same name. - Formatting the Xacro file using
xmllintfor uniformity and readability.
For more ways to use, please refer to the source code.
Contributions are welcome!
This project is licensed under the MIT License.
Feel free to open an issue for support, questions, or suggestions.