roarm-ik 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roarm_ik-0.1.0/LICENSE +21 -0
- roarm_ik-0.1.0/PKG-INFO +23 -0
- roarm_ik-0.1.0/README.md +8 -0
- roarm_ik-0.1.0/examples/basic.py +6 -0
- roarm_ik-0.1.0/examples/draw_square.py +30 -0
- roarm_ik-0.1.0/pyproject.toml +25 -0
- roarm_ik-0.1.0/roarm_ik/__init__.py +1 -0
- roarm_ik-0.1.0/roarm_ik/arm.py +100 -0
- roarm_ik-0.1.0/roarm_ik.egg-info/PKG-INFO +23 -0
- roarm_ik-0.1.0/roarm_ik.egg-info/SOURCES.txt +12 -0
- roarm_ik-0.1.0/roarm_ik.egg-info/dependency_links.txt +1 -0
- roarm_ik-0.1.0/roarm_ik.egg-info/top_level.txt +3 -0
- roarm_ik-0.1.0/setup.cfg +4 -0
- roarm_ik-0.1.0/setup.py +12 -0
roarm_ik-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HootSoon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
roarm_ik-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roarm-ik
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library for the WaveShare Ro-arm m3 adding inverse kinematics functionality wrapping the roarmsdk
|
|
5
|
+
Author: HootSoon: Hudson Reeves
|
|
6
|
+
Author-email: Your Name <your.email@example.com>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# roarm-ik-solver
|
|
17
|
+
|
|
18
|
+
[](https://badge.fury.io/py/roarm-kinematics)
|
|
19
|
+
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
|
|
21
|
+
A full 3D Spatial (XYZ) Inverse Kinematics engine for the Waveshare RoArm-M3 desktop robot arm.
|
|
22
|
+
|
|
23
|
+
|
roarm_ik-0.1.0/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# roarm-ik-solver
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/roarm-kinematics)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A full 3D Spatial (XYZ) Inverse Kinematics engine for the Waveshare RoArm-M3 desktop robot arm.
|
|
7
|
+
|
|
8
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from roarm_ik import Arm
|
|
2
|
+
|
|
3
|
+
def main():
|
|
4
|
+
print("Connecting to RoArm-M3...")
|
|
5
|
+
arm = Arm(port="/dev/ttyUSB0")
|
|
6
|
+
|
|
7
|
+
print("Moving to start of square...")
|
|
8
|
+
# Move to the bottom-left corner of the square before drawing
|
|
9
|
+
arm.move_to_xyz(0, 10, -5, 5, wait=True)
|
|
10
|
+
|
|
11
|
+
print("Drawing 10x10 square in the Y-Z plane...")
|
|
12
|
+
# draw_line(phi, x1, y1, z1, x2, y2, z2)
|
|
13
|
+
|
|
14
|
+
# Bottom edge (Right to Left)
|
|
15
|
+
arm.draw_line(0, 10, -5, 5, 10, 5, 5)
|
|
16
|
+
|
|
17
|
+
# Right edge (Bottom to Top)
|
|
18
|
+
arm.draw_line(0, 10, 5, 5, 10, 5, 15)
|
|
19
|
+
|
|
20
|
+
# Top edge (Left to Right)
|
|
21
|
+
arm.draw_line(0, 10, 5, 15, 10, -5, 15)
|
|
22
|
+
|
|
23
|
+
# Left edge (Top to Bottom)
|
|
24
|
+
arm.draw_line(0, 10, -5, 15, 10, -5, 5)
|
|
25
|
+
|
|
26
|
+
print("Square complete. Returning to center.")
|
|
27
|
+
arm.move_to_xyz(0, 10, 0, 10, wait=True)
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
main()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "roarm-ik"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Your Name", email = "your.email@example.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "A Python library for the WaveShare Ro-arm m3 adding inverse kinematics functionality wrapping the roarmsdk"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
# Add any dependencies your library needs here, for example:
|
|
21
|
+
# "numpy",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["."] # Tells it to look for your Python package folder in the root
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .arm import Arm
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from roarm_sdk.roarm import roarm
|
|
2
|
+
import math
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
class Arm(roarm):
|
|
6
|
+
'''
|
|
7
|
+
RoArm IK solver & SDK Communication wrapper
|
|
8
|
+
'''
|
|
9
|
+
def __init__(self, port="/dev/ttyUSB0", baudrate=115200):
|
|
10
|
+
super().__init__(roarm_type="roarm_m3", port=port, baudrate=baudrate)
|
|
11
|
+
|
|
12
|
+
self.r1 = 10
|
|
13
|
+
self.r2 = 7.5
|
|
14
|
+
self.r3 = 7
|
|
15
|
+
|
|
16
|
+
#Store X,Y,Z and Phi
|
|
17
|
+
self.pos = [0, 0, 0, 0]
|
|
18
|
+
self.angles = [0, 0, 90, 0, 0, 10]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def generate_ik(self, phi, x, y, z):
|
|
24
|
+
self.pos[0] = x
|
|
25
|
+
self.pos[1] = y
|
|
26
|
+
self.pos[2] = z
|
|
27
|
+
self.pos[3] = phi
|
|
28
|
+
|
|
29
|
+
phi_rad = math.radians(phi)
|
|
30
|
+
base_angle_rad = math.atan2(y, x)
|
|
31
|
+
R = math.sqrt(math.pow(x, 2) + math.pow(y, 2))
|
|
32
|
+
|
|
33
|
+
D3x = R
|
|
34
|
+
D3y = z
|
|
35
|
+
|
|
36
|
+
D2x = D3x - self.r3 * math.cos(phi_rad)
|
|
37
|
+
D2y = D3y - self.r3 * math.sin(phi_rad)
|
|
38
|
+
|
|
39
|
+
d = math.sqrt(math.pow(D2x, 2) + math.pow(D2y, 2))
|
|
40
|
+
|
|
41
|
+
if d > (self.r1 + self.r2):
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
a = math.atan2(D2y, D2x)
|
|
45
|
+
b = math.acos((math.pow(self.r1, 2) + math.pow(d, 2) - math.pow(self.r2, 2)) / (2 * self.r1 * d))
|
|
46
|
+
|
|
47
|
+
math_theta1 = a + b
|
|
48
|
+
|
|
49
|
+
inner_elbow = math.acos((math.pow(self.r1, 2) + math.pow(self.r2, 2) - math.pow(d, 2)) / (2 * self.r1 * self.r2))
|
|
50
|
+
math_theta2 = math.pi - inner_elbow
|
|
51
|
+
|
|
52
|
+
robot_shoulder = (math.pi / 2) - math_theta1
|
|
53
|
+
robot_elbow = math_theta2
|
|
54
|
+
|
|
55
|
+
robot_shoulder_deg = math.degrees(robot_shoulder)
|
|
56
|
+
robot_elbow_deg = math.degrees(robot_elbow)
|
|
57
|
+
robot_base_deg = math.degrees(base_angle_rad)
|
|
58
|
+
|
|
59
|
+
robot_wrist_deg = 90 - robot_shoulder_deg - robot_elbow_deg - phi
|
|
60
|
+
|
|
61
|
+
return [robot_base_deg, robot_shoulder_deg, robot_elbow_deg, robot_wrist_deg, 0, 10]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def wait_for_arrival(self, target_angles, tolerance=2.0, timeout=3.0):
|
|
67
|
+
start_time = time.time()
|
|
68
|
+
while time.time() - start_time < timeout:
|
|
69
|
+
current_angles = self.get_joints_angle()
|
|
70
|
+
if current_angles is not None and len(current_angles) >= 4:
|
|
71
|
+
max_diff = max(abs(current_angles[i] - target_angles[i]) for i in range(4))
|
|
72
|
+
if max_diff <= tolerance:
|
|
73
|
+
break
|
|
74
|
+
time.sleep(0.05)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def move_to_xyz(self, phi, x, y, z, wait=True):
|
|
79
|
+
angles = self.generate_ik(phi, x, y, z)
|
|
80
|
+
if angles:
|
|
81
|
+
self.joints_angle_ctrl(angles, 500, 254)
|
|
82
|
+
if wait:
|
|
83
|
+
self.wait_for_arrival(angles)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def draw_line(self, phi, x1, y1, z1, x2, y2, z2, steps=30):
|
|
88
|
+
for i in range(steps + 1):
|
|
89
|
+
t = i / steps
|
|
90
|
+
cx = x1 + (x2 - x1) * t
|
|
91
|
+
cy = y1 + (y2 - y1) * t
|
|
92
|
+
cz = z1 + (z2 - z1) * t
|
|
93
|
+
angles = self.generate_ik(phi, cx, cy, cz)
|
|
94
|
+
if angles:
|
|
95
|
+
self.joints_angle_ctrl(angles, 800, 254)
|
|
96
|
+
time.sleep(0.05)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if angles:
|
|
100
|
+
self.wait_for_arrival(angles)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roarm-ik
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library for the WaveShare Ro-arm m3 adding inverse kinematics functionality wrapping the roarmsdk
|
|
5
|
+
Author: HootSoon: Hudson Reeves
|
|
6
|
+
Author-email: Your Name <your.email@example.com>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# roarm-ik-solver
|
|
17
|
+
|
|
18
|
+
[](https://badge.fury.io/py/roarm-kinematics)
|
|
19
|
+
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
|
|
21
|
+
A full 3D Spatial (XYZ) Inverse Kinematics engine for the Waveshare RoArm-M3 desktop robot arm.
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
examples/basic.py
|
|
6
|
+
examples/draw_square.py
|
|
7
|
+
roarm_ik/__init__.py
|
|
8
|
+
roarm_ik/arm.py
|
|
9
|
+
roarm_ik.egg-info/PKG-INFO
|
|
10
|
+
roarm_ik.egg-info/SOURCES.txt
|
|
11
|
+
roarm_ik.egg-info/dependency_links.txt
|
|
12
|
+
roarm_ik.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
roarm_ik-0.1.0/setup.cfg
ADDED
roarm_ik-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='roarm_ik',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
description='A 3D Inverse Kinematics library for the Waveshare RoArm-M3',
|
|
7
|
+
author='HootSoon: Hudson Reeves',
|
|
8
|
+
packages=find_packages(),
|
|
9
|
+
install_requires=[
|
|
10
|
+
'roarm_sdk',
|
|
11
|
+
],
|
|
12
|
+
)
|