Skip to content

Commit

Permalink
Co-authored-by: Abhishek Shrestha <[email protected].…
Browse files Browse the repository at this point in the history
…com>

Co-authored-by: Oxygonix <[email protected]>
  • Loading branch information
EthanMunoz03 committed Oct 25, 2024
1 parent 4655b55 commit 30b3012
Show file tree
Hide file tree
Showing 48 changed files with 154 additions and 3 deletions.
4 changes: 1 addition & 3 deletions computer_vision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ In your terminal:
cd computer_vision
conda create --name pcr python=3.10
conda activate pcr
pip install -r requirements.txt

:)
pip install -r requirements.txt
153 changes: 153 additions & 0 deletions pcr/arm_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import sys
import os
import numpy as np

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from xarm.wrapper import XArmAPI

ARM: XArmAPI = XArmAPI('192.168.1.166')

ARM.motion_enable(enable=True)
ARM.set_mode(0)
ARM.set_state(0)
ARM.connect()

# Home Coordinates
x = 287
y = -194
z = 329

# Go to arms home
def goHome():
ARM.set_position(x, y, z, speed=65, wait=True)

# Move y over after each letter
def addY():
global y
y = y + 100

# Write the letter E and go back home
def writeE():
ARM.set_position(x, y, z + 150, speed=65, wait=True)
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
ARM.set_position(x, y, z + 150, speed=65, wait=True)
ARM.set_position(x, y, z + 75, speed=65, wait=True)
ARM.set_position(x, y + 75, z + 75, speed=65, wait=True)
ARM.set_position(x, y, z + 75, speed=65, wait=True)
ARM.set_position(x, y, z, speed=65, wait=True)
ARM.set_position(x, y + 75, z, speed=65, wait=True)

# update y
addY()

# go back to home
goHome()

# Write the letter T and go back home
def writeT():
global y
y = y + 32.5

ARM.set_position(x, y, z + 150, speed=65, wait=True)
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
ARM.set_position(x, y - 75, z + 150, speed=65, wait=True)
ARM.set_position(x, y, z + 150, speed=65, wait=True)

# update y
addY()

# go back to home
goHome()

# Write the letter H and go back home
def writeH():
ARM.set_position(x, y, z + 150, speed=65, wait=True)
ARM.set_position(x, y, z + 75, speed=75, wait=True)
ARM.set_position(x, y + 75, z + 75, speed=65, wait=True)
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)
ARM.set_position(x, y + 75, z, speed=65, wait=True)

# update y
addY()

# go back to home
goHome()

# Write the letter A and go back home
def writeA():
ARM.set_position(x, y + 32.5, z + 150, speed=65, wait=True)
ARM.set_position(x, y + 75, z, speed=65, wait=True)
ARM.set_position(x, y + 53.75, z + 75, speed=65, wait=True)
ARM.set_position(x, y + 16.25, z + 75, speed=65, wait=True)

# update y
addY()

# go back to home
goHome()

# Write the letter N and go back home
def writeN():
ARM.set_position(x, y, z + 150, speed=65, wait=True)
ARM.set_position(x, y + 75, z, speed=65, wait=True)
ARM.set_position(x, y + 75, z + 150, speed=65, wait=True)

# update y
addY()

# go back to home
goHome()

# Function to generate waypoints for a circular arc
def generate_arc(center, radius, start_angle, end_angle, num_points):
angles = np.linspace(start_angle, end_angle, num_points)
waypoints = []
for angle in angles:
x = center[0] + radius * np.cos(angle)
y = center[1] + radius * np.sin(angle)
waypoints.append((x, y, center[2])) # Keep z constant for 2D circular arc
return waypoints

def move_in_arc(center, radius, start_angle, end_angle, num_points):
waypoints = generate_arc(center, radius, start_angle, end_angle, num_points)
for x, y, z in waypoints:
ARM.set_position(x, y, z, speed=65, wait=True)

# Example usage
center = (x, y) # Center of the arc in the XY plane
radius = 50 # Radius of the arc
start_angle = 0 # Starting angle in radians
end_angle = np.pi / 2 # End angle in radians (90 degrees)
num_points = 20 # Number of waypoints

move_in_arc(center, radius, start_angle, end_angle, num_points)



def write_eight():
ARM.set_position(x, y, z, speed=65, wait=True)


# Go to arms home
goHome()

# Write out 'ETHAN'
# writeE()
# writeT()
# writeH()
# writeA()
# writeN()


# Write out '8'
write_eight()


# Go back to original home
y = -194
goHome()

ARM.motion_enable(enable=False)
ARM.reset(wait=True)
ARM.disconnect()
Binary file added xarm/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added xarm/__pycache__/version.cpython-312.pyc
Binary file not shown.
Binary file added xarm/core/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added xarm/core/comm/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added xarm/core/comm/__pycache__/base.cpython-312.pyc
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 added xarm/core/utils/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file added xarm/core/utils/__pycache__/crc16.cpython-312.pyc
Binary file not shown.
Binary file added xarm/core/utils/__pycache__/log.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added xarm/tools/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added xarm/tools/__pycache__/threads.cpython-312.pyc
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 added xarm/wrapper/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file added xarm/x3/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/base.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/base_board.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/code.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/decorator.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/events.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/ft_sensor.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/gpio.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/grammar_async.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/gripper.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/parse.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/record.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/robotiq.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/servo.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/studio.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/track.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/utils.cpython-312.pyc
Binary file not shown.
Binary file added xarm/x3/__pycache__/xarm.cpython-312.pyc
Binary file not shown.

0 comments on commit 30b3012

Please sign in to comment.