diff --git a/.github/workflows/python_publish_linux.yml b/.github/workflows/python_publish_linux.yml index 46c351525..945e9d732 100644 --- a/.github/workflows/python_publish_linux.yml +++ b/.github/workflows/python_publish_linux.yml @@ -35,7 +35,5 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel - twine upload dist/*.gz twine upload wheelhouse/*manylinux* diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index df13a5583..0183d9179 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/upload_tar.yml b/.github/workflows/upload_tar.yml new file mode 100644 index 000000000..e7a8b983a --- /dev/null +++ b/.github/workflows/upload_tar.yml @@ -0,0 +1,36 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# name: Upload tar to PyPI + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + deploy: + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 2 + matrix: + os: [ubuntu-latest] + python-version: [3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/*.gz diff --git a/roboticstoolbox/examples/tripleangledemo.py b/roboticstoolbox/examples/tripleangledemo.py index 3009ecec0..a6d1055f9 100644 --- a/roboticstoolbox/examples/tripleangledemo.py +++ b/roboticstoolbox/examples/tripleangledemo.py @@ -11,30 +11,33 @@ from spatialmath import SO3, SE3 import numpy as np - -# TODO -# rotate the rings according to the rotation axis, so that the axles -# point the right way - -# Launch the simulator Swift -env = swift.Swift() -env.launch() - path = rtb.rtb_path_to_datafile("data") +# rotation angle sequence +sequence = "ZYX" + +# compute the three rotation matrices +BASE = SE3(0, 0, 0.5) +R1 = SO3() +R2 = SO3() +R3 = SO3() g1 = Mesh( - filename=str(path / "gimbal-ring1.stl"), color=[34, 143, 201], scale=(1.0 / 3,) * 3 + filename=str(path / "gimbal-ring1.stl"), + color=[34, 143, 201], + scale=(1.0 / 3,) * 3, ) g2 = Mesh( - filename=str(path / "gimbal-ring2.stl"), color=[31, 184, 72], scale=(1.1 / 3,) * 3 + filename=str(path / "gimbal-ring2.stl"), + color=[31, 184, 72], + scale=(1.1 / 3,) * 3, ) g3 = Mesh( filename=str(path / "gimbal-ring3.stl"), color=[240, 103, 103], - scale=(1.1**2 / 3,) * 3, + scale=(1.1 ** 2 / 3,) * 3, ) plane = Mesh( @@ -42,23 +45,6 @@ scale=(1.0 / (180 * 3),) * 3, color=[240, 103, 103], ) -print(path / "spitfire_assy-gear_up.stl") -env.add(g1) -env.add(g2) -env.add(g3) -env.add(plane) - -print("Supermarine Spitfire Mk VIII by Ed Morley @GRABCAD") -print("Gimbal models by Peter Corke using OpenSCAD") - -# compute the three rotation matrices -BASE = SE3(0, 0, 0.5) -R1 = SO3() -R2 = SO3() -R3 = SO3() - -# rotation angle sequence -sequence = "ZYX" def update_gimbals(theta, ring): @@ -92,140 +78,159 @@ def convert(R): plane.T = convert(R1 * R2 * R3 * SO3.Ry(pi / 2) * SO3.Rz(pi / 2)) -# slider call backs, invoke the central handler -def set_one(x): - update_gimbals(float(x), 1) - - -def set_two(x): - update_gimbals(float(x), 2) - - -def set_three(x): - update_gimbals(float(x), 3) +def demo(): + # TODO + # rotate the rings according to the rotation axis, so that the axles + # point the right way + # Launch the simulator Swift + env = swift.Swift() + env.launch() -r_one = swift.Slider( - set_one, min=-180, max=180, step=1, value=0, desc="Outer gimbal", unit="°" -) + print(path / "spitfire_assy-gear_up.stl") + env.add(g1) + env.add(g2) + env.add(g3) + env.add(plane) + print("Supermarine Spitfire Mk VIII by Ed Morley @GRABCAD") + print("Gimbal models by Peter Corke using OpenSCAD") -r_two = swift.Slider( - set_two, min=-180, max=180, step=1, value=0, desc="Middle gimbal", unit="°" -) + # slider call backs, invoke the central handler + def set_one(x): + update_gimbals(float(x), 1) + def set_two(x): + update_gimbals(float(x), 2) -r_three = swift.Slider( - set_three, min=-180, max=180, step=1, value=0, desc="Inner gimbal", unit="°" -) + def set_three(x): + update_gimbals(float(x), 3) + r_one = swift.Slider( + set_one, min=-180, max=180, step=1, value=0, desc="Outer gimbal", unit="°" + ) -# buttons to set a 3-angle sequence -ZYX_button = swift.Button( - lambda x: change_sequence("ZYX"), desc="ZYX (roll-pitch-yaw angles)" -) + r_two = swift.Slider( + set_two, min=-180, max=180, step=1, value=0, desc="Middle gimbal", unit="°" + ) -XYZ_button = swift.Button( - lambda x: change_sequence("XYZ"), desc="XYZ (roll-pitch-yaw angles)" -) + r_three = swift.Slider( + set_three, + min=-180, + max=180, + step=1, + value=0, + desc="Inner gimbal", + unit="°", + ) -ZYZ_button = swift.Button(lambda x: change_sequence("ZYZ"), desc="ZYZ (Euler angles)") + # buttons to set a 3-angle sequence + ZYX_button = swift.Button( + lambda x: change_sequence("ZYX"), desc="ZYX (roll-pitch-yaw angles)" + ) -button = swift.Button(lambda x: set("ZYX"), desc="Set to Zero") + XYZ_button = swift.Button( + lambda x: change_sequence("XYZ"), desc="XYZ (roll-pitch-yaw angles)" + ) + ZYZ_button = swift.Button( + lambda x: change_sequence("ZYZ"), desc="ZYZ (Euler angles)" + ) -# button to reset joint angles -def reset(e): - r_one.value = 0 - r_two.value = 0 - r_three.value = 0 - # env.step(0) + button = swift.Button(lambda x: set("ZYX"), desc="Set to Zero") + # button to reset joint angles + def reset(e): + r_one.value = 0 + r_two.value = 0 + r_three.value = 0 + # env.step(0) -zero_button = swift.Button(reset, desc="Set to Zero") - - -def update_all_sliders(): - update_gimbals(float(r_one.value), 1) - update_gimbals(float(r_two.value), 2) - update_gimbals(float(r_three.value), 3) - + zero_button = swift.Button(reset, desc="Set to Zero") -def change_sequence(new): - global sequence + def update_all_sliders(): + update_gimbals(float(r_one.value), 1) + update_gimbals(float(r_two.value), 2) + update_gimbals(float(r_three.value), 3) - xyz = "XYZ" + def change_sequence(new): + global sequence - # update the state of the ring_axis dropdowns - ring1_axis.checked = xyz.find(new[0]) - ring2_axis.checked = xyz.find(new[1]) - ring3_axis.checked = xyz.find(new[2]) + xyz = "XYZ" - sequence = new - update_all_sliders() + # update the state of the ring_axis dropdowns + ring1_axis.checked = xyz.find(new[0]) + ring2_axis.checked = xyz.find(new[1]) + ring3_axis.checked = xyz.find(new[2]) + sequence = new + update_all_sliders() -# handle radio button on angle slider -def angle(index, ring): - global sequence + # handle radio button on angle slider + def angle(index, ring): + global sequence - # print('angle', index, ring) - xyz = "XYZ" - s = list(sequence) - s[ring] = xyz[int(index)] - sequence = "".join(s) - update_all_sliders() + # print('angle', index, ring) + xyz = "XYZ" + s = list(sequence) + s[ring] = xyz[int(index)] + sequence = "".join(s) + update_all_sliders() + ring1_axis = swift.Radio(lambda x: angle(x, 0), options=["X", "Y", "Z"], checked=2) -ring1_axis = swift.Radio(lambda x: angle(x, 0), options=["X", "Y", "Z"], checked=2) + ring2_axis = swift.Radio(lambda x: angle(x, 1), options=["X", "Y", "Z"], checked=1) -ring2_axis = swift.Radio(lambda x: angle(x, 1), options=["X", "Y", "Z"], checked=1) + ring3_axis = swift.Radio(lambda x: angle(x, 2), options=["X", "Y", "Z"], checked=0) -ring3_axis = swift.Radio(lambda x: angle(x, 2), options=["X", "Y", "Z"], checked=0) + label = swift.Label(desc="Triple angle") + def chekked(e, el): + nlabel = "s: " -label = swift.Label(desc="Triple angle") + if e[0]: + nlabel += "a" + r_one.value = 0 + if e[1]: + nlabel += "b" + r_two.value = 0 -def chekked(e, el): - nlabel = "s: " + if e[2]: + nlabel += "c" + r_three.value = 0 - if e[0]: - nlabel += "a" - r_one.value = 0 + if e[3]: + el.value = 1 - if e[1]: - nlabel += "b" - r_two.value = 0 + label.desc = nlabel - if e[2]: - nlabel += "c" - r_three.value = 0 + env.add(label) + env.add(r_one) + env.add(ring1_axis) - if e[3]: - el.value = 1 + env.add(r_two) + env.add(ring2_axis) - label.desc = nlabel + env.add(r_three) + env.add(ring3_axis) + env.add(ZYX_button) + env.add(XYZ_button) + env.add(ZYZ_button) + env.add(zero_button) -env.add(label) -env.add(r_one) -env.add(ring1_axis) + update_gimbals(0, 1) + update_gimbals(0, 2) + update_gimbals(0, 3) -env.add(r_two) -env.add(ring2_axis) + while True: + env.step(0) -env.add(r_three) -env.add(ring3_axis) -env.add(ZYX_button) -env.add(XYZ_button) -env.add(ZYZ_button) -env.add(zero_button) +def main(): + demo() -update_gimbals(0, 1) -update_gimbals(0, 2) -update_gimbals(0, 3) -while True: - env.step(0) +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index c58292735..7fc06f801 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,7 @@ def package_files(directory): setup( name="roboticstoolbox-python", - version="1.0.0", + version="1.0.1", description="A Python library for robotic education and research", long_description=long_description, long_description_content_type="text/markdown", @@ -136,7 +136,7 @@ def package_files(directory): entry_points={ "console_scripts": [ "eigdemo=roboticstoolbox.examples.eigdemo:main", - "tripleangledemo=roboticstoolbox.examples.tripleangledemo", + "tripleangledemo=roboticstoolbox.examples.tripleangledemo:main", "twistdemo=roboticstoolbox.examples.twistdemo:main", ] },