-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from open-dynamic-robot-initiative/fkloss/py
Convert to Python package
- Loading branch information
Showing
66 changed files
with
155 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Install package via pip and run tests | ||
name: Tests (pip install) | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: Update pip | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Install package | ||
run: | | ||
python -m pip install ".[test]" | ||
- name: Run tests | ||
run: | | ||
python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.pyc | ||
urdf/* | ||
.DS_Store | ||
build/ | ||
*.egg-info | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>robot_properties_fingers</name> | ||
<version>1.1.0</version> | ||
<version>1.2.0</version> | ||
<description>Xacro files and meshes of the (Tri-)Finger robots.</description> | ||
<maintainer email="[email protected]">Felix Widmaier</maintainer> | ||
<license>BSD 3-clause</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<license>BSD-3-Clause</license> | ||
|
||
<!-- We need the xacro package to build the urdf model --> | ||
<build_depend>xacro</build_depend> | ||
|
||
<exec_depend>pinocchio</exec_depend> | ||
|
||
<test_depend>ament_cmake_pytest</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/robot_properties_fingers | ||
[install] | ||
install_scripts=$base/lib/robot_properties_fingers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""Setup script for the robot_properties_fingers package.""" | ||
|
||
import pathlib | ||
from os import path | ||
|
||
from setuptools import find_packages, setup | ||
from setuptools.command.build_py import build_py | ||
|
||
import xacro | ||
|
||
package_name = "robot_properties_fingers" | ||
|
||
|
||
class CustomBuildCommand(build_py): | ||
"""Custom build command to process xacro files.""" | ||
|
||
def run(self) -> None: | ||
"""Run the build command.""" | ||
# Call the original build_py command | ||
build_py.run(self) | ||
|
||
# Define the paths | ||
xacro_dir = pathlib.Path("xacro_files") | ||
urdf_dir = pathlib.Path(self.build_lib) / package_name / "urdf" | ||
|
||
# Process each xacro file | ||
for xacro_file in xacro_dir.glob("**/*.xacro"): | ||
relative_urdf_path = xacro_file.relative_to(xacro_dir).with_suffix("") | ||
urdf_file = urdf_dir / relative_urdf_path | ||
|
||
# ensure output directory exists | ||
urdf_file.parent.mkdir(parents=True, exist_ok=True) | ||
|
||
# Use xacro API to process the file | ||
doc = xacro.process_file(str(xacro_file)) | ||
urdf_content = doc.toprettyxml(indent=" ") | ||
urdf_file.write_text(urdf_content) | ||
|
||
|
||
setup( | ||
name=package_name, | ||
version="1.2.0", | ||
packages=find_packages(where="src"), | ||
package_dir={"": "src"}, | ||
package_data={"robot_properties_fingers": ["meshes/*.stl", "meshes/**/*.stl"]}, | ||
data_files=[ | ||
( | ||
"share/ament_index/resource_index/packages", | ||
[path.join("resource", package_name)], | ||
), | ||
( | ||
path.join("share", package_name), | ||
["package.xml"], | ||
), | ||
], | ||
install_requires=[ | ||
"setuptools", | ||
"xacro", | ||
"pin", # pinocchio | ||
], | ||
extras_require={"test": ["pytest"]}, | ||
zip_safe=True, | ||
maintainer="Felix Kloss", | ||
maintainer_email="[email protected]", | ||
description="Xacro files and meshes of the (Tri-)Finger robots.", | ||
license="BSD-3-Clause", | ||
tests_require=["pytest"], | ||
entry_points={ | ||
"console_scripts": [], | ||
}, | ||
cmdclass={"build_py": CustomBuildCommand}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.