Skip to content

Commit 30b3012

Browse files
committed
Co-authored-by: Abhishek Shrestha <[email protected]>
Co-authored-by: Oxygonix <[email protected]>
1 parent 4655b55 commit 30b3012

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+154
-3
lines changed

computer_vision/README.md

Lines changed: 1 addition & 3 deletions

pcr/arm_test.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import sys
2+
import os
3+
import numpy as np
4+
5+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
6+
7+
from xarm.wrapper import XArmAPI
8+
9+
ARM: XArmAPI = XArmAPI('192.168.1.166')
10+
11+
ARM.motion_enable(enable=True)
12+
ARM.set_mode(0)
13+
ARM.set_state(0)
14+
ARM.connect()
15+
16+
# Home Coordinates
17+
x = 287
18+
y = -194
19+
z = 329
20+
21+
# Go to arms home
22+
def goHome():
23+
ARM.set_position(x, y, z, speed=65, wait=True)
24+
25+
# Move y over after each letter
26+
def addY():
27+
global y
28+
y = y + 100
29+
30+
# Write the letter E and go back home
31+
def writeE():
32+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
33+
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
34+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
35+
ARM.set_position(x, y, z + 75, speed=65, wait=True)
36+
ARM.set_position(x, y + 75, z + 75, speed=65, wait=True)
37+
ARM.set_position(x, y, z + 75, speed=65, wait=True)
38+
ARM.set_position(x, y, z, speed=65, wait=True)
39+
ARM.set_position(x, y + 75, z, speed=65, wait=True)
40+
41+
# update y
42+
addY()
43+
44+
# go back to home
45+
goHome()
46+
47+
# Write the letter T and go back home
48+
def writeT():
49+
global y
50+
y = y + 32.5
51+
52+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
53+
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
54+
ARM.set_position(x, y - 75, z + 150, speed=65, wait=True)
55+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
56+
57+
# update y
58+
addY()
59+
60+
# go back to home
61+
goHome()
62+
63+
# Write the letter H and go back home
64+
def writeH():
65+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
66+
ARM.set_position(x, y, z + 75, speed=75, wait=True)
67+
ARM.set_position(x, y + 75, z + 75, speed=65, wait=True)
68+
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
69+
ARM.set_position(x, y + 75, z, speed=65, wait=True)
70+
71+
# update y
72+
addY()
73+
74+
# go back to home
75+
goHome()
76+
77+
# Write the letter A and go back home
78+
def writeA():
79+
ARM.set_position(x, y + 32.5, z + 150, speed=65, wait=True)
80+
ARM.set_position(x, y + 75, z, speed=65, wait=True)
81+
ARM.set_position(x, y + 53.75, z + 75, speed=65, wait=True)
82+
ARM.set_position(x, y + 16.25, z + 75, speed=65, wait=True)
83+
84+
# update y
85+
addY()
86+
87+
# go back to home
88+
goHome()
89+
90+
# Write the letter N and go back home
91+
def writeN():
92+
ARM.set_position(x, y, z + 150, speed=65, wait=True)
93+
ARM.set_position(x, y + 75, z, speed=65, wait=True)
94+
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
95+
96+
# update y
97+
addY()
98+
99+
# go back to home
100+
goHome()
101+
102+
# Function to generate waypoints for a circular arc
103+
def generate_arc(center, radius, start_angle, end_angle, num_points):
104+
angles = np.linspace(start_angle, end_angle, num_points)
105+
waypoints = []
106+
for angle in angles:
107+
x = center[0] + radius * np.cos(angle)
108+
y = center[1] + radius * np.sin(angle)
109+
waypoints.append((x, y, center[2])) # Keep z constant for 2D circular arc
110+
return waypoints
111+
112+
def move_in_arc(center, radius, start_angle, end_angle, num_points):
113+
waypoints = generate_arc(center, radius, start_angle, end_angle, num_points)
114+
for x, y, z in waypoints:
115+
ARM.set_position(x, y, z, speed=65, wait=True)
116+
117+
# Example usage
118+
center = (x, y) # Center of the arc in the XY plane
119+
radius = 50 # Radius of the arc
120+
start_angle = 0 # Starting angle in radians
121+
end_angle = np.pi / 2 # End angle in radians (90 degrees)
122+
num_points = 20 # Number of waypoints
123+
124+
move_in_arc(center, radius, start_angle, end_angle, num_points)
125+
126+
127+
128+
def write_eight():
129+
ARM.set_position(x, y, z, speed=65, wait=True)
130+
131+
132+
# Go to arms home
133+
goHome()
134+
135+
# Write out 'ETHAN'
136+
# writeE()
137+
# writeT()
138+
# writeH()
139+
# writeA()
140+
# writeN()
141+
142+
143+
# Write out '8'
144+
write_eight()
145+
146+
147+
# Go back to original home
148+
y = -194
149+
goHome()
150+
151+
ARM.motion_enable(enable=False)
152+
ARM.reset(wait=True)
153+
ARM.disconnect()
236 Bytes
Binary file not shown.
176 Bytes
Binary file not shown.
306 Bytes
Binary file not shown.
303 Bytes
Binary file not shown.
10.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3.63 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
156 Bytes
Binary file not shown.
1.45 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
201 Bytes
Binary file not shown.
Binary file not shown.
227 Bytes
Binary file not shown.
127 KB
Binary file not shown.
7.66 KB
Binary file not shown.
2.25 KB
Binary file not shown.
6.08 KB
Binary file not shown.
8.23 KB
Binary file not shown.
18.6 KB
Binary file not shown.
17.2 KB
Binary file not shown.
Binary file not shown.
37.7 KB
Binary file not shown.
6 KB
Binary file not shown.
11.2 KB
Binary file not shown.
13 KB
Binary file not shown.
20.3 KB
Binary file not shown.
7.22 KB
Binary file not shown.
26.3 KB
Binary file not shown.
1.81 KB
Binary file not shown.
109 KB
Binary file not shown.

0 commit comments

Comments
 (0)