### Clone and Install Repository Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Clone the forked repository and install the project in editable mode with development dependencies. ```bash git clone git@github.com:YourLogin/yourdfpy.git cd yourdfpy ``` ```bash pip install -U pip setuptools -e . ``` -------------------------------- ### Install from TestPyPI Source: https://github.com/clemense/yourdfpy/blob/main/README.md Installs a package from TestPyPI, with fallback to the main PyPI. Useful for testing releases before they go live. ```bash python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple yourdfpy==v ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Install pre-commit to automatically check code style and quality before committing. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Install yourdfpy with pip Source: https://github.com/clemense/yourdfpy/blob/main/README.md Install the library using pip. This is the standard method for adding Python packages to your environment. ```bash pip install yourdfpy ``` -------------------------------- ### Run Tox in a Dedicated Virtual Environment Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Create a dedicated virtual environment, install Tox, and run all Tox environments. ```bash virtualenv .venv source .venv/bin/activate .venv/bin/pip install tox .venv/bin/tox -e all ``` -------------------------------- ### Check Tox Version and Path Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Verify the installed Tox version and its location in your system's PATH. ```bash tox --version # OR which tox ``` -------------------------------- ### yourdfpy.urdf.URDF.cfg Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Gets or sets the current configuration of the URDF model. ```APIDOC ## property cfg ### Description Current configuration. ### Returns * **np.ndarray** - The current configuration of the URDF model. ``` -------------------------------- ### yourdfpy.viz.setup_logging Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Sets up basic logging with a specified minimum log level. ```APIDOC ## yourdfpy.viz.setup_logging(loglevel) ### Description Setup basic logging. ### Parameters #### Path Parameters * **loglevel** (int) - Required - minimum loglevel for emitting messages ``` -------------------------------- ### Compile and Preview Documentation with Tox Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Use tox to compile documentation and Python's http.server to preview it locally. Ensure the docs directory is correctly specified. ```bash tox -e docs ``` ```bash python3 -m http.server --directory 'docs/_build/html' ``` -------------------------------- ### Set up Virtual Environment Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Use virtualenv or Miniconda to create an isolated Python environment for development. ```bash virtualenv source /bin/activate ``` ```bash conda create -n pyscaffold python=3 six virtualenv pytest pytest-cov conda activate pyscaffold ``` -------------------------------- ### Preview Documentation Locally Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Serve the compiled documentation using Python's built-in HTTP server for local preview. Access it at http://localhost:8000. ```bash python3 -m http.server --directory 'docs/_build/html' ``` -------------------------------- ### Build Release Artifacts with tox Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Run this command to build the distribution files for a new release. Verify that the files in the 'dist' folder have the correct version number and are not excessively large. ```bash tox -e build ``` -------------------------------- ### Run Unit Tests with Tox Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Execute all pre-configured tasks and tests using Tox. Ensure your changes do not break existing tests. ```bash tox ``` -------------------------------- ### Compile Documentation with Tox Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Use tox to compile the project documentation. This command ensures that the documentation is built correctly according to the project's standards. ```bash tox -e docs ``` -------------------------------- ### Create Virtual Environment with virtualenv Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Set up an isolated Python virtual environment using virtualenv. Activate the environment to manage project dependencies separately. ```bash virtualenv source /bin/activate ``` -------------------------------- ### yourdfpy.viz.run Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Calls the main function with CLI arguments extracted from sys.argv. This can serve as an entry point for console scripts. ```APIDOC ## yourdfpy.viz.run() ### Description Calls [`main()`](#yourdfpy.viz.main) passing the CLI arguments extracted from `sys.argv`. This function can be used as entry point to create console scripts with setuptools. ``` -------------------------------- ### Publish Release to PyPI with tox Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Execute this command to upload the built distribution files to PyPI. Ensure that the upload is successful and all artifacts are correctly published. ```bash tox -e publish -- --repository pypi ``` -------------------------------- ### Create Pull Request Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Navigate to your fork's web page and initiate a pull request to submit your changes for review. ```bash Uncomment the following paragraph if using GitHub: # Find more detailed information `creating a PR`_. You might also want to open # the PR as a draft first and mark it as ready for review after the feedbacks # from the continuous integration (CI) system or any required fixes. ``` -------------------------------- ### yourdfpy.viz.main Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A wrapper function that allows string arguments to be passed in a CLI fashion for visualization. ```APIDOC ## yourdfpy.viz.main(args) ### Description Wrapper allowing string arguments in a CLI fashion. ### Parameters #### Path Parameters * **args** (List[str]) - Required - command line parameters as list of strings (for example `["--verbose", "42"]`). ``` -------------------------------- ### Create Virtual Environment with Conda Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Create and activate a Conda environment for the project, pre-installing necessary packages like Python, six, virtualenv, pytest, and pytest-cov. ```bash conda create -n pyscaffold python=6 virtualenv pytest pytest-cov conda activate pyscaffold ``` -------------------------------- ### Visualize URDF Model from Command Line Source: https://github.com/clemense/yourdfpy/blob/main/README.md Use the yourdfpy command-line tool to visualize a URDF file. This command requires the path to your URDF file. ```bash yourdfpy ./my_description/urdf/robot.urdf ``` -------------------------------- ### List Available Tox Checks Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst View all available pre-configured tasks and checks that can be run with Tox. ```bash tox -av ``` -------------------------------- ### Clean Build Artifacts with tox Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md Use this command to clean the 'dist' and 'build' folders before creating a new release. This ensures no old build artifacts interfere with the new release. ```bash tox -e clean ``` -------------------------------- ### yourdfpy.viz.parse_args Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Parses command line parameters provided as a list of strings. ```APIDOC ## yourdfpy.viz.parse_args(args) ### Description Parse command line parameters ### Parameters #### Path Parameters * **args** (List[str]) - Required - command line parameters as list of strings (for example `["--help"]`). ### Returns #### Success Response - **argparse.Namespace** - command line parameters namespace ``` -------------------------------- ### Create Montage of Scene Images Source: https://github.com/clemense/yourdfpy/blob/main/README.md Creates a montage image from multiple PNG scene images. This command-line usage is typically run after generating individual scene images. ```bash montage /tmp/test*png -geometry +50+0 -tile x1 /tmp/montage_geom.jpg ``` -------------------------------- ### Upload to PyPI Source: https://github.com/clemense/yourdfpy/blob/main/README.md Uploads distribution files to the main PyPI repository. This is the final step for releasing a new version. ```bash twine upload dist/* ``` -------------------------------- ### Fetch All Tags Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Ensure all tags are fetched from the upstream repository, useful for verifying versions. ```bash git describe --abbrev=0 --tags ``` -------------------------------- ### Upload to TestPyPI Source: https://github.com/clemense/yourdfpy/blob/main/README.md Uploads distribution files to the TestPyPI repository. This is a preliminary step before uploading to the main PyPI. ```bash python setup.py bdist_wheel twine upload -r testpypi dist/* ``` -------------------------------- ### show Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Opens a simple viewer to display the URDF model. Users can choose to visualize either the collision or visual geometry. ```APIDOC ## show(collision_geometry=False, callback=None) ### Description Open a simpler viewer displaying the URDF model. ### Parameters #### Path Parameters - **collision_geometry** (bool, optional) - Whether to display the or elements. Defaults to False. ``` -------------------------------- ### Recreate Tox Environment Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Recreate the Tox environment with the -r flag if dependencies are missing or issues arise. ```bash tox -r -e docs ``` -------------------------------- ### Tag and Push Git Repository Source: https://github.com/clemense/yourdfpy/blob/main/README.md Commands for tagging a new version and pushing it to the remote repository. This is part of the deployment process. ```bash git tag -l rm dist/* rm -rf build/ git gui # commit something? git tag v git push origin main git push origin ``` -------------------------------- ### Alternative: Manual Cleanup Source: https://github.com/clemense/yourdfpy/blob/main/docs/contributing.md If 'tox -e clean' is not available or preferred, you can manually remove the 'dist' and 'build' directories using standard shell commands. ```bash rm -rf dist build ``` -------------------------------- ### Push Branch to Remote Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Push your local feature branch to the remote repository on the code hosting service. ```bash git push -u origin my-feature ``` -------------------------------- ### Load URDFs and Measure Performance Source: https://github.com/clemense/yourdfpy/blob/main/README.md This code snippet demonstrates how to load a list of URDF files using different libraries (urdfpy, urdf_parser_py, yourdfpy) and measures their parsing times. It also shows how to load URDFs without mesh loading and scene graph building using yourdfpy. ```python robot_assets = ['robot-assets/urdfs/robots/barret_hand/bhand_model.URDF', 'robot-assets/urdfs/robots/robotiq_gripper/robotiq_arg85_description.URDF', 'robot-assets/urdfs/robots/anymal/anymal.urdf', 'robot-assets/urdfs/robots/franka_panda/panda.urdf', 'robot-assets/urdfs/robots/ginger_robot/gingerurdf.urdf', 'robot-assets/urdfs/robots/halodi/eve_r3.urdf', 'robot-assets/urdfs/robots/kinova/kinova.urdf', 'robot-assets/urdfs/robots/kuka_iiwa/model.urdf', 'robot-assets/urdfs/robots/pr2/pr2.urdf', 'robot-assets/urdfs/robots/ur10/ur10_robot.urdf', 'robot-assets/urdfs/robots/ur5/ur5_gripper.urdf', 'robot-assets/urdfs/robots/yumi/yumi.urdf'] import urdfpy import urdf_parser_py import yourdfpy from functools import partial def load_urdfs(fnames, load_fn): results = {fname: None for fname in fnames} for fname in fnames: try: x = load_fn(fname) results[fname] = x except: print("Problems loading: ", fname) pass print(sum([1 for x, y in results.items() if y is not None]), "/", len(fnames)) return results # parsing success rate load_urdfs(robot_assets, urdfpy.URDF.load) load_urdfs(robot_assets, urdf_parser_py.urdf.URDF.load) load_urdfs(robot_assets, yourdfpy.URDF.load) # parsing times %timeit load_urdfs(robot_assets, urdfpy.URDF.load) %timeit load_urdfs(robot_assets, urdf_parser_py.urdf.URDF.load) %timeit load_urdfs(robot_assets, yourdfpy.URDF.load) %timeit load_urdfs(robot_assets, partial(yourdfpy.URDF.load, load_meshes=False, build_scene_graph=False)) ``` -------------------------------- ### Stage and Commit Changes Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Stage modified files and commit them with a descriptive message. Ensure pre-commit hooks pass. ```bash git add git commit ``` -------------------------------- ### Visualization Utilities Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/modules.md Functions for generating visualizations, including joint limit trajectories and setting up logging. ```APIDOC ## generate_joint_limit_trajectory() ### Description Generates a trajectory for joint limits. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## main() ### Description Main entry point for the visualization module. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## parse_args() ### Description Parses command-line arguments for the visualization module. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## run() ### Description Executes the main visualization logic. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## setup_logging() ### Description Sets up the logging configuration for the visualization module. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## viewer_callback() ### Description Callback function for the viewer. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Compare URDF Loading Speed Source: https://github.com/clemense/yourdfpy/blob/main/README.md Compares the loading speed of URDF files using yourdfpy and urdf_parser_py. This snippet is useful for performance benchmarking. ```python urdfpy_fnames = [x for x, y in load_urdfs(robot_assets, urdfpy.URDF.load).items() if y is not None] %timeit load_urdfs(urdfpy_fnames, yourdfpy.URDF.load) ``` ```python urdfparser_fnames = [x for x, y in load_urdfs(robot_assets, urdf_parser_py.urdf.URDF.from_xml_file).items() if y is not None] %timeit load_urdfs(urdfparser_fnames, functools.partial(yourdfpy.URDF.load, load_meshes=False, build_scene_graph=False)) ``` -------------------------------- ### zero_cfg Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Returns the zero configuration for the URDF model. ```APIDOC ## zero_cfg ### Description Returns the zero configuration for the URDF model. ### Parameters None ### Request Example None ### Response #### Success Response (200) * **Returns** (np.ndarray) - The zero configuration. #### Response Example None ``` -------------------------------- ### Create a Feature Branch Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Create a new branch for your feature or bugfix. Never work directly on the master branch. ```bash git checkout -b my-feature ``` -------------------------------- ### load Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Loads a URDF model from a specified file path or file-like object. This is the primary method for initializing a URDF model within the library, with various options for controlling mesh loading and scene graph construction. ```APIDOC ## load(fname_or_file, **kwargs) ### Description Load URDF file from filename or file object. ### Parameters #### Path Parameters - **fname_or_file** (str or file object) - Required - A filename or file object, file-like object, stream representing the URDF file. #### Query Parameters - **build_scene_graph** (bool, optional) - Whether to build a scene graph to enable transformation queries and forward kinematics. Defaults to True. - **build_collision_scene_graph** (bool, optional) - Whether to build a scene graph for elements. Defaults to False. - **load_meshes** (bool, optional) - Whether to load the meshes referenced in the elements. Defaults to True. - **load_collision_meshes** (bool, optional) - Whether to load the collision meshes referenced in the elements. Defaults to False. - **filename_handler** (list[type], optional) - Any function f(in: str) -> str, that maps filenames in the URDF to actual resources. Can be used to customize treatment of package:// directives or relative/absolute filenames. Defaults to None. - **mesh_dir** (str, optional) - A root directory used for loading meshes. Defaults to “”. - **force_mesh** (bool, optional) - Each loaded geometry will be concatenated into a single one (instead of being turned into a graph; in case the underlying file contains multiple geometries). This might loose texture information but the resulting scene graph will be smaller. Defaults to False. - **force_collision_mesh** (bool, optional) - Same as force_mesh, but for collision scene. Defaults to True. ### Raises **ValueError** – If filename does not exist. ### Returns URDF model. ### Return type yourdfpy.URDF ``` -------------------------------- ### scene Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Provides access to a trimesh Scene object representing the URDF model. This allows for advanced visualization and manipulation of the robot's geometry. ```APIDOC ## scene ### Description A scene object representing the URDF model. ### Returns A trimesh scene object. ### Return type trimesh.Scene ``` -------------------------------- ### View Commit History Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Inspect the commit history to understand recurring communication patterns for writing descriptive commit messages. ```bash git log --graph --decorate --pretty=oneline --abbrev-commit --all ``` -------------------------------- ### Generate URDF Scene Visualizations Source: https://github.com/clemense/yourdfpy/blob/main/README.md Generates and saves images of URDF scenes. This code iterates through robot assets, loads them, sets up a camera, and saves the scene as a PNG image. It includes basic error handling for loading issues. ```python cam_rot = s.camera_transform robot_assets = glob.glob('/data/robot-assets/urdfs/robots/**/*.urdf') for i, fname in enumerate(robot_assets): try: s = yourdfpy.URDF.load(fname).scene cam_T = s.camera.look_at(points=s.convex_hull.vertices, rotation=cam_rot) # distance=2.6 s.camera_transform = cam_T png = s.save_image() with open(f"/tmp/test{i:02}.png", 'wb') as f: f.write(png) except Exception as e: print(e) ``` -------------------------------- ### filename_handler_add_prefix Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Adds a prefix to a given filename. ```APIDOC ## filename_handler_add_prefix(fname, prefix) ### Description Adds a prefix to a given filename. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fname** (str) - Required - A file name. * **prefix** (str) - Required - A prefix. ### Request Example None ### Response #### Success Response (200) * **Returns** (str) - Prefix plus file name. #### Response Example None ``` -------------------------------- ### apply_visual_color Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Applies the color of the visual material to a Trimesh object. ```APIDOC ## apply_visual_color(geom, visual, material_map) ### Description Applies the color of the visual material to a Trimesh object. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **geom** (Trimesh) - Required - Trimesh to color. * **visual** (yourdfpy.urdf.Visual) - Required - Visual description from XML. * **material_map** (Dict[str, yourdfpy.urdf.Material]) - Required - Dictionary mapping material names to their definitions. ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### yourdfpy.urdf.Robot Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents a URDF robot model, containing lists of links, joints, materials, transmissions, and Gazebo-specific elements. ```APIDOC ## class yourdfpy.urdf.Robot(name: str, links: List[yourdfpy.urdf.Link] = , joints: List[yourdfpy.urdf.Joint] = , materials: List[yourdfpy.urdf.Material] = , transmission: List[str] = , gazebo: List[str] = ) ### Description Represents a URDF robot model, containing lists of links, joints, materials, transmissions, and Gazebo-specific elements. ### Parameters * **name** (str) - The name of the robot. * **links** (List[yourdfpy.urdf.Link]) - A list of Link objects. * **joints** (List[yourdfpy.urdf.Joint]) - A list of Joint objects. * **materials** (List[yourdfpy.urdf.Material]) - A list of Material objects. * **transmission** (List[str]) - A list of transmission configurations. * **gazebo** (List[str]) - A list of Gazebo-specific configurations. ``` -------------------------------- ### Load URDFs and Measure Parsing Success Rate Source: https://github.com/clemense/yourdfpy/blob/main/docs/readme.md This function loads a list of URDF files using a provided loading function and reports the success rate. It's used to compare the robustness of different URDF parsing libraries. ```python robot_assets = ['robot-assets/urdfs/robots/barret_hand/bhand_model.URDF', 'robot-assets/urdfs/robots/robotiq_gripper/robotiq_arg85_description.URDF', 'robot-assets/urdfs/robots/anymal/anymal.urdf', 'robot-assets/urdfs/robots/franka_panda/panda.urdf', 'robot-assets/urdfs/robots/ginger_robot/gingerurdf.urdf', 'robot-assets/urdfs/robots/halodi/eve_r3.urdf', 'robot-assets/urdfs/robots/kinova/kinova.urdf', 'robot-assets/urdfs/robots/kuka_iiwa/model.urdf', 'robot-assets/urdfs/robots/pr2/pr2.urdf', 'robot-assets/urdfs/robots/ur10/ur10_robot.urdf', 'robot-assets/urdfs/robots/ur5/ur5_gripper.urdf', 'robot-assets/urdfs/robots/yumi/yumi.urdf'] import urdfpy import urdf_parser_py import yourdfpy from functools import partial def load_urdfs(fnames, load_fn): results = {fname: None for fname in fnames} for fname in fnames: try: x = load_fn(fname) results[fname] = x except: print("Problems loading: ", fname) pass print(sum([1 for x, y in results.items() if y is not None]), "/", len(fnames)) return results # parsing success rate load_urdfs(robot_assets, urdfpy.URDF.load) load_urdfs(robot_assets, urdf_parser_py.urdf.URDF.load) load_urdfs(robot_assets, yourdfpy.URDF.load) ``` -------------------------------- ### yourdfpy.urdf.URDF.center_cfg Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Calculates and returns the center configuration of the URDF model. It uses the average of each joint's limits if available, otherwise defaults to zero. ```APIDOC ## property center_cfg ### Description Return center configuration of URDF model by using the average of each joint’s limits if present, otherwise zero. ### Returns * **(n), float** - The default configuration of the URDF model. ``` -------------------------------- ### Run Pytest with Debugger Source: https://github.com/clemense/yourdfpy/blob/main/CONTRIBUTING.rst Execute a specific failing test with the --pdb option to enter an interactive debugging session upon error. ```bash tox -- -k --pdb ``` -------------------------------- ### Filename Handler Functions Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/modules.md Utility functions for handling filenames within URDF files. ```APIDOC ## filename_handler_absolute2relative(filename) ### Description Converts an absolute filename to a relative one. ### Method `filename_handler_absolute2relative(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The absolute filename. ### Response #### Success Response (str) Returns the relative filename. ``` ```APIDOC ## filename_handler_add_prefix(prefix) ### Description Creates a filename handler that adds a prefix to filenames. ### Method `filename_handler_add_prefix(prefix)` ### Parameters #### Path Parameters - **prefix** (str) - Required - The prefix to add. ### Response #### Success Response (function) Returns a filename handler function. ``` ```APIDOC ## filename_handler_ignore_directive(filename) ### Description Handles filenames by ignoring specific directives. ### Method `filename_handler_ignore_directive(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the handled filename. ``` ```APIDOC ## filename_handler_ignore_directive_package(filename) ### Description Handles filenames by ignoring package directives. ### Method `filename_handler_ignore_directive_package(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the handled filename. ``` ```APIDOC ## filename_handler_magic(filename) ### Description Applies a magic handler to filenames. ### Method `filename_handler_magic(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the handled filename. ``` ```APIDOC ## filename_handler_meta(filename) ### Description Handles filenames using meta information. ### Method `filename_handler_meta(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the handled filename. ``` ```APIDOC ## filename_handler_null(filename) ### Description A null filename handler that returns the filename unchanged. ### Method `filename_handler_null(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the original filename. ``` ```APIDOC ## filename_handler_relative(filename) ### Description Handles filenames by ensuring they are relative. ### Method `filename_handler_relative(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The filename to handle. ### Response #### Success Response (str) Returns the relative filename. ``` -------------------------------- ### write_xml_file Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Writes the URDF model to an XML file. ```APIDOC ## write_xml_file(fname) ### Description Writes the URDF model to an XML file. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fname** (str) - Required - Filename of the file to be written. Usually ends in .urdf. ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### yourdfpy.urdf.filename_handler_meta Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A filename handler that calls other filename handlers until the resulting file name points to an existing file. It takes a filename and a list of handler functions, returning the resolved filename or the input if no file is found. ```APIDOC ## yourdfpy.urdf.filename_handler_meta(fname, filename_handlers) ### Description A filename handler that calls other filename handlers until the resulting file name points to an existing file. ### Parameters #### Path Parameters * **fname** (str) - Required - A file name. * **filename_handlers** (list[fn]) - Required - A list of function pointers to filename handlers. ### Returns #### Success Response - **str** - The resolved file name that points to an existing file or the input if none of the files exists. ``` -------------------------------- ### yourdfpy.viz.generate_joint_limit_trajectory Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Generates a trajectory for all actuated joints by interpolating between their limits. For continuous joints, it interpolates between 0 and 2*pi. ```APIDOC ## yourdfpy.viz.generate_joint_limit_trajectory(urdf_model, loop_time) ### Description Generate a trajectory for all actuated joints that interpolates between joint limits. For continuous joint interpolate between [0, 2 * pi]. ### Parameters #### Path Parameters * **urdf_model** (yourdfpy.URDF) - Required - * **loop_time** (float) - Required - Time in seconds to loop through the trajectory. ### Returns #### Success Response - **dict** - A dictionary over all actuated joints with list of configuration values. ``` -------------------------------- ### URDF Filename Handlers Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/modules.md Functions for handling URDF filenames, including relative paths and recursive searching. ```APIDOC ## filename_handler_relative_to_urdf_file() ### Description Handles URDF filenames relative to the URDF file's location. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` ```APIDOC ## filename_handler_relative_to_urdf_file_recursive() ### Description Recursively handles URDF filenames relative to the URDF file's location. ### Method N/A (Python function) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### filename_handler_magic Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A general-purpose filename handler that attempts to resolve a filename, returning the input if no resolution is found. ```APIDOC ## filename_handler_magic(fname, dir) ### Description A general-purpose filename handler that attempts to resolve a filename, returning the input if no resolution is found. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fname** (str) - Required - A file name. * **dir** (str) - Required - A directory. ### Request Example None ### Response #### Success Response (200) * **Returns** (str) - The file name that exists or the input if nothing is found. #### Response Example None ``` -------------------------------- ### yourdfpy.urdf.filename_handler_relative Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A filename handler that joins a given filename with a specified directory. ```APIDOC ## yourdfpy.urdf.filename_handler_relative(fname, dir) ### Description A filename handler that joins a file name with a directory. ### Parameters #### Path Parameters * **fname** (str) - Required - A file name. * **dir** (str) - Required - A directory. ### Returns #### Success Response - **str** - The directory joined with the file name. ``` -------------------------------- ### write_xml Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Writes the URDF model to an XML element hierarchy. ```APIDOC ## write_xml() ### Description Writes the URDF model to an XML element hierarchy. ### Parameters None ### Request Example None ### Response #### Success Response (200) * **Returns** (etree.ElementTree) - XML data. #### Response Example None ``` -------------------------------- ### update_cfg Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Updates the joint configuration of a URDF model and performs forward kinematics. It accepts a dictionary, list, tuple, or numpy array for the configuration. ```APIDOC ## update_cfg(configuration) ### Description Updates the joint configuration of a URDF model and performs forward kinematics. It accepts a dictionary, list, tuple, or numpy array for the configuration. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **configuration** (dict, list[float], tuple[float], np.ndarray) - Required - A mapping from joints or joint names to configuration values, or a list containing a value for each actuated joint. ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### Errors * **ValueError**: Raised if dimensionality of configuration does not match number of actuated joints of URDF model. * **TypeError**: Raised if configuration is neither a dict, list, tuple or np.ndarray. ``` -------------------------------- ### yourdfpy.urdf.filename_handler_null Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A lazy filename handler that simply returns its input filename. ```APIDOC ## yourdfpy.urdf.filename_handler_null(fname) ### Description A lazy filename handler that simply returns its input. ### Parameters #### Path Parameters * **fname** (str) - Required - A file name. ### Returns #### Success Response - **str** - Same file name. ``` -------------------------------- ### yourdfpy.urdf.URDF.collision_scene Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Provides a trimesh Scene object representing the collision elements defined in the URDF model. ```APIDOC ## property collision_scene ### Description A scene object representing the elements of the URDF model. ### Returns * **trimesh.Scene** - A trimesh scene object containing collision geometry. ``` -------------------------------- ### filename_handler_ignore_directive Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Removes any directive prefix (e.g., '://') from a filename. ```APIDOC ## filename_handler_ignore_directive(fname) ### Description Removes any directive prefix (e.g., '://') from a filename. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fname** (str) - Required - A file name. ### Request Example None ### Response #### Success Response (200) * **Returns** (str) - The file name without the prefix. #### Response Example None ``` -------------------------------- ### URDF Class Methods Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/modules.md Methods available on the URDF class for loading, validating, and manipulating URDF data. ```APIDOC ## URDF.clear_errors() ### Description Clears any accumulated errors in the URDF object. ### Method `clear_errors()` ### Parameters None ### Response None ``` ```APIDOC ## URDF.contains(element_name) ### Description Checks if a URDF element with the given name exists. ### Method `contains(element_name)` ### Parameters #### Path Parameters - **element_name** (str) - Required - The name of the element to check for. ### Response #### Success Response (bool) Returns True if the element exists, False otherwise. ``` ```APIDOC ## URDF.get_transform(link_name) ### Description Retrieves the transformation matrix for a given link. ### Method `get_transform(link_name)` ### Parameters #### Path Parameters - **link_name** (str) - Required - The name of the link. ### Response #### Success Response (numpy.ndarray) Returns the 4x4 transformation matrix. ``` ```APIDOC ## URDF.load(filename) ### Description Loads URDF data from a file. ### Method `load(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The path to the URDF file. ### Response None ``` ```APIDOC ## URDF.show() ### Description Displays a visual representation of the URDF model. ### Method `show()` ### Parameters None ### Response None ``` ```APIDOC ## URDF.split_along_joints(joint_names) ### Description Splits the URDF model into multiple URDF objects along specified joints. ### Method `split_along_joints(joint_names)` ### Parameters #### Path Parameters - **joint_names** (list[str]) - Required - A list of joint names to split along. ### Response #### Success Response (list[URDF]) Returns a list of URDF objects. ``` ```APIDOC ## URDF.update_cfg(cfg) ### Description Updates the configuration of the URDF model. ### Method `update_cfg(cfg)` ### Parameters #### Path Parameters - **cfg** (numpy.ndarray) - Required - The new configuration array. ### Response None ``` ```APIDOC ## URDF.validate() ### Description Validates the URDF model for correctness and consistency. ### Method `validate()` ### Parameters None ### Response #### Success Response (list[URDFError]) Returns a list of validation errors, or an empty list if valid. ``` ```APIDOC ## URDF.validate_filenames() ### Description Validates that all filenames referenced in the URDF are accessible. ### Method `validate_filenames()` ### Parameters None ### Response #### Success Response (list[URDFError]) Returns a list of filename validation errors, or an empty list if all are valid. ``` ```APIDOC ## URDF.write_xml(filename) ### Description Writes the URDF model to an XML file. ### Method `write_xml(filename)` ### Parameters #### Path Parameters - **filename** (str) - Required - The path to the output XML file. ### Response None ``` ```APIDOC ## URDF.write_xml_file(file_obj) ### Description Writes the URDF model to an XML file object. ### Method `write_xml_file(file_obj)` ### Parameters #### Path Parameters - **file_obj** (file object) - Required - The file object to write to. ### Response None ``` ```APIDOC ## URDF.write_xml_string() ### Description Returns the URDF model as an XML string. ### Method `write_xml_string()` ### Parameters None ### Response #### Success Response (str) Returns the URDF model as an XML string. ``` -------------------------------- ### write_xml_string Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Writes the URDF model to a string. ```APIDOC ## write_xml_string(**kwargs) ### Description Writes the URDF model to a string. ### Parameters None ### Request Example None ### Response #### Success Response (200) * **Returns** (str) - String of the xml representation of the URDF model. #### Response Example None ``` -------------------------------- ### yourdfpy.urdf.Actuator Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents an actuator in a URDF model, including its name, mechanical reduction, and hardware interfaces. ```APIDOC ## class yourdfpy.urdf.Actuator ### Description Represents an actuator in a URDF model. ### Attributes * **name** (str) - The name of the actuator. * **mechanical_reduction** (float | None) - The mechanical reduction ratio of the actuator. * **hardware_interfaces** (List[str]) - A list of hardware interfaces the actuator uses. ``` -------------------------------- ### get_transform Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Retrieves the homogeneous transformation matrix between two specified frames. This is crucial for kinematic calculations and understanding the spatial relationships between different parts of the robot model. ```APIDOC ## get_transform(frame_to, frame_from=None, collision_geometry=False) ### Description Get the transform from one frame to another. ### Parameters #### Path Parameters - **frame_to** (str) - Required - Node name. - **frame_from** (str, optional) - Node name. If None it will be set to self.base_frame. Defaults to None. - **collision_geometry** (bool, optional) - Whether to use the collision geometry scene graph (instead of the visual geometry). Defaults to False. ### Raises **ValueError** – Raised if scene graph wasn’t constructed during intialization. ### Returns Homogeneous transformation matrix ### Return type (4, 4) float ``` -------------------------------- ### yourdfpy.urdf.SafetyController Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Defines safety controller parameters for a joint, including soft limits and gains for position and velocity. ```APIDOC ## class yourdfpy.urdf.SafetyController(soft_lower_limit: float | None = None, soft_upper_limit: float | None = None, k_position: float | None = None, k_velocity: float | None = None) ### Description Defines safety controller parameters for a joint, including soft limits and gains for position and velocity. ### Parameters * **soft_lower_limit** (float | None) - The soft lower limit for the joint. * **soft_upper_limit** (float | None) - The soft upper limit for the joint. * **k_position** (float | None) - The proportional gain for position control. * **k_velocity** (float | None) - The proportional gain for velocity control. ``` -------------------------------- ### yourdfpy.urdf.Calibration Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents calibration parameters for a joint in a URDF model. ```APIDOC ## class yourdfpy.urdf.Calibration ### Description Represents calibration parameters for a joint. ### Attributes * **rising** (float | None) - The rising value for calibration. * **falling** (float | None) - The falling value for calibration. ``` -------------------------------- ### yourdfpy.urdf.URDF.base_link Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Retrieves the name of the base or root link of the URDF model. ```APIDOC ## property base_link ### Description Name of URDF base/root link. ### Returns * **str** - The name of the base link of the URDF model. ``` -------------------------------- ### yourdfpy.urdf.Dynamics Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents dynamic properties of a joint in a URDF model. ```APIDOC ## class yourdfpy.urdf.Dynamics ### Description Represents dynamic properties of a joint. ### Attributes * **damping** (float | None) - The damping coefficient. * **friction** (float | None) - The friction coefficient. ``` -------------------------------- ### yourdfpy.urdf.Mimic Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Defines a mimic joint relationship, where one joint's movement mimics another's with optional multiplier and offset. ```APIDOC ## class yourdfpy.urdf.Mimic(joint: str, multiplier: float | None = None, offset: float | None = None) ### Description Defines a mimic joint relationship, where one joint's movement mimics another's with optional multiplier and offset. ### Parameters * **joint** (str) - The name of the joint to mimic. * **multiplier** (float | None) - An optional multiplier for the mimicked joint's movement. * **offset** (float | None) - An optional offset for the mimicked joint's movement. ``` -------------------------------- ### num_dofs Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Provides the number of degrees of freedom (DOFs) for the actuated joints in the URDF model. The number of DOFs can vary based on the joint type. ```APIDOC ## num_dofs ### Description Number of degrees of freedom of actuated joints. Depending on the type of the joint, the number of DOFs might vary. ### Returns Degrees of freedom. ### Return type int ``` -------------------------------- ### yourdfpy.urdf.Inertial Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents the inertial properties of a link in a URDF model. ```APIDOC ## class yourdfpy.urdf.Inertial ### Description Represents inertial properties of a link. ### Attributes * **origin** (numpy.ndarray | None) - The origin (pose) of the inertial frame. * **mass** (float | None) - The mass of the link. * **inertia** (numpy.ndarray | None) - The inertia tensor. ``` -------------------------------- ### Measure URDF Parsing Times Source: https://github.com/clemense/yourdfpy/blob/main/docs/readme.md This code measures the time taken to parse a list of URDF files using different libraries and configurations. It includes a specific test for yourdfpy with mesh loading disabled. ```python # parsing times %timeit load_urdfs(robot_assets, urdfpy.URDF.load) %timeit load_urdfs(robot_assets, urdf_parser_py.urdf.URDF.load) %timeit load_urdfs(robot_assets, yourdfpy.URDF.load) %timeit load_urdfs(robot_assets, partial(yourdfpy.URDF.load, load_meshes=False, build_scene_graph=False)) ``` -------------------------------- ### link_map Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md A dictionary mapping link names to their corresponding link objects. This property facilitates direct access to link information within the URDF structure. ```APIDOC ## link_map ### Description A dictionary mapping link names to link objects. ### Returns Mapping from link name (str) to Link. ### Return type dict ``` -------------------------------- ### filename_handler_ignore_directive_package Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Removes the 'package://' directive and its associated package name from a filename, and then removes any other directives. ```APIDOC ## filename_handler_ignore_directive_package(fname) ### Description Removes the 'package://' directive and its associated package name from a filename, and then removes any other directives. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **fname** (str) - Required - A file name. ### Request Example None ### Response #### Success Response (200) * **Returns** (str) - The file name without 'package://' and the package name. #### Response Example None ``` -------------------------------- ### apply_visual_color Function Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/modules.md Applies a color to a visual element in the URDF. ```APIDOC ## apply_visual_color(visual, color) ### Description Applies a specified color to a URDF visual element. ### Method `apply_visual_color(visual, color)` ### Parameters #### Path Parameters - **visual** (Visual) - Required - The visual element to color. - **color** (list[float]) - Required - A list of four floats representing RGBA color values (0.0 to 1.0). ### Response None ``` -------------------------------- ### yourdfpy.urdf.Texture Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents a texture resource in the URDF model, storing the filename of the texture image. ```APIDOC ## class yourdfpy.urdf.Texture(filename: str) ### Description Represents a texture resource in the URDF model, storing the filename of the texture image. ### Parameters * **filename** (str) - The path to the texture image file. ``` -------------------------------- ### yourdfpy.urdf.Mesh Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents a mesh resource in the URDF model. It stores the filename of the mesh and an optional scale factor. ```APIDOC ## class yourdfpy.urdf.Mesh(filename: str, scale: float | numpy.ndarray | NoneType = None) ### Description Represents a mesh resource in the URDF model. It stores the filename of the mesh and an optional scale factor. ### Parameters * **filename** (str) - The path to the mesh file. * **scale** (float | numpy.ndarray | None) - An optional scaling factor to apply to the mesh. ``` -------------------------------- ### yourdfpy.urdf.URDF.actuated_joints Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Retrieves a list of actuated joint objects from the URDF model, excluding mimic and fixed joints. ```APIDOC ## property actuated_joints ### Description List of actuated joints. This excludes mimic and fixed joints. ### Returns * **list[yourdfpy.urdf.Joint]** - A list of actuated Joint objects. ``` -------------------------------- ### yourdfpy.urdf.Link Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents a link in a URDF model, which can have inertial, visual, and collision properties. ```APIDOC ## class yourdfpy.urdf.Link ### Description Represents a link. ### Attributes * **name** (str) - The name of the link. * **inertial** (yourdfpy.urdf.Inertial | None) - The inertial properties of the link. * **visuals** (List[yourdfpy.urdf.Visual]) - A list of visual elements for the link. * **collisions** (List[yourdfpy.urdf.Collision]) - A list of collision elements for the link. ``` -------------------------------- ### yourdfpy.urdf.Box Source: https://github.com/clemense/yourdfpy/blob/main/docs/api/yourdfpy.md Represents a box geometry in a URDF model. ```APIDOC ## class yourdfpy.urdf.Box ### Description Represents a box geometry. ### Attributes * **size** (numpy.ndarray) - The dimensions of the box. ```