137 Commits
Author SHA1 Message Date
adeck a822ea5184 Add QR codes for Web UI 2024-08-20 10:05:57 -05:00
adeck 5a5202e6f5 Add mode query 2024-08-16 12:12:39 -05:00
adeck 3fb78f8b5a Fix simulation mode 2024-08-16 12:09:32 -05:00
Cole Deck 48e7c7b85f Update sensor code 2024-08-08 10:51:05 -05:00
Cole Deck ea5daf8689 Switch to unicode encoding 2024-08-06 17:41:45 -05:00
Cole Deck 05baceb388 Fix logic 2024-08-06 17:36:31 -05:00
Cole Deck 43694ca97d Use alternate method 2024-08-06 17:33:22 -05:00
Cole Deck 3f731a4bd3 Use alternate method 2024-08-06 17:30:41 -05:00
Cole Deck 419498cae6 Include stderr 2024-08-06 17:26:12 -05:00
Cole Deck c89fc86812 Fix stdout flush 2024-08-06 17:16:20 -05:00
Cole Deck f8507a1bc9 Add more statistics, fix camera, windows client update 2024-08-06 17:01:27 -05:00
adeck 534cc23c8d Update MQTT commands, arm height 2024-07-31 18:25:10 -05:00
adeck b677556ece Add counter, MQTT 2024-07-30 12:54:13 -05:00
adeck 621a530530 Update web with shutdown procedure 2024-07-29 14:01:20 -05:00
adeck 0ad656728d Add shutdown routine 2024-07-29 13:50:58 -05:00
adeck 4591dc6900 Add show mode 2024-07-29 13:38:14 -05:00
adeck 1ac8712e0f Update web, disable sensors in testing mode 2024-07-29 12:06:16 -05:00
adeck af91817a98 Match LED strip color 2024-07-25 10:43:04 -05:00
adeck 24e0094d2a Add system controller camera mode 2024-07-25 10:35:16 -05:00
adeck faf4cc1ba8 Led loop 2024-05-14 21:52:14 -05:00
adeck 0d0ec75783 update web 2024-05-14 21:50:46 -05:00
adeck 5c4d92a84c Remove temp file 2024-05-14 21:50:11 -05:00
Cole Deck 02ab16a566 Add windows client mode updates 2024-05-14 21:51:36 -05:00
adeck 927f61e124 update loading app 2024-05-14 20:53:01 -05:00
adeck d69cce2e38 Add camera error message 2024-05-14 20:44:33 -05:00
adeck 98fef5ad3d increase camera timeout 2024-05-14 20:42:23 -05:00
adeck fa25b2c8b1 add CORS 2024-05-14 20:29:32 -05:00
adeck 32260595a1 Open gripper before picking up 2024-05-14 20:21:09 -05:00
adeck aeeb4c232a slow reset 2024-05-14 20:18:26 -05:00
adeck bbb2b3ff17 speed up 2024-05-14 20:10:47 -05:00
adeck b811351aba remove old var 2024-05-14 20:08:45 -05:00
adeck 38ee4f9b9a update sensor system 2024-05-14 20:07:35 -05:00
adeck b56d176c82 test camera 2024-05-14 19:07:49 -05:00
adeck 25085f542f Try old method 2024-05-14 18:52:27 -05:00
adeck 2562fea076 try this 2024-05-14 18:48:25 -05:00
adeck 0ca9f01aa9 use boolean value 2024-05-14 18:44:54 -05:00
adeck 8b37661a84 manual open in UR5 control 2024-05-14 18:43:43 -05:00
adeck 6347cde9e2 Manually close modbus socket 2024-05-14 18:41:31 -05:00
adeck 7885c0900d add camera timeout 2024-05-14 18:32:09 -05:00
adeck c1f783bb2c fix transition to idle after camera fail 2024-05-14 18:23:41 -05:00
adeck a2e7592ef7 adjust 2024-05-14 18:17:58 -05:00
adeck b0d61d7d00 Adjust slot position 2024-05-14 18:14:17 -05:00
adeck 9687a6e492 Revert to base urx, reduce camera time 2024-05-14 17:52:53 -05:00
adeck 0e6ca7490a Lower frame count 2024-05-14 17:49:10 -05:00
adeck 61954b23b9 Slow to 60hz 2024-05-14 17:44:52 -05:00
adeck 3ede455d2c Update web 2024-05-14 17:37:18 -05:00
adeck ba6c697f00 Add return from tray in web 2024-05-14 17:34:02 -05:00
adeck 24d959da71 Update label generation, websocket listen mode 2024-05-14 17:33:47 -05:00
adeck 33af359a86 Flip vertical move 2024-05-14 16:26:32 -05:00
adeck 43f8c3b615 Other way 2024-05-14 16:24:01 -05:00
adeck a96f34baac Readjust 2024-05-14 16:22:50 -05:00
adeck 635c2708a0 Redo arm startup motion 2024-05-14 16:16:05 -05:00
adeck 62ec1e7443 Add tray return API call 2024-05-14 16:01:10 -05:00
Cole Deck 951ae8cdda Remove unnecessary deps that are pre-installed 2024-05-14 14:59:12 -05:00
adeck 5e0f1e93d2 prerelease 2024-05-13 02:21:07 -05:00
adeck fab8324dea Update web 2024-05-12 18:36:07 -05:00
adeck dbaf018c7b Remove hover effects for touchscreens 2024-05-12 18:30:04 -05:00
adeck f47270a600 Update jukebox-web 2024-05-12 18:19:03 -05:00
adeck e4861e0590 Add datasheet URL to cable details 2024-05-12 18:14:39 -05:00
adeck c45c59aa62 Fix cable_search 2024-05-12 17:56:47 -05:00
adeck 1e01141f41 Make cable_search match cable_map 2024-05-12 16:59:59 -05:00
adeck 2296aea463 Add useful print statements 2024-05-10 12:58:17 -05:00
adeck 341d2232d7 Don't delete old JSON files 2024-05-10 12:51:45 -05:00
adeck 25dc18669b Downgrade camelot for better parsing 2024-05-10 12:28:59 -05:00
adeck 6c8d0bf666 Update web ui 2024-05-09 18:19:24 -05:00
adeck be51423c89 Add real-time UR5 position updates (hopefully) 2024-05-09 18:18:55 -05:00
adeck f416e25c1c Update LED system 2024-05-08 20:28:48 -05:00
adeck dd7bc12fe5 Update jukebox-web 2024-05-08 16:52:28 -05:00
adeck f06540f568 Add category field, update datasheet extracted fields 2024-05-08 16:51:01 -05:00
adeck 4a78586c34 Update jukebox-web 2024-05-08 16:44:46 -05:00
adeck 21cb2beb67 Pull description from Belden API for more consistent values 2024-05-08 16:44:22 -05:00
adeck a905858e3b Add more descriptions 2024-05-08 15:48:26 -05:00
adeck faf33aede7 add descriptions 2024-05-08 15:18:09 -05:00
adeck dc4cf5c222 Center images 2024-05-08 13:27:45 -05:00
adeck ee78037f17 Remove debug statement 2024-05-08 13:07:47 -05:00
adeck f1f2e3191b Square up images 2024-05-08 13:04:43 -05:00
adeck 1f69dbdb82 fix clean install bug 2024-05-08 12:34:07 -05:00
adeck 36249058ac Add brand and images, fileserver for images, start to add arm queue 2024-05-08 12:29:43 -05:00
adeck eca65dc0e0 fix typo 2024-04-29 17:49:56 -05:00
adeck fabd1fe10a Simulation for sensors 2024-04-29 17:48:42 -05:00
adeck b4ad57d52d Separate scanning bypass 2024-04-29 17:25:02 -05:00
adeck 72ab357dbf Improve simulation mode 2024-04-29 17:19:52 -05:00
adeck d0083ed33f Simulation mode 2024-04-29 13:30:04 -05:00
adeck d92ceafa57 Fix non-matching positions 2024-04-29 12:42:11 -05:00
adeck 62bcb07956 Update runtime LED modes 2024-04-29 12:33:55 -05:00
BlueOceanWave c52fe167bf Merge branch 'main' of https://git.myitr.org/Jukebox/jukebox-software 2024-04-26 17:49:14 -05:00
BlueOceanWave f7b4f264c4 Fixed positions for holder 47 and 45 in config.yaml 2024-04-26 17:49:11 -05:00
adeck fb31ab0d73 Add LED animations to runtime 2024-04-24 14:42:47 -05:00
adeck 302d275c64 Update config 2024-04-24 14:42:47 -05:00
adeck 43392fa3ca Freeze math3d version 2024-04-24 14:42:47 -05:00
adeck 660fe29236 Update camera image parser 2024-04-24 14:42:47 -05:00
BlueOceanWave 275cbd027e Added open gripper to init routine 2024-04-24 14:42:07 -05:00
BlueOceanWave f4e43f33d2 Created functions for routines 2024-04-24 14:40:38 -05:00
BlueOceanWave ae97ed1a14 Made pickup and dropoff routines for tray and holder. Adjusted home position 2024-04-23 18:56:11 -05:00
BlueOceanWave 237319db14 Fixed drop off routine to not hit walls 2024-04-22 21:56:07 -05:00
adeck a698c4a753 Add more routines 2024-04-18 20:33:55 -05:00
adeck 939474378a Add open and close gripper functions 2024-04-12 22:05:34 -05:00
adeck 145f51d08c Update IPs for LED system 2024-04-12 20:28:34 -05:00
BlueOceanWave 4973fc79be Merge branch 'main' of https://git.myitr.org/Jukebox/jukebox-software 2024-04-12 20:28:33 -05:00
BlueOceanWave ff2269193b small dimensions fixes 2024-04-12 20:28:31 -05:00
adeck 5edd7f4592 Remove extraneous pass 2024-03-27 20:41:07 -05:00
adeck 4dd6f7649a Implement cable_search 2024-03-27 20:40:20 -05:00
adeck dc1e568a96 Add basic cable_map implementation 2024-03-27 20:33:21 -05:00
adeck 1ec6d92cfa Deploy docker containers 2024-03-27 19:50:01 -05:00
adeck e21ded46f1 Update juekbox-web 2024-03-27 19:47:17 -05:00
adeck 672507f498 Add jukebox web 2024-03-27 19:46:45 -05:00
adeck 64bb50f055 Add setup-alpine-vm.sh 2024-03-28 00:44:57 +00:00
adeck 5016b4e99f Update compose.yml 2024-03-28 00:44:35 +00:00
adeck efbda23c38 Fix docker runtime support 2024-03-27 18:53:50 -05:00
adeck 19ce328596 Correctly parse results from get_specs 2024-03-27 17:49:02 -05:00
adeck ad216f21fa Implement cable_details call 2024-03-26 18:42:01 -05:00
BlueOceanWave 6d6c2030a9 Merge branch 'main' of https://git.myitr.org/Jukebox/jukebox-software 2024-03-26 15:24:20 -05:00
BlueOceanWave 9893222335 Pick-up routine 2024-03-26 15:24:18 -05:00
adeck 82a52dea5a Add cables to meilisearch db 2024-03-26 15:09:26 -05:00
adeck 77fdc43fce Add missing robot pass-ins 2024-03-24 15:35:46 -05:00
adeck 3de59f5985 Convert ur5_control to class based (untested) 2024-03-24 15:31:58 -05:00
BlueOceanWave 6887fa943b Merge branch 'main' of https://git.myitr.org/Jukebox/jukebox-software 2024-03-24 13:50:17 -05:00
BlueOceanWave 2ec7906ee4 Basic move restrictions and flip routine 2024-03-23 15:47:10 -05:00
adeck 069d2175d9 Convert led code to class based for multithreading 2024-03-23 15:33:51 -05:00
adeck 9b1b92e21d Re-add https:// format, needed for most devices 2024-03-21 19:48:46 -05:00
adeck ee0f8f4250 Remove cairosvg VERSION patch 2024-03-21 19:41:46 -05:00
adeck 9c9435570b Remove cairosvg as it doesn't have pip-only lib. Use png instead. 2024-03-21 19:39:43 -05:00
adeck 1bf10f7349 Update label generator to include belden logo, use QR code, URL matching 2024-03-21 18:57:59 -05:00
adeck 3c8d6c7ad3 Remove debug print 2024-03-20 16:31:29 -05:00
adeck cbe7225fc9 Fix bug with part name in query_search 2024-03-20 16:27:43 -05:00
adeck 44efc4006e Correct flip rz orientation 2024-03-19 17:48:32 -05:00
adeck 218303e92b Try different moves 2024-03-17 22:01:34 -05:00
adeck e5d3f87b5c Go to home position first 2024-03-17 20:49:39 -05:00
adeck 2ab1d0dbb3 Add flip around mode to fit edge slots 2024-03-17 20:48:26 -05:00
adeck 1338c3f440 Added tool z rotation for angled gripper 2024-03-17 20:07:25 -05:00
adeck 83b077b4df Make limb lengths and offsets global 2024-03-17 19:59:17 -05:00
adeck f16242f5be Re-merge calculate_theta into get_joints_from_xyz_rel 2024-03-17 19:53:49 -05:00
adeck 2f28a01b7c Add basic kinematics for gripper angle 2024-03-17 19:50:04 -05:00
adeck fb85a56d47 Use movejs to go to all cable positions 2024-03-17 16:21:57 -05:00
adeck bec0c63763 Fix ur5_control bugs, fully working IK!! Thanks Nadeem 2024-03-17 16:13:53 -05:00
BlueOceanWave 4ae30b82a0 Cleaned up notebook 2024-03-17 15:43:06 -05:00
BlueOceanWave 4bc3e30116 Fixed edge cases when calculating base angle 2024-03-17 01:01:39 -05:00
46 changed files with 5422 additions and 956 deletions

No files matched your search

+3 -1
View File
@@ -3,6 +3,7 @@ venv
__pycache__
# cable data folder(s)
cables
cables_old
cables-sample.zip
# meilisearch (mainly where I've put the data volume for the container)
meili_data
@@ -15,8 +16,9 @@ output.mp4
# log files
output.log
# images
*.png
map*.png
# Built app
build
# Generated label images
labels
temp
+3
View File
@@ -0,0 +1,3 @@
[submodule "jukebox-web"]
path = jukebox-web
url = https://git.myitr.org/Jukebox/jukebox-web
+3 -3
View File
@@ -3,11 +3,11 @@ FROM python:3.11-slim
# Get runtime dependencies
# glx for OpenCV, ghostscript for datasheet PDF rendering, zbar for barcode scanning, git for cloning repos
RUN apt-get update && apt-get install -y libgl1-mesa-glx ghostscript libzbar0 git && apt-get clean && rm -rf /var/lib/apt/lists
COPY *.py *.yml *.sh *.txt *.html static templates ./
COPY requirements.txt ./
#COPY config-server.yml config.yml
RUN pip3 install -r requirements.txt
CMD ["python3", "run.py"]
COPY *.py *.yml *.sh *.txt *.html static templates ./
CMD ["sh", "-c", "python3 run.py"]
EXPOSE 5000
EXPOSE 8000
EXPOSE 9000
Binary file not shown.
+13 -10
View File
@@ -40,13 +40,16 @@ class DriveImg():
self.onLine = False
fprint("Offline")
def close(self):
self.trans.close()
def read_img(self):
resposta = 'Falha'
try:
if not self.onLine:
#print(f'tentando Conectar camera {self.ip}...')
gravaLog(ip=self.ip,msg=f'Trying to connect...')
sleep(2)
#sleep(2)
try:
self.trans = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.trans.connect((self.ip,self.PORT))
@@ -55,7 +58,7 @@ class DriveImg():
except:
self.onLine = False
self.trans.close()
return resposta
return "Error", None
ret = self.trans.recv(64)
try:
valida = str(ret[0:15].decode('UTF-8'))
@@ -63,15 +66,15 @@ class DriveImg():
if valida.find("TC IMAGE")<0:
self.onLine = False
self.trans.close()
sleep(2)
#sleep(2)
gravaLog(ip=self.ip,tipo="Falha",msg=f'Unable to find TC IMAGE bookmark')
return "Error"
return "Error", None
except Exception as ex:
self.onLine = False
self.trans.close()
sleep(2)
#sleep(2)
gravaLog(ip=self.ip,tipo="Falha",msg=f'Error - {str(ex)}')
return "Error"
return "Error", None
if ret:
frame = int.from_bytes(ret[24:27],"little")
isJpeg = int.from_bytes(ret[32:33],"little")
@@ -113,8 +116,8 @@ class DriveImg():
#print(f'erro {str(ex)}')
self.onLine = False
self.trans.close()
sleep(2)
return resposta
#sleep(2)
return "Error", None
class DriveData():
HEADERSIZE = 100
@@ -139,7 +142,7 @@ class DriveData():
if not self.onLine:
#print(f'tentando Conectar...\n')
gravaLog(ip=self.ip,msg=f'tentando Conectar...',file="log_data.txt")
sleep(2)
#sleep(2)
try:
self.trans = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.trans.connect((self.ip,self.PORT))
@@ -154,7 +157,7 @@ class DriveData():
except Exception as ex:
self.onLine = False
gravaLog(ip=self.ip,tipo="Falha Generica",msg=f'erro {str(ex)}',file="log_data.txt")
sleep(2)
#sleep(2)
return resposta
Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 446.6 151.4" style="enable-background:new 0 0 446.6 151.4;" xml:space="preserve">
<style type="text/css">
.st0{fill:#004990;}
</style>
<g>
<g>
<path class="st0" d="M21.2,32.1h-1.4v87.2H55c20.3,0,32-9.1,32-24.9c0-12.3-5.6-19.7-15.8-22.1c5.1-3.6,7.8-9.1,7.8-16.9
c0-15.5-8.9-23.3-26.5-23.3H21.2z M44.7,51.6c7.4,0,11.4,1.1,11.4,6.8c0,4.8-3.1,6.8-10.5,6.8c0,0-0.6,0-1.1,0
c0-2.1,0-11.5,0-13.6C44.5,51.6,44.7,51.6,44.7,51.6z M45.4,84.4l1.8,0c4.6,0,10.3-0.1,13,2.6c1.2,1.2,1.8,2.9,1.8,5.2
c0,2-0.6,3.5-1.7,4.7c-3,3-9.2,2.9-13.8,2.9c0,0-1.4,0-2.1,0c0-2.1,0-13.3,0-15.4C44.9,84.4,45.4,84.4,45.4,84.4z"/>
<g>
<path class="st0" d="M139.8,32.1H90.4v87.2h50.8V98c0,0-23.7,0-26.1,0c0-2,0-9.8,0-11.8c2.4,0,24.8,0,24.8,0V64.8
c0,0-22.3,0-24.8,0c0-2,0-9.4,0-11.4c2.5,0,26.1,0,26.1,0V32.1H139.8z"/>
</g>
<g>
<path class="st0" d="M169.3,32.1H146v87.2h51V98c0,0-23.9,0-26.3,0c0-2.6,0-65.9,0-65.9H169.3z"/>
</g>
<g>
<path class="st0" d="M332.4,32.1H283v87.2h50.8V98c0,0-23.7,0-26.1,0c0-2,0-9.8,0-11.8c2.4,0,24.8,0,24.8,0V64.8
c0,0-22.3,0-24.8,0c0-2,0-9.4,0-11.4c2.5,0,26.1,0,26.1,0V32.1H332.4z"/>
</g>
<g>
<path class="st0" d="M424.6,32.1h-23.3c0,0,0,43,0,49.3c-4-5.1-38.4-49.3-38.4-49.3h-24v87.2h24.7c0,0,0-43.1,0-49.5
c4,5.1,38.4,49.5,38.4,49.5h24V32.1H424.6z"/>
</g>
<g>
<g>
<path class="st0" d="M233.8,32.1h-32.5v87.2h32.5c24.4,0,44.3-19.6,44.3-43.6C278.1,51.7,258.2,32.1,233.8,32.1z M226,53.5
c13.6,0.3,22,8.7,22,22.2c0,13.6-8.2,21.9-22,22.2V53.5z M231.5,101.3c12.5-3,20.7-10.7,20.8-25.7c-0.2-15-8.3-22.7-20.8-25.7
c14,2.1,25,9.5,25,25.6v0.1C256.5,91.8,245.5,99.2,231.5,101.3z M260.2,75.6c-0.2-18-10-29.8-24.9-33.3
c16.7,2.5,29.6,14,29.6,33.3c0,0,0,0,0,0.1h0c0,19.3-13,30.7-29.7,33.2C250.1,105.3,260,93.6,260.2,75.6z M240.3,115.7
c16.7-4.7,28.3-19.2,28.5-39.9v-0.3c-0.2-20.7-11.9-35.1-28.5-39.8c19,3.9,33.5,17.7,33.6,39.7v0.4
C273.9,97.9,259.4,111.8,240.3,115.7z"/>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

+26
View File
@@ -0,0 +1,26 @@
1172C
86104CY
FIT-221-1_4
10GXW13
10GXW53
29501F
29512
3092A
3105A
3106A
6300FE
6300UE
7922A
7958A
8760
9841
FI4X012W0
FISX012W0
IOP6U
RA500P
SPE101
SPE102
TF-1LF-006-RS5
TF-SD9-006-RI5
TT-SLG-024-HTN
3050
+29
View File
@@ -0,0 +1,29 @@
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
python run.py
:--------------------------------------
+13
View File
@@ -0,0 +1,13 @@
services:
meilisearch:
image: "getmeili/meilisearch:v1.6.2"
ports:
- "7700:7700"
environment:
MEILI_MASTER_KEY: fluffybunnyrabbit
MEILI_NO_ANALYTICS: true
volumes:
- "meili_data:/meili_data"
volumes:
meili_data:
+17
View File
@@ -9,5 +9,22 @@ services:
volumes:
- "meili_data:/meili_data"
jukebox-software:
build: .
init: true
ports:
- "5000:5000"
- "8000:8000"
- "9000:9000"
environment:
- PYTHONUNBUFFERED=1
depends_on:
- meilisearch
jukebox-web:
build: jukebox-web
ports:
- "3000:3000"
volumes:
meili_data:
+126 -94
View File
@@ -3,70 +3,102 @@ core:
serverip: 172.26.178.114
clientip: 172.26.176.1
server: Hyper-Vd
loopspeed: 60 # fps
mqtt:
enabled: False
server: 172.31.108.4
arm:
ip: 192.168.1.145
tool:
offset_x: 0
offset_y: 0
offset_z: 0.14
limbs:
limb_base: 0.11
limb1: 0.425
limb2: 0.39225
limb3: 0.1
limb_wrist: 0.0997
cables:
port: 7900
directory: ./cables/ # must include trailing slash
#cable_map:
cameras:
banner:
ip: 192.168.1.125
port: 32200
ip: 192.168.1.199
port: 80
animation_time: 60
led:
fps: 90
timeout: 0
fps: 100
timeout: 1
controllers:
- universe: 9
ip: 192.168.68.131
- universe: 1
ip: 192.168.1.200
ledstart: 0
ledend: 143
mode: rgb
- universe: 3
ip: 192.168.68.131
- universe: 2
ip: 192.168.1.201
ledstart: 144
ledend: 287
mode: rgb
- universe: 2
ip: 192.168.68.131
- universe: 3
ip: 192.168.1.202
ledstart: 288
ledend: 431
mode: rgb
- universe: 4
ip: 192.168.5.40
ip: 192.168.1.203
ledstart: 432
ledend: 575
mode: rgb
- universe: 1
ip: 192.168.5.4
- universe: 5
ip: 192.168.1.204
ledstart: 576
ledend: 719
mode: rgb
- universe: 5
ip: 192.168.68.131
- universe: 6
ip: 192.168.1.205
ledstart: 720
ledend: 863
mode: rgb
- universe: 6
ip: 192.168.68.131
- universe: 7
ip: 192.168.1.206
ledstart: 864
ledend: 1007
mode: rgb
- universe: 7
ip: 192.168.68.131
- universe: 8
ip: 192.168.1.207
ledstart: 1008
ledend: 1151
mode: rgb
- universe: 8
ip: 192.168.68.131
- universe: 9
ip: 192.168.1.208
ledstart: 1152
ledend: 1295
mode: rgb
- universe: 0
ip: 192.168.68.130
ledstart: 1296
ledend: 1365
mode: rgbw
- universe: 10
ip: 192.168.1.209
mode: solid
color: [0, 50, 100]
- universe: 11
ip: 192.168.1.210
mode: solid
color: [0, 50, 100]
- universe: 12
ip: 192.168.1.211
mode: solid
color: [0, 50, 100]
# - universe: 0
# ip: 192.168.1.209
# ledstart: 1296
# ledend: 1365
# mode: rgbw
map:
@@ -76,37 +108,37 @@ led:
start: 0
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, 304.8]
- type: circle
start: 24
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, 266.7]
- type: circle
start: 48
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, 228.6]
- type: circle
start: 72
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-197.973, 190.5]
- type: circle
start: 96
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-263.965, 152.4]
- type: circle
start: 120
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-263.965, 76.2]
# controller 2
@@ -114,37 +146,37 @@ led:
start: 144
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, 228.6]
- type: circle
start: 168
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, 190.5]
- type: circle
start: 192
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, 152.4]
- type: circle
start: 216
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-197.973, 114.3]
- type: circle
start: 240
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-197.973, 38.1]
- type: circle
start: 264
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-263.965, 0]
# controller 3
@@ -152,37 +184,37 @@ led:
start: 288
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, 152.4]
- type: circle
start: 312
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, 114.3]
- type: circle
start: 336
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, 76.2]
- type: circle
start: 360
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, 0]
- type: circle
start: 384
size: 24
diameter: 63.5
angle: 0
pos: [-197.973, -38.1]
angle: 180
pos: [-199.0, -35.0]
- type: circle
start: 408
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-263.965, -76.2]
# controller 4
@@ -190,37 +222,37 @@ led:
start: 432
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, 76.2]
- type: circle
start: 456
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, 152.4]
- type: circle
start: 480
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, 228.6]
- type: circle
start: 504
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, 266.7]
- type: circle
start: 528
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, 190.5]
- type: circle
start: 552
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, 114.3]
@@ -229,37 +261,37 @@ led:
start: 576
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, 0]
- type: circle
start: 600
size: 24
diameter: 63.5
angle: 0
pos: [197.973, 38.1]
angle: 180
pos: [201.973, 34.1]
- type: circle
start: 624
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [197.973, 114.3]
- type: circle
start: 648
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [197.973, 190.5]
- type: circle
start: 672
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [263.965, 152.4]
- type: circle
start: 696
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [263.965, 76.2]
# controller 6
@@ -267,37 +299,37 @@ led:
start: 720
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, -76.2]
- type: circle
start: 744
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [197.973, -38.1]
- type: circle
start: 768
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [263.965, 0]
- type: circle
start: 792
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [263.965, -76.2]
- type: circle
start: 816
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [263.965, -152.4]
- type: circle
start: 840
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [197.973, -114.3]
# controller 7
@@ -305,75 +337,75 @@ led:
start: 864
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, -114.3]
- type: circle
start: 888
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, -152.4]
- type: circle
start: 912
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, -114.3]
- type: circle
start: 936
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, -76.2]
- type: circle
start: 960
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-197.973, -114.3]
- type: circle
start: 984
size: 24
diameter: 63.5
angle: 0
pos: [-131.982, -152.4]
angle: 180
pos: [-133.0, -151.0]
# controller 8
- type: circle
start: 1008
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, -228.6]
- type: circle
start: 1032
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, -190.5]
- type: circle
start: 1056
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-65.991, -266.7]
- type: circle
start: 1080
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-131.982, -228.6]
- type: circle
start: 1104
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-197.973, -190.5]
- type: circle
start: 1128
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [-263.965, -152.4]
# controller 9
@@ -381,49 +413,49 @@ led:
start: 1152
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [0, -304.8]
- type: circle
start: 1176
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, -266.7]
- type: circle
start: 1200
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, -228.6]
- type: circle
start: 1224
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [197.973, -190.5]
- type: circle
start: 1248
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [131.982, -152.4]
- type: circle
start: 1272
size: 24
diameter: 63.5
angle: 0
angle: 180
pos: [65.991, -190.5]
# Strips
- type: strip
start: 1296
size: 70
length: 600
angle: 270 # down
pos: [375, 300]
# - type: strip
# start: 1296
# size: 70
# length: 600
# angle: 270 # down
# pos: [375, 300]
global_position_offset: [0,0] # default coordinate spce below as center of arm at 0,0 - adjust if necessary
animation_time: 40
position_map:
- index: 0
pos: [-152.4, 263.965]
@@ -442,7 +474,7 @@ position_map:
- index: 7
pos: [-38.1, 197.973]
- index: 8
pos: [38.1, 197.973]
pos: [34.1, 201.973]
- index: 9
pos: [114.3, 197.973]
- index: 10
@@ -500,7 +532,7 @@ position_map:
- index: 36
pos: [-228.6, -131.982]
- index: 37
pos: [-152.4, -131.982]
pos: [-151.0, -133.0]
- index: 38
pos: [-76.2, -131.982]
- index: 39
@@ -516,7 +548,7 @@ position_map:
- index: 44
pos: [-114.3, -197.973]
- index: 45
pos: [-38.1, -197.973]
pos: [-35.0, -199.0]
- index: 46
pos: [38.1, -197.973]
- index: 47
+23
View File
@@ -0,0 +1,23 @@
import http.server
import socketserver
import os
class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
self.send_header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type')
http.server.SimpleHTTPRequestHandler.end_headers(self)
def run_server(port, directory):
"""
Run a simple HTTP server serving files from the specified directory with CORS enabled.
"""
# Change the working directory to the specified directory
os.makedirs(directory, exist_ok=True)
os.chdir(directory)
# Create the HTTP server using the CORS-enabled handler
with socketserver.TCPServer(("", port), CORSHTTPRequestHandler) as httpd:
print(f"Serving files at port {port} with CORS enabled")
httpd.serve_forever()
+84 -40
View File
@@ -30,6 +30,7 @@ def query_search(partnum, source):
fprint("Searching for " + partnum)
if source == "Belden":
token_url = "https://www.belden.com/coveo/rest/token?t=" + str(int(time.time()))
try:
with requests.get(token_url) as r:
out = json.loads(r.content)
token = out["token"]
@@ -47,7 +48,6 @@ def query_search(partnum, source):
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
try:
with requests.post(search_url, headers=headers, data=search_data) as r:
a = r.text
a = json.loads(a)
@@ -70,6 +70,8 @@ def query_search(partnum, source):
if idx < 0:
fprint("Could not find part in API: " + partnum)
return False
name = a["results"][idx]["title"]
#fprint("Search result found: result " + str(idx) + ", for ID " + name)
#urlname = a["results"][0]["raw"]["catalogitemurlname"]
img = a["results"][idx]["raw"]["catalogitemimageurl"]
@@ -79,15 +81,20 @@ def query_search(partnum, source):
brand = a["results"][idx]["raw"]["catalogitembrand"]
desc = a["results"][idx]["raw"]["catalogitemlongdesc"]
shortdesc = a["results"][idx]["raw"]["catalogitemshortdesc"]
a = json.dumps(a["results"][idx], indent=2)
app = a["results"][idx]["raw"]["catalogitemapplication"]
category = a["results"][idx]["raw"]["catalogitemfilterproductcategory"]
#a = json.dumps(a["results"][idx], indent=2)
#print(a, urlname, img, uri, dsurl)
out = dict()
out["url"] = "https://www.belden.com/products/" + uri
out["datasheet"] = "https://catalog.belden.com/techdata/EN/" + dsid + "_techdata.pdf"
out["brand"] = brand
out["name"] = shortdesc
out["short_description"] = shortdesc
out["description"] = desc
out["application"] = app
out["category"] = category
out["image"] = "https://www.belden.com" + img
out["partnum"] = name
#print(out)
@@ -157,8 +164,9 @@ def touch(path):
def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
with alive_bar(len(partnums) * 2, dual_line=True, calibrate=30, bar="classic2", spinner="classic") as bar:
def get_multi(partnums, delay, dir, webport, cache=True, bar=None):
#with alive_bar(len(partnums) * 2, dual_line=True, calibrate=30, bar="classic2", spinner="classic", disable=True, file=sys.stdout) as bar:
failed = list()
actualpartnums = list()
def _try_download_datasheet(partnum, output_dir, dstype): # Guess datasheet URL
@@ -186,7 +194,7 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
# and set chunk_size parameter to None.
#if chunk:
bartext = bartext + "."
bar.text = bartext
# bar.text = bartext
f.write(chunk)
#fprint("")
return output_dir + "/datasheet.pdf"
@@ -215,7 +223,7 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
# and set chunk_size parameter to None.
#if chunk:
bartext = bartext + "."
bar.text = bartext
# bar.text = bartext
f.write(chunk)
#fprint("")
return output_dir + "/datasheet.pdf"
@@ -242,7 +250,7 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
# and set chunk_size parameter to None.
#if chunk:
bartext = bartext + "."
bar.text = bartext
# bar.text = bartext
f.write(chunk)
#fprint("")
return output_dir + "/part-hires." + url.split(".")[-1]
@@ -251,34 +259,35 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
os.remove(partnum + "/datasheet.pdf")
sys.exit()
def __use_cached_datasheet(partnum, path, output_dir, dstype):
def __use_cached_datasheet(partnum, path, output_dir, dstype, weburl, extra):
fprint("Using cached datasheet for " + partnum)
bar.text = "Using cached datasheet for " + partnum
bar(skipped=True)
# bar.text = "Using cached datasheet for " + partnum
# bar(skipped=True)
if not os.path.exists(output_dir + "/parsed"):
fprint("Parsing Datasheet contents of " + partnum)
bar.text = "Parsing Datasheet contents of " + partnum + ".pdf..."
# bar.text = "Parsing Datasheet contents of " + partnum + ".pdf..."
out = read_datasheet.parse(path, output_dir, partnum, dstype)
bar(skipped=False)
out = read_datasheet.parse(path, output_dir, partnum, dstype, weburl, extra)
# bar(skipped=False)
return out
else:
fprint("Datasheet already parsed for " + partnum)
bar.text = "Datasheet already parsed for " + partnum + ".pdf"
bar(skipped=True)
# bar.text = "Datasheet already parsed for " + partnum + ".pdf"
# bar(skipped=True)
def __downloaded_datasheet(partnum, path, output_dir, dstype):
def __downloaded_datasheet(partnum, path, output_dir, dstype, weburl, extra):
fprint("Downloaded " + path)
bar.text = "Downloaded " + path
bar(skipped=False)
# bar.text = "Downloaded " + path
# bar(skipped=False)
fprint("Parsing Datasheet contents of " + partnum)
bar.text = "Parsing Datasheet contents of " + partnum + ".pdf..."
out = read_datasheet.parse(path, output_dir, partnum, dstype)
bar(skipped=False)
# bar.text = "Parsing Datasheet contents of " + partnum + ".pdf..."
out = read_datasheet.parse(path, output_dir, partnum, dstype, weburl, extra)
# bar(skipped=False)
return out
def run_search(partnum):
partnum = partnum.replace("%20", " ") # undo URL encoding
oldpartnum = partnum
if dstype == "Alphawire":
# For alphawire, sanitize the part number for only the final result check, because their API is very wierd
@@ -286,8 +295,9 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
partnum = partnum.replace("/","_")
output_dir = dir + partnum
path = output_dir + "/datasheet.pdf"
weburl = ":" + str(webport) + "/" + partnum + "/"
bartext = "Downloading files for part " + partnum
bar.text = bartext
# bar.text = bartext
partnum = oldpartnum.replace("_","/")
returnval = [partnum, dstype, False, False]
if (not os.path.exists(output_dir + "/found_part_hires")) or not (os.path.exists(path) and os.path.getsize(path) > 1) or not cache:
@@ -297,53 +307,80 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
if search_result is not False:
# Download high resolution part image if available and needed
#oldpartnum = partnum
partnum = search_result["partnum"]
returnval = [partnum, dstype, False, False]
output_dir = dir + partnum
path = output_dir + "/datasheet.pdf"
bartext = "Downloading files for part " + partnum
bar.text = bartext
os.makedirs(output_dir, exist_ok=True)
with open(output_dir + "/search-result.json", 'w') as json_file:
fprint("Saving search result of " + partnum)
json.dump(search_result, json_file)
# bar.text = bartext
if not os.path.exists(output_dir + "/found_part_hires") or not cache:
if _download_image(search_result["image"], output_dir):
fprint("Downloaded hi-res part image for " + partnum)
returnval = [partnum, dstype, True, False]
if os.path.exists(output_dir + "/parsed"):
os.remove(output_dir + "/parsed")
touch(output_dir + "/found_part_hires")
else:
fprint("Using cached hi-res part image for " + partnum)
# Download datasheet from provided URL if needed
if os.path.exists(path) and os.path.getsize(path) > 1 and cache:
out = __use_cached_datasheet(partnum, path, output_dir, dstype)
out = __use_cached_datasheet(partnum, path, output_dir, dstype, weburl, search_result)
returnval = [partnum, dstype, True, out]
elif _download_datasheet(search_result["datasheet"], output_dir) is not False:
out = __downloaded_datasheet(partnum, path, output_dir, dstype)
out = __downloaded_datasheet(partnum, path, output_dir, dstype, weburl, search_result)
returnval = [partnum, dstype, True, out]
elif os.path.exists(path) and os.path.getsize(path) > 1 and cache:
out = __use_cached_datasheet(partnum, path, output_dir, dstype)
search_result = {}
if os.path.exists(output_dir + "/search-result.json"):
with open(output_dir + "/search-result.json", 'r', encoding='utf-8') as file:
search_result = json.load(file)
out = __use_cached_datasheet(partnum, path, output_dir, dstype, weburl, search_result)
returnval = [partnum, dstype, True, out]
# If search fails, and we don't already have the datasheet, guess datasheet URL and skip the hires image download
elif _try_download_datasheet(partnum, output_dir, dstype) is not False:
out = __downloaded_datasheet(partnum, path, output_dir, dstype)
search_result = {}
if os.path.exists(output_dir + "/search-result.json"):
with open(output_dir + "/search-result.json", 'r', encoding='utf-8') as file:
search_result = json.load(file)
out = __downloaded_datasheet(partnum, path, output_dir, dstype, weburl, search_result)
returnval = [partnum, dstype, False, out]
# Failed to download with search or guess :(
else:
return False
time.sleep(delay)
actualpartnums.append(returnval)
return returnval
# We already have a hi-res image and the datasheet - perfect!
else:
fprint("Using cached hi-res part image for " + partnum)
out = __use_cached_datasheet(partnum, path, output_dir, dstype)
search_result = {}
if os.path.exists(output_dir + "/search-result.json"):
with open(output_dir + "/search-result.json", 'r', encoding='utf-8') as file:
search_result = json.load(file)
out = __use_cached_datasheet(partnum, path, output_dir, dstype, weburl, search_result)
returnval = [partnum, dstype, False, out]
actualpartnums.append(returnval)
return True
for fullpartnum in partnums:
if fullpartnum is False:
actualpartnums.append(False)
continue
if fullpartnum[0:2] == "BL": # catalog.belden.com entry
partnum = fullpartnum[2:]
dstype = "Belden"
@@ -370,11 +407,11 @@ def get_multi(partnums, delay=0.25, dir="cables/", cache=True):
time.sleep(delay)
if not success:
fprint("Failed to download datasheet for part " + partnum)
bar.text = "Failed to download datasheet for part " + partnum
# bar.text = "Failed to download datasheet for part " + partnum
failed.append((partnum, dstype))
bar(skipped=True)
bar(skipped=True)
time.sleep(delay)
# bar(skipped=True)
# bar(skipped=True)
if len(failed) > 0:
fprint("Failed to download:")
@@ -405,6 +442,7 @@ if __name__ == "__main__":
# ]
partnums = [
# Actual cables in Jukebox
"BL3092A",
"AW86104CY",
"AW3050",
"AW6714",
@@ -434,10 +472,11 @@ if __name__ == "__main__":
"BL6300FE 009Q",
"BLRA500P 006Q",
]
# Some ones I picked, including some invalid ones
a = [
"BL10GXS12",
"BLRST 5L-RKT 5L-949",
"BLRST%205L-RKT%205L-949",
"BL10GXS13",
"BL10GXW12",
"BL10GXW13",
@@ -448,13 +487,18 @@ if __name__ == "__main__":
"BLFISD012R9",
"BLFDSD012A9",
"BLFSSL024NG",
"BLFISX006W0",
"BLFISX00103",
"BLC6D1100007"
"BLFISX006W0", # datasheet only
"BLFISX00103", # invalid
"BLC6D1100007" # invalid
]
print(query_search("74002", "Belden"))
#get_multi(partnums, 0.25)
#print(query_search("TT-SLG-024-HTNN", "Belden"))
from label_generator import gen_label
gen_label("BLTF-SD9-006-RI5")
gen_label("BLRA500P")
gen_label("AWFIT-221-1_4")
gen_label("BLRST 5L-RKT 5L-949")
get_multi(partnums, 0.25)
#query_search("10GXS13", "Belden")
-1
View File
@@ -1 +0,0 @@
<html> <head> <title>RGB Controller Configuration</title> <style> body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; } </style> </head> <body> <h1>RGB Controller Configuration</h1><br> <h2>Set IP address</h2> Needs reboot to apply<br> Set to 0.0.0.0 for DHCP <form method="post" enctype="application/x-www-form-urlencoded" action="/postform/"> <input type="text" name="ipa" value="0" size="3">. <input type="text" name="ipb" value="0" size="3">. <input type="text" name="ipc" value="0" size="3">. <input type="text" name="ipd" value="0" size="3"> <input type="submit" value="Set"> </form><br> <h2>Set Hostname</h2> Needs reboot to apply<br> Max 64 characters <form method="post" enctype="application/x-www-form-urlencoded" action="/postform/"> <input type="text" name="hostname" value="RGBController" size="20"> <input type="submit" value="Set"> </form><br> <h2>DMX512 Start Universe</h2> Applies immediately<br> Between (inclusive) 1-65000 <form method="post" enctype="application/x-www-form-urlencoded" action="/postform/"> <input type="text" name="universe" value="1" size="5"> <input type="submit" value="Set"> </form><br> <form method="post" enctype="application/x-www-form-urlencoded" action="/postform/"> <input type="submit" name="reboot" value="Reboot"> </form><br> </body></html>
+208 -204
View File
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -52,16 +52,23 @@
},
{
"cell_type": "code",
"execution_count": 75,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"flip\n",
"[62.18186071534606, -126.63734509021032, 142.6959710408549, -106.0586259506446]\n"
"data": {
"text/plain": [
"[82.5301003420473,\n",
" -83.54918182551367,\n",
" 111.24503912126411,\n",
" -117.69585729575046,\n",
" -90.0,\n",
" 90.0]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@@ -69,7 +76,6 @@
" # Normalizes degree theta from -1.5pi to 1.5pi\n",
" multiplier = 1.5\n",
" normalized_theta = theta % (math.pi * multiplier)\n",
" \n",
" # Maintain the negative sign if the original angle is negative\n",
" if theta < 0:\n",
" normalized_theta -= math.pi * multiplier\n",
@@ -77,28 +83,28 @@
" # Return angle\n",
" return normalized_theta\n",
"\n",
"def get_joints_from_xyz_rel(x, y, z, rx=0, ry=0, rz=0, tool_offset=(0.145, 0, 0.14), initial_guess = (math.pi/2, math.pi/2, 0)):\n",
"def get_joints_from_xyz_rel(x, y, z, rx=0, ry=-math.pi/2, rz=0, initial_guess = (math.pi/2, math.pi/2, 0)):\n",
" # Get limbs and offsets\n",
" offset_x, offset_y, offset_z = tool_offset\n",
" l_bs, l1, l2, l3 = (0.14, .422864, .359041, .15)\n",
"\n",
" offset_x, offset_y, offset_z = (0, 0, 0.14) # Tool offset\n",
" l_bs, l1, l2, l3, l_wt = (0.1333, .425, .39225, .1267, .0997) # Limb lengths\n",
" \n",
" # Calculate base angle and r relative to shoulder joint\n",
" def calculate_theta(x, y, a):\n",
" # Calculate if we need the + or - in our equations\n",
" if (x>-a and y>=0) or (x>a and y<0):\n",
" print('no flip')\n",
" if (x>a and y>=0) or (x>-a and y<0):\n",
" flip = 1\n",
" elif (x<-a and y>=0) or (x<a and y<0):\n",
" print('flip')\n",
" elif (x<a and y>=0) or (x<-a and y<0):\n",
" flip = -1\n",
" else: \n",
" print('critical')\n",
" # Critical section (x=a, or x=-a). Infinite slope\n",
" # Return 0 or 180 depending on sign\n",
" return math.atan2(y, 0)\n",
" return math.atan2(y, 0) - math.pi/2\n",
" \n",
" # Calculate tangent line y = mx + b\n",
" m = (x*y - math.sqrt(x*x*y*y-(x*x-a*a)*(y*y-a*a)))/(x*x-a*a)\n",
" if abs(a) != abs(x): # If there is no division by 0\n",
" m = (x*y + math.sqrt(x*x*y*y-(x*x-a*a)*(y*y-a*a)))/(x*x-a*a)\n",
" else: # Deal with edge case when x^2=a^2\n",
" m = flip*(-a*a+y*y)/(a*y-flip*abs(a*y))\n",
" b = flip * a * math.sqrt(1+m*m)\n",
"\n",
" # Calculate equivalent tangent point on circle\n",
@@ -108,11 +114,11 @@
" # Calculate base angle, make angle negative if flip=1\n",
" theta = math.atan2(cy, cx) + (-math.pi if flip==1 else 0)\n",
"\n",
" return theta\n",
" return theta \n",
" \n",
" base_theta = calculate_theta(x, y, l_bs)\n",
" cx, cy = l_bs*math.cos(base_theta), l_bs*math.sin(l_bs)\n",
" r = math.sqrt((x-cx)**2 + (y-cy)**2) - 0.1\n",
" cx, cy = l_bs*math.cos(base_theta), l_bs*math.sin(base_theta)\n",
" r = math.sqrt((x-cx)**2 + (y-cy)**2) \n",
"\n",
"\n",
" # Formulas to find out joint positions for (r, z)\n",
@@ -120,7 +126,7 @@
" a, b, c = p \n",
"\n",
" return (l1*math.cos(a) + l2*math.cos(a-b) + l3*math.cos(a-b-c) - r, # r\n",
" l1*math.sin(a) + l2*math.sin(a-b) - l3*math.sin(a-b-c) - (z+offset_z), # z\n",
" l1*math.sin(a) + l2*math.sin(a-b) - l3*math.sin(a-b-c) - (l3*math.sin(a-b-c)) - (z + offset_z), # z\n",
" a-b-c) # wrist angle\n",
"\n",
"\n",
@@ -130,123 +136,48 @@
" # Return result\n",
" return base, shoulder, elbow, wrist1, ry, rz\n",
"\n",
"def get_joints_from_xyz_abs(x, y, z):\n",
" joints = get_joints_from_xyz_rel(x, y, z)\n",
"def get_joints_from_xyz_abs(x, y, z, rx=0, ry=-math.pi/2, rz=math.pi/2):\n",
" joints = get_joints_from_xyz_rel(x, y, z, rx, ry, rz)\n",
"\n",
" # Joint offsets\n",
" # Base, Shoulder, Elbow, Wrist\n",
" inverse = [1, -1, 1, 1, 1, 1]\n",
" offsets = [-math.pi/2, 0, 0, -math.pi/2, -math.pi/2, 0]\n",
" offsets = [-math.pi/2, 0, 0, -math.pi/2, 0, 0]\n",
"\n",
" # Return adjusted joint positions\n",
" return [o+j*i for j, o, i in zip(joints, offsets, inverse)]\n",
" robot_angles = [o+j*i for j, o, i in zip(joints, offsets, inverse)]\n",
"\n",
"# print([math.degrees(deg) for deg in get_joints_from_xyz_rel(0.3, 0.3, 0.3)])\n",
"print([math.degrees(deg) for deg in get_joints_from_xyz_abs(0, -0.3, 0.1)])"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"no flip\n"
]
},
{
"data": {
"text/plain": [
"-126.86989764584402"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def calculate_theta(x, y, a):\n",
" # Calculate if we need the + or - in our equations\n",
" if (x>a and y>=0) or (x>-a and y<0):\n",
" print('no flip')\n",
" flip = 1\n",
" elif (x<a and y>=0) or (x<-a and y<0):\n",
" print('flip')\n",
" flip = -1\n",
" else: \n",
" print('critical')\n",
" # Critical section (x=a, or x=-a). Infinite slope\n",
" # Return 0 or 180 depending on sign\n",
" return math.atan2(y, 0)\n",
" \n",
" # Calculate tangent line y = mx + b\n",
" m = (x*y + math.sqrt(x*x*y*y-(x*x-a*a)*(y*y-a*a)))/(x*x-a*a)\n",
" b = flip * a * math.sqrt(1+m*m)\n",
" return robot_angles\n",
"\n",
" # Calculate equivalent tangent point on circle\n",
" cx = (-flip*m*b)/(1+m*m)\n",
" cy = m*cx + flip*b\n",
"\n",
" # Calculate base angle\n",
" theta = math.atan2(cy, cx) + (-math.pi if flip==1 else 0)\n",
"\n",
" return theta\n",
"\n",
"calculate_theta(5,-5,1)"
"# Print degree rotation for each joint (robot angles)\n",
"[math.degrees(deg) for deg in get_joints_from_xyz_abs(-0.2, -0.5, 0.1)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Simulate arm and joint angles"
"### Simulate Arm and Joint Angles"
]
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"no flip\n",
"Target position (x,y,z): 0.3 0.3 0.3\n",
"Angles (base, shoulder, elbow, wrist): [-25.7322, 113.4225, 127.6133, -14.1908]\n",
"no flip\n",
"Robot Angles: [-115.7322, -113.4225, 127.6133, -104.1908]\n",
"elbow (x,y): -0.168 0.388\n",
"wrist (x,y): 0.18 0.3\n",
"tool (x,y): 0.33 0.3\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlkAAAGxCAYAAABRB6M1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAABV60lEQVR4nO3deVxVBfrH8c8FBNxAFAVRFHet3HIhzFwmEqtfZVOTmpNKlo3t0aLWJDY2YeWUpqblpNlUozWTTqvloNgiLqmMVmpqGmkCboBigsL5/XH14lWWc4HD5V6+79frvCbOfc65z702+eUsz7EZhmEgIiIiIlXKx90NiIiIiHgjhSwRERERCyhkiYiIiFhAIUtERETEAgpZIiIiIhZQyBIRERGxgEKWiIiIiAUUskREREQsoJAlIiIiYgGFLBERERELKGS54Msvv+SGG24gIiICm83G8uXLHa+dPn2aiRMn0rVrV+rXr09ERASjR4/m119/ddSkpKRgs9lKXDZu3Fjme6empvK73/2O+vXrExQUxIABA/jtt98cr//1r3+lX79+1KtXj0aNGpW4jw8//JCOHTvSqVMnPv7440p9FyIiIlI2hSwX5OXl0b17d+bOnXvRaydPnmTz5s08/fTTbN68mQ8++ICdO3dy4403Omr69evHwYMHnZa77rqLNm3a0Lt371LfNzU1laFDhzJkyBA2bNjAxo0buf/++/HxKf7jKygo4A9/+AMTJkwocR/5+fncd999vPrqq8yZM4cJEyZQUFBQiW9DREREymLTA6IrxmazsWzZMoYNG1ZqzcaNG+nbty8///wzrVq1uuj106dP06JFCx544AGefvrpUvdzxRVXcM011zBt2rRy+3rzzTd5+OGHyc7Odlqfm5tLt27d+PbbbwHo06cPW7dupWHDhuXuU0RERFynI1kWysnJwWazlXn67siRI8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8Cbdmw+9WwqVP2qe929x8Z2D+IUh/HzbeC590gWUR8M1I2P065O6yD3MVEZFayeUjWUuXLmX06NHMnz+f6OhoZs6cyfvvv8/OnTtp1qzZRfUpKSkcO3aMzp074+/vz8cff8yjjz7KJ598QlxcHGAPWZmZmSxatMixXUBAACEhIaZ6cueRLLDfOTjbRF1d7OMcGlvbTu1y+oT94vmsFPvRrqPfglHo7q6K1W1RfKQrbDDUb6MjXSIitYTLISs6Opo+ffowZ84cAIqKioiMjOSBBx5g0qRJpvZx+eWXc/311zNt2jTAHrKys7NZvny5a92f5e6QtQvoBJj5IqcDE61tp3Y7nQtZX9sfdJ2ZAsc22wem1hT1Wl0Qulq7uyMREbGIS6cLCwoK2LRpE7GxxY899vHxITY2ltTU1HK3NwyD5ORkdu7cyYABA5xeS0lJoVmzZnTq1IkJEyZw5MiRUveTn59Pbm6u0+JOHYDrTNbOBc5Y2EutVycIWlwHPV+EoRvhliMw4EPonGCfgYWbjyKdTIe9b8G6ePhPFPynDay7E/b+A06aeSKmiIh4CpcuaDl8+DCFhYWEhYU5rQ8LC2PHjh2lbpeTk0OLFi3Iz8/H19eXV199lWuuucbx+tChQ/n9739PmzZt2LNnD08++STXXnstqamp+PpePBgyKSmJZ555xpXWLfcQ8ImJul+A5cCtlnYjDv6NoOUN9gUg/6h9Cv2504vZW93ZHeTtg58W2ReLine truncated
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"def draw_arm(x, y, z):\n",
"def draw_arm_side_view(x, y, z, details=False):\n",
"\n",
" # Get joint angles\n",
" l1, l2, l3 = (.422864, .359041, .15)\n",
" offset_x, offset_y, offset_z = (0.145, 0, 0.195)\n",
" l1, l2, l3 = .425, .39225, .1267\n",
" offset_x, offset_y, offset_z = (0, 0, 0.14)\n",
" r, theta = cartesian_to_polar(x, y)\n",
" base, shoulder, elbow, wrist = get_joints_from_xyz_rel(x, y, z)\n",
" base, shoulder, elbow, wrist, _, _ = get_joints_from_xyz_rel(x, y, z)\n",
"\n",
" # Print angles\n",
" if details:\n",
" print('Target position (x,y,z):', x, y, z)\n",
" print('R: ', round(math.sqrt(x**2+y**2),4))\n",
" print('Angles (base, shoulder, elbow, wrist):', [round(math.degrees(i), 4) for i in [base, shoulder, elbow, wrist]])\n",
" print('Robot Angles:', [round(math.degrees(i), 4) for i in get_joints_from_xyz_abs(x, y, z)])\n",
"\n",
@@ -263,6 +194,7 @@
" ty = y3 - offset_z\n",
"\n",
" # Print each joint's endpoint position\n",
" if details:\n",
" print('elbow (x,y):', round(x1,3), round(y1,3))\n",
" print('wrist (x,y):', round(x2,3), round(y2,3))\n",
" print('tool (x,y):', round(x3,3), round(y3,3))\n",
@@ -287,37 +219,126 @@
"\n",
" # Display z arrow\n",
" plt.annotate(f'', xy=(x3, 0), xycoords='data', xytext=(tx, ty), textcoords='data', arrowprops={'arrowstyle': '<->'})\n",
" plt.annotate(f'z={round(ty,4)}', xy=(x3+0.01, y2/2), xycoords='data', xytext=(x3/2, 0), textcoords='offset points')\n",
" plt.annotate(f'z={round(ty,4)}', xy=(tx+0.01, ty/2), xycoords='data', xytext=(x3/2, 0), textcoords='offset points')\n",
" \n",
" # Display plot\n",
" ax = plt.subplot(111)\n",
" ax.spines[['right', 'top']].set_visible(False)\n",
" plt.axis('equal')\n",
" plt.show()\n",
"\n",
"draw_arm(0.3, 0.3, 0.3)"
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def draw_arm_top_view(x, y, z, details=False):\n",
" # Get joint and position information\n",
" angles = get_joints_from_xyz_rel(x, y, z)\n",
" offset_x, offset_y, offset_z = (0, 0, 0.14) # Tool offset\n",
" l_bs, l1, l2, l3, l_wt = (0.1333, .425, .39225, .1267, .0997) # Limb lengths\n",
" cx, cy = l_bs*math.cos(angles[0]), l_bs*math.sin(angles[0]) # Base tangent point\n",
" line_angle = math.pi/2+angles[0]\n",
"\n",
" if details:\n",
" print('Angles:', [round(math.degrees(angle),3) for angle in angles])\n",
" print(f'Circle position (cx, cy): ({round(cx, 3)}, {round(cy, 3)})')\n",
"\n",
"\n",
" # Plot coordinate system\n",
" fig = plt.figure()\n",
" ax = fig.add_subplot(1, 1, 1)\n",
" ax.spines['left'].set_position('center')\n",
" ax.spines['bottom'].set_position('center')\n",
" ax.spines['right'].set_color('none')\n",
" ax.spines['top'].set_color('none')\n",
" ax.set_yticklabels([])\n",
" ax.set_xticklabels([])\n",
" ax.set_xticks([])\n",
" ax.set_yticks([])\n",
"\n",
" # Target point\n",
" # plt.plot(x, y, 'go')\n",
"\n",
" # Circle\n",
" circle = plt.Circle((0, 0), l_bs, color='b', fill=False, linewidth=1)\n",
" plt.plot([0, cx], [0, cy], color='b', linewidth=1)\n",
" ax.add_patch(circle)\n",
"\n",
" # Draw limbs\n",
" # Shoulder\n",
" x1, y1 = polar_to_cartesian(l1*math.cos(angles[1]), line_angle)\n",
" x1, y1 = cx+x1, cy+y1\n",
" z1 = l1*math.sin(angles[1])\n",
" plt.plot([cx, x1], [cy, y1], color='cyan', linewidth=3)\n",
"\n",
" # Elbow\n",
" x2, y2 = polar_to_cartesian(l2*math.cos(angles[1]-angles[2]), line_angle)\n",
" x2 += x1\n",
" y2 += y1\n",
" z2 = z1 + l2*math.sin(angles[1]-angles[2])\n",
" plt.plot([x1, x2], [y1, y2], color='orange', linewidth=2)\n",
"\n",
" # Wrist\n",
" x3, y3 = polar_to_cartesian(l3*math.cos(angles[1]-angles[2]-angles[3]), line_angle)\n",
" x3 += x2\n",
" y3 += y2\n",
" z3 = z2 + l3*math.sin(angles[1]-angles[2]-angles[3]) \n",
" plt.plot([x2, x3], [y2, y3], color='red', linewidth=2)\n",
"\n",
" # Print joint positions\n",
" if details:\n",
" print(f'Shoulder (x, y, z): ({round(x1,3)}, {round(y1,3)}, {round(z1,3)})')\n",
" print(f'Elbow (x, y, z): ({round(x2,3)}, {round(y2,3)}, {round(z2,3)})')\n",
" print(f'Wrist (x, y, z): ({round(x3,3)}, {round(y3,3)}, {round(z3,3)})')\n",
"\n",
" # Display angle\n",
" plt.text(0.01, -0.01-cy/abs(cy+0.00001)*0.02, f'{round(math.degrees(angles[0]), 2)}°', fontsize=7)\n",
"\n",
" # Display x arrow\n",
" sign = x3/abs(x3)\n",
" plt.annotate(f'', xy=(0, y3), xycoords='data', xytext=(x3, y3), textcoords='data', arrowprops={'arrowstyle': '<->'})\n",
" plt.annotate(f'x={round(x3,3)}', xy=(-0.1-sign*0.13, y3-0.015), xycoords='data', xytext=(x2/2, 0), textcoords='offset points')\n",
"\n",
" # Display y arrow\n",
" sign = y3/abs(y3)\n",
" plt.annotate(f'', xy=(x3, 0), xycoords='data', xytext=(x3, y3), textcoords='data', arrowprops={'arrowstyle': '<->'})\n",
" plt.annotate(f'y={round(y3,3)}', xy=((x3-0.1), -0.015-sign*0.03), xycoords='data', xytext=(x3/2, 0), textcoords='offset points')\n",
"\n",
"\n",
" # Set axis limits and labels\n",
" axis_limit = math.hypot(x, y)+.1\n",
" plt.axis('square')\n",
" plt.xlim(-axis_limit, axis_limit)\n",
" plt.ylim(-axis_limit, axis_limit)\n",
"\n",
" # Adjust the position of axis labels\n",
" plt.xlabel('+x', horizontalalignment='right', x=1.05)\n",
" plt.ylabel('+y', verticalalignment='top', rotation=0, y=1.05)\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Target position (x,y,z): 0.3 0.3 0.3\n",
"Angles (base, shoulder, elbow, wrist): [33.9862, 85.2162, 73.3858, 11.8304]\n",
"Robot Angles: [33.9862, -85.2162, 73.3858, -78.1696]\n",
"elbow (x,y): 0.035 0.421\n",
"wrist (x,y): 0.387 0.495\n",
"tool (x,y): 0.537 0.495\n"
"Angles: [-53.867, 89.583, 87.39, 2.193, -90.0, 0.0]\n",
"Circle position (cx, cy): (0.079, -0.108)\n",
"Shoulder (x, y, z): (0.081, -0.106, 0.425)\n",
"Elbow (x, y, z): (0.398, 0.125, 0.44)\n",
"Wrist (x, y, z): (0.5, 0.2, 0.44)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGlCAYAAAAoK/bpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA/xklEQVR4nO3deXRU9f3/8VcWskB2AmELRBJlFYIJyTdYFjWAwEHo12/FFRotWgsWmtYKLgQEDSpfi9+KqCjo0R+CWlyOWpCm0qqkBhNSEIQKAhEkYc+EIBPI3N8fwYGRBGZCZrkzz8c5c+rcfO6d91wovPjczxJkGIYhAAAALwn2dgEAACCwEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAAIBXEUYAwE/885//1NixY9WpUycFBQXp3Xffdfj5qlWrNGLECLVt21ZBQUEqLy936roLFy5Ujx49FBkZqeTkZP3ud7/TyZMn7T9fvHix+vXrp5iYGMXExCgnJ0d//etfHa6xfft2XX311erSpYvmzZt3qV8VfoYwAgB+ora2Vv3799eiRYua/PnPfvYzPfHEE05fc/ny5ZoxY4YKCgr09ddf6+WXX9bKlSv14IMP2tt06dJF8+fPV2lpqb788ktde+21GjdunLZs2WJvM3XqVN1+++1677339N5772n9+vXN/6LwO6HeLgAA0DJGjRqlUaNGNfnzO+64Q5K0e/dup6+5fv16XX311br11lslSSkpKbrlllv0xRdf2NuMHTvW4ZzHHntMixcv1r/+9S/16dNHknT06FFlZGSoX79+6tSpk44dO+Z0DfB/9IwAAJo0aNAglZaWqqSkRJL07bff6qOPPtLo0aMbbV9fX68VK1aotrZWOTk59uOPPvqocnNz1bp1awUHB2vkyJEeqR/mQM8IAKBJt956qw4dOqSf/exnMgxDp0+f1q9//WuHxzS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OHNHs2bNVXl6uXbt2KSSk8cWnli9frvbt26t79+764Ycf9Kc//UlvvfWWduzYoXbt2un7779X3759NWHCBE2fPl0Wi0XTp09Xx44d9fbbb0uSrFar0tLStGzZMhmGoTvvvFM7d+5UWJgPjEewHnac2XJkg3TygLerck5QiBR35TlTagc2jPsIpuMUcFZaWpp27tx5wTapqanasWOHhyoyF8IILmr69On64IMP9M033yiokSW2N23apP79+2vHjh1KTU116po//pr+7W9/03XXXacXX3xRjzzyiPbv36/g4IYOu82bN6tfv3765ptvlJaWJovFon79+unLL7+UJA0cOFCbNm1SdLSHxyicrpWObHQMHse/9WwNlyIqzXGAaXy6FNra21UBpkYYuTT80wcXVFdXp9dff135+fmNBpHa2lotW7ZMl112mZKTk52+5osvvqjY2Fj1799fUkOvR1hYmD2ISFJkZMNKm5999pnS0tIUExOjvLw8dezYUUFBQZo3b577g4jtlFS9xXFmS/VX5llILCJJapt9NngkZErhCd6uCgAcEEZwQe+++66OHTumX/7ylw7Hn3vuOf3xj39UbW2tevToobVr1170cckHH3ygm2++WSdOnFDHjh21du1aJSYmSpKuvfZa5efn66mnntK0adNUW1urGTNmSJL2799vv0ZBQYGmT5+u4ODglg8ihiELine truncated
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAGYCAYAAAB/O/RVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAoc0lEQVR4nO3dd3TUVd7H8U86IY2eAEqzAIYSESSCrpQosnrEVQE1NBVQhBWeR9xdHxUF14BlFVBZVARkUWQtlMUKCIiUEEVAcEFQECWhaCAEklCS+/xxITFSTDR3fpPk/TpnTs7cmfnNdwhnPrm/W34BxhgjAADKWKDXBQAAKiYCBgDgBAEDAHCCgAEAOEHAAACcIGAAAE4QMAAAJwgYAIATBAwAwAkCBgDgBAEDAHCCgEGF16lTJ02f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ffmnHlVu2tL2cLl2kbdt8V0ellPVf6cNLpa2Titoa3CjN2yldN8S7ulCIgEG5smOHdM01Uv/+9ud//ys9/LAdrPdSQID0hz9Ib74pLVxoZ621bGknLR0/7m1tFY4x0rYp0geXSAe+tG1BVaR2/5Quf0sKre5tfShEwKBcOLlLine truncated
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
@@ -329,48 +350,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Target position (x,y,z): -0.3 -0.3 0.7\n",
"Angles (base, shoulder, elbow, wrist): [-117.3239, 78.0693, 0.0255, 79.0945]\n",
"Robot Angles: [-117.3239, -78.0693, 0.0255, -10.9055]\n",
"elbow (x,y): 0.087 0.414\n",
"wrist (x,y): 0.162 0.765\n",
"tool (x,y): 0.312 0.762\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\nadee\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\scipy\\optimize\\_minpack_py.py:178: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
" improvement from the last ten iterations.\n",
" warnings.warn(msg, RuntimeWarning)\n"
"Target position (x,y,z): 0.5 0.2 0.3\n",
"R: 0.5385\n",
"Angles (base, shoulder, elbow, wrist): [-53.8671, 89.5827, 87.3895, 2.1932]\n",
"Robot Angles: [-143.8671, -89.5827, 87.3895, -87.8068, -90.0, 90.0]\n",
"elbow (x,y): 0.003 0.425\n",
"wrist (x,y): 0.395 0.44\n",
"tool (x,y): 0.522 0.44\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGhCAYAAACzurT/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAABEj0lEQVR4nO3de1xUdf4/8NfMAAOI3EQuEkreoRIKhHBrbQsl8+ul+qZZCRFZv1ZbN9r9KqWgpm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sXFxcjMzERBQQESExORl5eHlJQUnDx5EsHBwW3qm5ubMWrUKAQHB+OTTz5BeHg4zp8/D39//+7on4hsiZNXiagbWBxGli1bhmnTpiE9PR0AUFBQgE2bNqGoqAizZ89uU19UVISamhrs3r0b7u7uAIDIyMiudU1E9oFP6iWibmDRaZrm5maUlZUhOTn51g6USiQnJ6O0tLTdbT7//HMkJSVh+vTpCAkJwZ133onFixdDp9OZfJ2mpibU1dUZLURkZ4QAaiSMjCiUQOA98vdDRA7LojBSXV0NnU6HkBDjiWghISHQaDTtbnPmzBl88skn0Ol02Lx5M+bOnYu//OUvWLhwocnXyc3NhZ+fn2GJiIiwpE0isobGcuB6lfk6vzsBtx7Line truncated
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Target position (x,y,z): -0.3 0.4 0.2\n",
"Angles (base, shoulder, elbow, wrist): [111.1813, 100.8341, 104.0795, -3.2455]\n",
"Robot Angles: [111.1813, -100.8341, 104.0795, -93.2455]\n",
"elbow (x,y): -0.079 0.415\n",
"wrist (x,y): 0.279 0.395\n",
"tool (x,y): 0.429 0.395\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGnCAYAAACZ9nwoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA7Y0lEQVR4nO3dfXQU9b3H8c9uQhIgDxAiCdAAStSoCOESEuMtiDU13nqxVHuLlCM0ctBW4Lbm2ipFQS0YiqhUpXJF1KpQ0Fq0UkUxwFVsGhATeZJUKBhENjw1CQRIQnbuHyurK3mYTTLZ2d3365w5sLPf2f3OiOHD/H4z4zAMwxAAAIANOQPdAAAAQHMIKgAAwLYIKgAAwLYIKgAAwLYIKgAAwLYIKgAAwLYIKgAAwL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X388ccqKytTWVmZ3nzzTUnSypUrNXfu3CY/d/jw4erSpYvP55aXl6uiosL7uSdPnpTT6ZTD4fDWnH3tdrs7fF8BAGiPyNZLAs8wDB0/flxxcXE+f8Ha2YkTJ7R7927v671796qsrEyJiYnq37+/fvGLX2jOnDm68MILdf755+u+++5T3759NXbsWElS//79fT4vNjZWkjRo0CB961vfkiQdOHBA11xzjV544QVlZWUpISFBkydPVkFBgRITExUfH6/p06crJydHV1xxhSTpu9/9rn75y19q6tSpmj59utxut+bNm6fIyEhdffXVnXBkAAAwLyiCyvHjx5WQkKDq6mrFx8cHuh1TPvzwQ5+/+AsKCiRJkyZN0vPPP69f/epXqq2t1W233aaqqip9+9vf1po1axQTE2P6OxoaGlReXq6TJ0961z322GNyOp266aabVFdXp7y8PP3+97/3vp+enq433nhDDzzwgHJycuR0OjVs2DCtWbNGffr06YA9BwCg4zgMwzAC3URrampqgi6oAACA9mOOCgAAsC2CCgAAsC2CCgAAsC2CCgAAsC2CCgAAsC2CCgCEifvvv1/p6enq3r27evbsqdzcXJWUlLS4TWFhoUaMGKG4uDj17t1bY8eOVXl5uU/N6NGj5XA4fJaf/vSnPjV/+ctfdNFFF+niiy/W6tWrO3zfELq4PBkAwsTy5cvVu3dvXXDBBTp16pQee+wxvfLKK9q9e7fOO++8Jre57rrrdPPNN2vEiBE6c+aMfv3rX2v79u3auXOnunfvLskTVC666CI9+OCD3u26devm/XldV1entLQ0PffcczIMQ7feeqv27NmjqKgo63caQS8obvgGAGi/H//4xz6vH330US1dulRbt27VNddc0+Q2a9as8Xn9/PPPq3fv3tqyZYtGjRrlXd+tWzfvM8W+qa6uThEREcrIyJAkRUZGqq6ujqACUxj6sYgh6bNANwEAzaivr9fTTz+thIQEDR061PR21dXVkqTExESf9cuWLVNSUpIGDx6sGTNm+NwxOz4+Xvn5+erTp4/69u2rn/3sZ4qLi+uYHUHIY+inPfYukw6/p8YuCTrcJV6fdUnQ7i7x2tklQVu7xOuLqAT9X2S8YqMSpC7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LVmyRElJSaa3mzFjhgoKCryva2pqlJqaakWLHSJkJtTCWhHRUsR5nn/ZtpVh+N57p62h50xtx+0XAFjIr6CSlJSkiIgIVVb6xvfKykqlpJx7pciePXu0b98+jRnz1XkEt9uLine truncated
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGmCAYAAACuv4RHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA2kElEQVR4nO3df1yV9d3H8Tc/5KeCGgaBCIrd4m8cJGG3P1akOZc/ZstaCyJnLbVl3DU1J1RmWJm5mdNmaaYZ1X1n7UdpRrHNopulUqZl6eb8MUHdChQa6DnX/Ye3J48C5zrIlwP6ej4e5zHPxfe6zve6bH7efK/r+z1+lmVZAgAA8BF/X3cAAABc3AgjAADApwgjAADApwgjAADApwgjAADApwgjAADApwgjAADApwgjAADApwgjAADApwgjAADApwgjAIAGFRQU6IorrlCHDh106aWXavz48dq1a1ej++zYsUMTJ05UYmKi/Pz8tHjx4nPaHDt2TDNmzFBCQoJCQ0M1ZMgQ/eUvf3FrU15ertGjRys2NlbTp0+X0+lszlNDK0IYAQA06I9//KOmTZumDz/8UJs2bdKJEyc0cuRIVVdXN7hPTU2NevTooQULFigmJqbeNj/5yU+0adMmrVmzRtu3b9fIkSOVmZmpgwcPutrMnTtXaWlpeuutt/TXv/5VhYWFzX5+aB38+KI8AIBdR44c0aWXXqo//vGPGjZsmMf2iYmJmjFjhmbMmOHa9s0336hDhw564403NGbMGNf21NRUjR49Wo888ogk6YYbbtCNN96oG264QT/72c/Up08fTZ06tdnPCb7HyAgAwLbKykpJUufOnZt8jJMnT8rhcCgkJMRte2hoqDZv3ux6P2vWLN19990KDg7W1q1blZWV1eTPROsW6OsOAADaBqfTqRkzZuiqq65Sv379mnycDh06KCMjQ/PmzVPv3r0VHR2tl156SSUlJerZs6erXVpamg4ePKijR482eLsHFwZGRgAAtkybNk2ffvppszy7sWbNGlmWpbi4OAUHB+tXv/qVbr75Zvn7u5elwMBAgshFgDACAPBo+vTp+v3vf6/33ntPXbt2Pe/jJSUl6Y9//KOOHz+u/fv3q7S0VCdOnFCPHj2aobdoa9pEGLEsS1VVVeJZWwBoWZZlafr06Vq/fr3effddde/evVmPHx4erssuu0xfffWVNm7cqHHjxjXr8dE2tIlnRo4dO6bIyEhVVlYqIiLC190BgIvGtGnTtG7dOr3xxhvq0KGDysvLJUmRkZEKDQ2VJGVlZSkuLk4FBQWSpLq6Ou3cudP154MHD6qsrEzt27d3PROyceNGWZalXr16affu3br//vuVnJysnJwcH5wlfK1NTO2tqqoijACAD/j5+dW7fdWqVbrtttskSSNGjFBiYqKef/55SdLevXvrHUEZPny4iouLJUmvvPKKZs+erQMHDqhz586aOHGi5s+fr8jISBOngVaOMAIAAHyqTTwzciFyOByaO3euunfvrtDQUCUlJWnevHluz8X4+fnV+3riiScaPO6yZcs0YMAARUREKCIiQhkZGXrrrbfc2uzZs0cTJkxQly5dFBERoRtvvFEVFRVubUpKSpSSkqLExEQ999xzzXvyAACcgTDiI4899piWLVump59+Wp999pkee+wxPf7441qyZImrzaFDh9xeK1eulJ+fnyZOnNjgcbt27aoFCxZoy5Yt+uijj3T11Vdr3Lhx2rFjhySpurpaI0eOlJ+fn9599129//77qqur0/XXX+/2vQ+TJ0/W3LlztW7dOhUUFGj//v3mLgYA4KLGbRof+f73v6/o6Gi3UYeJEycqNDRUa9eurXef8ePH69ixYyoqKvLqszp37qwnnnhCkydP1ttvv63Ro0frq6++cl3LyspKderUSW+//bYyMzMlSQkJCSouLtall16qESNGaPXq1erTp08TzxYAgIYxMuIjQ4YMUVFRkb744gtJ0scff6zNmzdr9OjR9bavqKjQH/7wB02ePNn2ZzgcDhUWFqq6uloZGRmSpNraWvn5+Sk4ONjVLiQkRP7+/m7LMOfl5al3796KjIzUlVdeSRABABjTJqb2XohmzZqlqqoqJSc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bw/g76/MzEyVlJQ0uN/DDz+sSy+9VJMnT7b1ObW1taqqqnJ7tUWMjAAA4JlXdfDo0aNyOByKjo522x4dHa3y8vJ699m8ebOee+45rVixwvbnFBQUKDIy0vWKj4/3pputBmEEAADPjNbBY8eO6dZbb9WKFSsUFRVle7/Zs2ersrLS9dq/f7/BXppDGAEAwLNAbxpHRUUpICBAFRUVbtsrKioUExNzTvs9e/Zo7969uv76613bnM5TJTowMFC7du1SUlLSOfsFBwcrODjYm661SoQRAAA886oOBgUFKTU1VUVFRa5tTqdTRUVFysjIOKd9cnKytm/frrKyMtdr7Nix+u53v6uysrI2e/vFLqb2AgDgmVcjI5KUm5ur7OxspaWlafDgwVq8eLGqq6uVk5MjScrKylJcXJwKCgoUEhKifv36ue3fsWNHSTpn+4WIkREAADzzOoxMmjRJR44cUV5ensrLy5WSkqINGza4Hmrdt2+f/P0prxJTewEAsMPPsiy7NdNnqqqqFBkZqcrKSkVERPi6O7Z9ImmgjXb3SXrCcF8AAK1bz549tWfPnkbbJCUlaffu3S3Uo5bDL+UGcZsGAADPqIMGEUYAAPCMOmgQYQQAAM+ogwYRRgAA8Iw6aBDrjAAA4BlhxCBGRgAA8Iw6aBDrjAAA4Bl10CBGRgAA8Iw6aBBhBAAAz6iLine truncated
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
@@ -380,63 +371,76 @@
}
],
"source": [
"draw_arm(0.3, 0.3, 0.3)\n",
"draw_arm(-0.3, -0.3, 0.7)\n",
"draw_arm(-0.3, 0.4, 0.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive Arm"
"def draw_arm(x, y, z, details=False):\n",
" draw_arm_top_view(x,y,z, details=details)\n",
" draw_arm_side_view(x,y,z, details=details)\n",
"\n",
"draw_arm(0.5,0.2,0.3, details=True)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "30dd696bcdc14aec9a1d4c17fb4787d4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.3, description='x', max=1.0, step=0.01), FloatSlider(value=0.3, desc…"
"{'elbow': (0.06441407671759522, -0.08297834710053949, 0.42498873000714044),\n",
" 'wrist': (0.3809831975755794, 0.14814654552767514, 0.44000000000002354),\n",
" 'wrist2': (0.4617483203289997, 0.20711259462904327, 0.44000000000002354),\n",
" 'tool': (0.4617483203289997, 0.20711259462904327, 0.5800000000000236)}"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.draw_arm(x, y, z)>"
]
},
"execution_count": 19,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from ipywidgets import interact, FloatSlider\n",
"def joint_positions(x, y, z):\n",
" # Get joint and position information\n",
" angles = get_joints_from_xyz_abs(x, y, z)\n",
" offset_x, offset_y, offset_z = (0, 0, 0.14) # Tool offset\n",
" l_bs, l1, l2, l3, l_wt = (0.1333, .425, .39225, .1267, .0997) # Limb lengths\n",
" cx, cy = l_bs*math.cos(angles[0]), l_bs*math.sin(angles[0]) # Base tangent point\n",
" line_angle = math.pi/2+angles[0]\n",
"\n",
"# Interactive slider for z coordinate\n",
"interact(draw_arm, x=FloatSlider(min=0, max=1, step=0.01, value=0.3),\n",
" y=FloatSlider(min=0, max=1, step=0.01, value=0.3),\n",
" z=FloatSlider(min=0, max=1, step=0.01, value=0.3))\n"
" # Elbow\n",
" x1, y1 = polar_to_cartesian(l1*math.cos(angles[1]), line_angle)\n",
" x1, y1 = cx+x1, cy+y1\n",
" z1 = l1*math.sin(angles[1])\n",
"\n",
" # Wrist\n",
" x2, y2 = polar_to_cartesian(l2*math.cos(angles[1]-angles[2]), line_angle)\n",
" x2 += x1\n",
" y2 += y1\n",
" z2 = z1 + l2*math.sin(angles[1]-angles[2])\n",
"\n",
" # Wrist 2\n",
" x3, y3 = polar_to_cartesian(l3*math.cos(angles[1]-angles[2]-angles[3]), line_angle)\n",
" x3 += x2\n",
" y3 += y2\n",
" z3 = z2 + l3*math.sin(angles[1]-angles[2]-angles[3]) \n",
"\n",
" # Tool\n",
" x4, y4 = polar_to_cartesian(offset_z*math.cos(angles[1]-angles[2]-angles[3]-angles[4]), line_angle)\n",
" x4 += x3\n",
" y4 += y3\n",
" z4 = z3 + offset_z*math.sin(angles[1]-angles[2]-angles[3]-angles[4])\n",
"\n",
"\n",
" positions = {\n",
" 'elbow': (x1, y1, z1),\n",
" 'wrist': (x2, y2, z2),\n",
" 'wrist2': (x3, y3, z3),\n",
" 'tool': (x4, y4, z4)\n",
" }\n",
"\n",
" return positions\n",
"\n",
"joint_positions(0.5,0.2,0.3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Submodule
+1
Submodule jukebox-web added at 08eebd400b.
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
import fitz # PyMuPDF
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
import os
def generate_pdf(path="labels"):
# Open the existing PDF
image_folder_path = path
doc = fitz.open('label_template.pdf')
page = doc[0] # Assuming you want to read from the first page
placeholders = []
for shape in page.get_drawings():
if shape['type'] == 's': # Checking for rectangle types
placeholders.append({
'x': shape['rect'].x0,
'y': shape['rect'].y0,
'width': shape['rect'].width,
'height': shape['rect'].height
})
# List all PNG images in the folder
image_files = [f for f in os.listdir(image_folder_path) if f.endswith('.png')]
image_paths = [os.path.join(image_folder_path, file) for file in image_files]
# Create a new PDF with ReportLab
c = canvas.Canvas(path + "/print.pdf", pagesize=letter)
current_placeholder = 0 # Track the current placeholder index
for image_path in image_paths:
if current_placeholder >= len(placeholders): # Check if a new page is needed
c.showPage()
current_placeholder = 0 # Reset placeholder index for new page
# Get current placeholder
placeholder = placeholders[current_placeholder]
# Place image at the placeholder position
c.drawImage(image_path, placeholder['x'], page.rect.height - placeholder['y'] - placeholder['height'], width=placeholder['width'], height=placeholder['height'])
current_placeholder += 1
# Save the final PDF
c.save()
# Close the original PDF
doc.close()
if __name__ == "__main__":
generate_pdf("labels")
+13 -4
View File
@@ -9,6 +9,7 @@ import os
import signal
from PIL import Image
from label_image import generate_code
from label_document import generate_pdf
def input_cable():
@@ -22,7 +23,7 @@ def input_cable():
print("Input part number:", inputnum)
print("Searching databases for cables...")
# Search both AW and BL sites
status, output = get_multi(["BL"+inputnum, "AW"+inputnum], delay=0.1, dir="temp/" + str(uuid.uuid4()) + "/", cache=False)
status, output = get_multi(["BL"+inputnum, "AW"+inputnum], delay=0.1, dir="temp/" + str(uuid.uuid4()) + "/", webport=":9000", cache=False)
print("")
if len(output) > 1:
for i in output:
@@ -61,9 +62,17 @@ def input_cable():
imgstr = "BL"
elif output[1] == "Alphawire":
imgstr = "AW"
img = generate_code(imgstr + output[0])
os.makedirs("labels", exist_ok=True)
img.save("labels/" + imgstr + output[0] + ".png")
gen_label(imgstr + output[0])
#img = generate_code(imgstr + output[0])
#os.makedirs("labels", exist_ok=True)
#img.save("labels/" + imgstr + output[0] + ".png")
def gen_label(partnum, path="labels"):
img = generate_code(partnum)
os.makedirs(path, exist_ok=True)
img.save(path + "/" + partnum + ".png")
generate_pdf(path)
def delete_folder(path):
# Check if the path is a directory
+84 -2
View File
@@ -3,8 +3,13 @@ from util import fprint
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
#import cv2
import numpy as np
from util import find_data_file
import segno
import io
#import cairosvg
#import math
@@ -134,7 +139,8 @@ for charset in (CODE128A, CODE128B):
def generate_code(data, show=False, check=False):
img = code128_image(data)
#img = code128_image(data)
img = qr_image(data)
if show:
img.show()
#img.show()
@@ -198,6 +204,7 @@ def code128_format(data):
return codes
def code128_image(data, height=100, thickness=3, quiet_zone=False):
partnum = data
if not data[-1] == CODE128B['Stop']:
data = code128_format(data)
@@ -227,12 +234,87 @@ def code128_image(data, height=100, thickness=3, quiet_zone=False):
#draw.arc(((width - width/5, width - width/5), (width*9 + width/5, width*9 + width/5)),0,360,fill='blue', width = int(width/8))
draw.arc(((width+int(width / 1.4), width+int(width / 1.4)), (width*9-int(width / 1.4), width*9-int(width / 1.4))),0,360,fill='blue', width = int(width/8))
font_path = find_data_file("OCRAEXT.TTF")
font_size = width/2
font = ImageFont.truetype(font_path, font_size)
text_width = font.getlength(partnum)
while text_width > width*4:
font_size -= 1
font = ImageFont.truetype(font_path, font_size)
text_width = font.getlength(partnum)
txtx = (int(width * 10) - text_width) / 2
txty = (int(width * 10)) / 2 + width / 2
draw.text((txtx,txty),partnum, "black", font)
return img
def qr_image(data, width=600):
partnum = data
# Monochrome Image
img = Image.new('RGB', (int(width * 10), int(width * 10)), 'white')
draw = ImageDraw.Draw(img)
#svg_path = find_data_file("belden-logo.svg")
#with open(svg_path, 'rb') as svg_file:
# png_image = cairosvg.svg2png(file_obj=svg_file,dpi=width*30, scale=30, background_color="white")
#with open("output.png", 'wb') as file:
# file.write(png_image)
png_image_io = "belden-logo-superhires.png"
png_image_pillow = Image.open(png_image_io)
png_width, png_height = png_image_pillow.size
png_image_pillow = png_image_pillow.resize((int(width*4), int(width*4/png_width*png_height)))
png_width, png_height = png_image_pillow.size
# paste belden logo first because it has a big border that would cover stuff up
img.paste(png_image_pillow, (int(width*5-png_width/2), int(width*3.25 - png_height/2)))
# draw circle border
#draw.arc(((width - width/5, width - width/5), (width*9 + width/5, width*9 + width/5)),0,360,fill='blue', width = int(width/8))
draw.arc(((width+int(width / 1.4), width+int(width / 1.4)), (width*9-int(width / 1.4), width*9-int(width / 1.4))),0,360,fill=(0, 73,144), width = int(width/8))
font_path = find_data_file("GothamCond-Medium.otf")
font_size = width/2
font = ImageFont.truetype(font_path, font_size)
text_width = font.getlength(partnum[2:])
# shrink font dynamically if it's too long of a name
while text_width > width*4:
font_size -= 1
font = ImageFont.truetype(font_path, font_size)
text_width = font.getlength(partnum[2:])
txtx = (int(width * 10) - text_width) / 2
txty = (int(width * 7.5)) / 2
# draw part number text
draw.text((txtx,txty),partnum[2:], "black", font)
# Draw QR code
partnum = partnum.replace(" ", "%20")
qrcode = segno.make('HTTPS://BLDN.APP/' + partnum,micro=False,boost_error=False,error="L",mask=3)
out = io.BytesIO()
qrx, _ = qrcode.symbol_size(1,0)
qrcode.save(out, scale=width*3/qrx, kind="PNG", border=0)
qrimg = Image.open(out)
img.paste(qrimg, box=(int(width*3.5),int(width*4.5)))
img = img.crop((width+int(width / 1.4)-int(width/8),width+int(width / 1.4)-int(width/8),img.size[0] - (width+int(width / 1.4)-int(width/8)), img.size[1] - (width+int(width / 1.4)-int(width/8)) ))
img = img.resize((1200, 1200), Image.LANCZOS) # 1200 dpi
return img
if __name__ == "__main__":
#print(generate_code("BL10GXS13"))
#print(generate_code("BL10GXgd35j35S13"))
#print(generate_code("BL10GX54hS13"))
print(generate_code("BL10Gj34qXS13", False, False))
#print(generate_code("BL10Gj34qXS13", False, False))
#print(generate_code("BL104w5545dp7bfwp43643534/4563G-XS13"))
#adjust_image(cv2.imread('test_skew.jpg'))
path = "labels"
img = generate_code("BL10GXS13")
import os
os.makedirs(path, exist_ok=True)
img.save(path + "/" + "BL10GXS13" + ".png")
+2064
View File
File diff suppressed because it is too large. Load diff
+476 -314
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
python led_control.py
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

After

Width:  |  Height:  |  Size: 344 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 41 KiB

+1
View File
@@ -0,0 +1 @@
56
+42 -15
View File
@@ -4,29 +4,54 @@ import cv2
import banner_ivu_export
import numpy as np
from util import fprint
import requests
class qr_reader():
camera = None
def __init__(self, ip, port):
self.camera = banner_ivu_export.DriveImg(ip, port)
self.ip = ip
self.port = port
self.url = "http://" + ip + ":" + str(port) + "/barcode"
#self.camera = banner_ivu_export.DriveImg(ip, port)
# def read_qr(self, tries=1):
# print("Trying " + str(tries) + " frames.")
# self.camera = banner_ivu_export.DriveImg(self.ip, self.port)
# for x in range(tries):
# print(str(x) + " ", end="", flush=True)
# imgtype, img = self.camera.read_img()
# if img is not None:
# #fprint(imgtype)
# image_array = np.frombuffer(img, np.uint8)
# img = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
# #cv2.imshow('Image', img)
# #cv2.waitKey(1)
# detect = cv2.QRCodeDetector()
# value, points, straight_qrcode = detect.detectAndDecode(img)
# if value != "":
# self.camera.close()
# return value
# else:
# print("\nGot no image for " + str(x))
# self.camera.close()
# return False
def read_qr(self, tries=1):
print("Trying " + str(tries) + " frames.")
for x in range(tries):
try:
imgtype, img = self.camera.read_img()
#fprint(imgtype)
image_array = np.frombuffer(img, np.uint8)
img = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
#cv2.imshow('Image', img)
#cv2.waitKey(1)
detect = cv2.QRCodeDetector()
value, points, straight_qrcode = detect.detectAndDecode(img)
return value
except:
continue
response = requests.get(self.url, timeout=tries * 15)
response.raise_for_status() # Raise an error for bad status codes
print(response.text) # Or handle the response as needed
if len(response.text) < 8:
return False
return response.text
except requests.Timeout:
print(f'The request timed out after {tries * 15} seconds')
except requests.RequestException as e:
print(f'An error occurred: {e}')
return False
class video_streamer():
camera = None
@@ -41,5 +66,7 @@ class video_streamer():
if __name__ == "__main__":
test = qr_reader("192.168.1.125", 32200)
import time
while True:
fprint(test.read_qr(5))
fprint(test.read_qr(300))
time.sleep(1)
+145 -29
View File
@@ -16,6 +16,8 @@ from util import win32
import os
import glob
import sys
from PIL import Image
import segno
def touch(path):
with open(path, 'a'):
@@ -37,7 +39,7 @@ def extract_table_name(table_start, searchpage, reader, dstype, fallbackname):
ymax = table_start + 10
elif dstype == "Alphawire":
ymin = table_start - 5
ymax = table_start + 10
ymax = table_start + 20
page = reader.pages[searchpage - 1]
parts = []
def visitor_body(text, cm, tm, fontDict, fontSize):
@@ -52,14 +54,52 @@ def extract_table_name(table_start, searchpage, reader, dstype, fallbackname):
return text_body
#fprint(text_body)
def parse(filename, output_dir, partnum, dstype):
def find_file_noext(directory, prefix="part-hires"):
"""
Find files in the specified directory that start with the given prefix and have any extension.
:param directory: The directory to search in.
:param prefix: The prefix to search for.
:return: A list of matching file names.
"""
# Get all files and directories in the specified directory
entries = os.listdir(directory)
# Filter files that match 'filename.EXTENSION'
matching_files = [file for file in entries if os.path.isfile(os.path.join(directory, file)) and file.split('.')[0] == prefix and len(file.split('.')) == 2]
#print(directory, matching_files)
return matching_files
def rotate_and_crop_image(path, image_name, force_rotate=False, partnum=""):
# Open the image file
fprint("Generating thumbnail image for part " + partnum)
image_path = path + "/" + image_name
with Image.open(image_path) as img:
# Check if the image is wider than it is tall
if force_rotate or img.width > img.height * 1.2:
# Rotate the image by 90 degrees counter-clockwise
img = img.rotate(90, expand=True)
# Determine the size of the square (the length of the shorter side of the image)
square_size = min(img.width, img.height)
if img.height < img.width:
offset = (img.width - img.height)/2
img_cropped = img.crop((offset, 0, square_size+offset, square_size))
else:
# Crop the image to a square from the top
img_cropped = img.crop((0, 0, square_size, square_size))
# Save or display the image
img_cropped.save(path + "/" + "thumbnail-" + image_name) # Save the cropped image
def parse(filename, output_dir, partnum, dstype, weburl, extra):
tables = []
# Extract table data
try:
if dstype == "Belden":
tables = camelot.read_pdf(filename, pages="1-end", flavor='lattice', backend="ghostscript", split_text=False, line_scale=100, process_background=True, resolution=600, interations=1, layout_kwargs={'detect_vertical': False, 'char_margin': 0.5}, shift_text=['r', 't'])
elif dstype == "Alphawire":
tables = camelot.read_pdf(filename, pages="1-end", flavor='lattice', backend="ghostscript", split_text=False, line_scale=50, process_background=True, resolution=600, interations=1, layout_kwargs={'detect_vertical': True, 'char_margin': 0.5}, shift_text=['l', 't'])
tables = camelot.read_pdf(filename, pages="1-end", flavor='lattice', backend="ghostscript", split_text=False, line_scale=50, process_background=True, resolution=600, interations=1, layout_kwargs={'detect_vertical': True, 'char_margin': 0.5}, shift_text=['l', 'b'])
except (OSError, RuntimeError) as e:
print(e)
if win32:
@@ -95,11 +135,26 @@ def parse(filename, output_dir, partnum, dstype):
#fprint(table_start)
text_body = extract_table_name(table_start, table.page, reader, dstype, n)
#print(text_body)
table_list[text_body] = table.df
#print(table_list[text_body])
if dstype == "Alphawire":
table_list_raw[text_body] = table
def reorder_row(row):
# Filter out NaNs and compute the original non-NaN values
non_nans = row[~row.isnull()]
# Create a new row with NaNs filled at the end
new_row = pd.Series(index=row.index)
new_row[:len(non_nans)] = non_nans
return new_row
# Apply the function to each row and return a new DataFrame
#table_list[text_body] = table.df.apply(reorder_row, axis=1)
#print(table_list[text_body])
table_list_raw[text_body] = table
#print(tbl)
#table.to_html("table" + str(n) + ".html")
#fprint(table.df)
@@ -134,6 +189,27 @@ def parse(filename, output_dir, partnum, dstype):
fp.write(image_file_object.data)
count += 1
if os.path.exists(output_dir + "/found_part_hires"):
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part-hires")[0], force_rotate=(dstype == "Alphawire"), partnum=partnum)
img = weburl + find_file_noext(output_dir, prefix="thumbnail-part-hires")[0]
elif len(find_file_noext(output_dir, prefix="part")) > 0:
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part")[0], force_rotate=(dstype == "Alphawire"), partnum=partnum)
img = weburl + find_file_noext(output_dir, prefix="thumbnail-part")[0]
else:
img = None
fprint("Making QR code for part " + partnum)
partnumqr = partnum.replace(" ", "%20")
if dstype == "Alphawire":
partnumqr = "AW" + partnumqr
if dstype == "Belden":
partnumqr = "BL" + partnumqr
qrcode = segno.make('HTTPS://BLDN.APP/' + partnumqr,micro=False,boost_error=False,error="L",mask=3)
#out = io.BytesIO()
qrx, _ = qrcode.symbol_size(1,0)
qrcode.save(output_dir + "/qrcode.png", scale=500.0/qrx, kind="PNG", border=0, light="#00000000")
qrpath = weburl + find_file_noext(output_dir, prefix="qrcode")[0]
# Table parsing and reordring
tables = dict()
torename = dict()
@@ -141,6 +217,7 @@ def parse(filename, output_dir, partnum, dstype):
#print(table_list.keys())
for table_name in table_list.keys():
# determine shape: horizontal or vertical
#print(table_name)
table = table_list[table_name]
rows = table.shape[0]
cols = table.shape[1]
@@ -177,11 +254,11 @@ def parse(filename, output_dir, partnum, dstype):
if dstype == "Alphawire" and table_name_2.find("\n") >= 0:
torename[table_name_2] = table_name_2[0:table_name_2.find("\n")]
if table_name_2.find(table.iloc[-1, 0]) >= 0:
# Name taken from table directly above - this table does not have a name
torename[table_name_2] = "Specs " + str(len(tables))
#table_list["Specs " + str(len(tables))] = table_list[table_name_2] # rename table to arbitrary altername name
break
# if dstype == "Alphawire" and table_name_2.find(table.iloc[-1, 0]) >= 0:
# # Name taken from table directly above - this table does not have a name
# torename[table_name_2] = "Specs " + str(len(tables))
# #table_list["Specs " + str(len(tables))] = table_list[table_name_2] # rename table to arbitrary altername name
# break
if vertical:
out = dict()
@@ -199,9 +276,9 @@ def parse(filename, output_dir, partnum, dstype):
out[col_data[0].replace("\n", " ")] = col_data[1:]
tables[table_name] = out
#print(out)
# multi-page table check, Alphawire
if dstype == "Alphawire" and table_name.isdigit():
if dstype == "Alphawire" and table_name.isdigit() and previous_table != "":
# table continues from previous page or has name on previous page
thistbl = table_list_raw[table_name]
prevtbl = table_list_raw[previous_table]
@@ -251,9 +328,6 @@ def parse(filename, output_dir, partnum, dstype):
#fprint(table_name)
#fprint(previous_table)
main_key = previous_table
cont_key = table_name
#fprint(tables)
@@ -267,15 +341,21 @@ def parse(filename, output_dir, partnum, dstype):
del tables[table_name]
else:
#print(tables)
#print(main_key)
#print(cont_key)
for key in tables[cont_key].keys():
tables[main_key][key] = tables[cont_key][key]
del tables[table_name]
else:
previous_table = table_name
else:
previous_table = table_name
# remove & rename tables
#print(torename)
for table_name in torename.keys():
tables[torename[table_name]] = tables[table_name]
tables[torename[str(table_name)]] = tables[str(table_name)]
del tables[table_name]
# remove multi-line values that occasionally squeak through
def replace_newlines_in_dict(d):
@@ -291,15 +371,42 @@ def parse(filename, output_dir, partnum, dstype):
tables = replace_newlines_in_dict(tables)
# summary
#print(tables)
output_table = dict()
output_table["partnum"] = partnum
id = str(uuid.uuid4())
output_table["id"] = id
#output_table["position"] = id
#output_table["brand"] = brand
output_table["fullspecs"] = tables
output_table["searchspecs"] = {"partnum": partnum, **flatten(tables)}
if "brand" in extra:
output_table["brand"] = extra["brand"]
else:
output_table["brand"] = dstype
output_table["datasheet"] = weburl + "datasheet.pdf"
output_table["qrcode"] = qrpath
if img is not None:
output_table["image"] = img
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **tables}
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "image": img, "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **flatten(tables)}
else:
output_table["fullspecs"] = {"partnum": partnum, "id": id, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **tables}
output_table["searchspecs"] = {"partnum": partnum, "brand": output_table["brand"], "datasheet": weburl + "datasheet.pdf", "qrcode": qrpath, **flatten(tables)}
if "short_description" in extra:
output_table["short_description"] = extra["short_description"]
output_table["fullspecs"]["short_description"] = extra["short_description"]
output_table["searchspecs"]["short_description"] = extra["short_description"]
if "description" in extra:
output_table["description"] = extra["description"]
output_table["fullspecs"]["description"] = extra["description"]
output_table["searchspecs"]["description"] = extra["description"]
if "application" in extra:
output_table["application"] = extra["application"]
output_table["fullspecs"]["application"] = extra["application"]
output_table["searchspecs"]["application"] = extra["application"]
if "category" in extra:
output_table["category"] = extra["category"]
output_table["fullspecs"]["category"] = extra["category"]
output_table["searchspecs"]["category"] = extra["category"]
output_table["searchspecs"]["id"] = id
@@ -308,16 +415,17 @@ def parse(filename, output_dir, partnum, dstype):
#print(output_table)
#run_cmd("rm \"" + output_dir + "\"/*.json") # not reliable!
pattern = os.path.join(output_dir, '*.json')
json_files = glob.glob(pattern)
for file_path in json_files:
os.remove(file_path)
# pattern = os.path.join(output_dir, '*.json')
# json_files = glob.glob(pattern)
# for file_path in json_files:
# os.remove(file_path)
#print(f"Deleted {file_path}")
with open(output_dir + "/search_" + output_table["searchspecs"]["id"] + ".json", 'w') as json_file:
with open(output_dir + "/search.json", 'w') as json_file:
json.dump(output_table["searchspecs"], json_file)
with open(output_dir + "/specs_" + output_table["partnum"] + ".json", 'w') as json_file:
with open(output_dir + "/specs.json", 'w') as json_file:
json.dump(output_table["fullspecs"], json_file)
fprint("Datasheet values parsed and saved for " + partnum)
#print(json.dumps(output_table, indent=2))
touch(output_dir + "/parsed") # mark as parsed
return True
@@ -346,12 +454,20 @@ def flatten(tables):
fullkeyname = (table + ": " + keyname).replace(".","")
if type(tables[table][key]) is not tuple:
if len(tables[table][key]) > 0:
out[fullkeyname] = convert_to_number(tables[table][key])
#print("\"" + keyname + "\":", "\"" + str(out[fullkeyname]) + "\",")
elif len(tables[table][key]) == 1:
if len(tables[table][key][0]) > 0:
out[fullkeyname] = convert_to_number(tables[table][key][0])
#print("\"" + keyname + "\":", "\"" + str(out[fullkeyname]) + "\",")
else:
tmp = []
for x in range(len(tables[table][key])):
if len(tables[table][key][x]) > 0:
tmp.append(tables[table][key][x].strip())
#out[fullkeyname + " " + str(x+1)] = convert_to_number(tables[table][key][x])
out[fullkeyname] = tmp
# if the item has at least two commas in it, split it
if tables[table][key].count(',') > 0:
out[fullkeyname] = list(map(lambda x: x.strip(), tables[table][key].split(",")))
@@ -369,4 +485,4 @@ def flatten(tables):
if __name__ == "__main__":
print(parse("cables/3050/datasheet.pdf", "cables/3050", "3050", "Alphawire"))
print(parse("cables/3050/datasheet-new.pdf", "cables/3050", "3050", "Alphawire"))
+7 -4
View File
@@ -1,9 +1,10 @@
# Runtime
camelot-py
opencv-python
camelot-py[base]==0.9.0
#opencv-python
pypdf2==2.12.1
alive-progress
requests
math3d==4.0.0
git+https://github.com/Byeongdulee/python-urx.git
meilisearch
pyyaml
@@ -16,10 +17,12 @@ numpy
scipy
ipywidgets
pandas
pyarrow
#pyarrow
ghostscript
pyzbar
segno
pyModbusTCP
paho-mqtt
# Development
matplotlib
+1007 -95
View File
File diff suppressed because it is too large. Load diff
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
pkill -9 python # kill any old processes
cd /root/jukebox-software
python run.py
+12 -8
View File
@@ -1,10 +1,12 @@
#!/usr/bin/env python3
"""Interactions with the Meilisearch API for adding and searching cables."""
from meilisearch import Client
from meilisearch.task import TaskInfo
from meilisearch.errors import MeilisearchApiError
import json
import time
DEFAULT_URL = "http://localhost:7700"
DEFAULT_URL = "http://127.0.0.1:7700"
DEFAULT_APIKEY = "fluffybunnyrabbit" # I WOULD RECOMMEND SOMETHING MORE SECURE
DEFAULT_INDEX = "cables"
DEFAULT_FILTERABLE_ATTRS = ["partnum", "uuid", "position"] # default filterable attributes
@@ -34,12 +36,15 @@ class JukeboxSearch:
# create the index if it does not exist already
try:
self.client.get_index(self.index)
self.client.delete_index(self.index)
self.client.create_index(self.index)
except MeilisearchApiError as _:
self.client.create_index(self.index)
# make a variable to easily reference the index
self.idxref = self.client.index(self.index)
time.sleep(0.05)
# update filterable attributes if needed
self.idxref.update_distinct_attribute('partnum')
self.update_filterables(filterable_attrs)
def add_document(self, document: dict) -> TaskInfo:
@@ -65,11 +70,10 @@ class JukeboxSearch:
:param filterables: List of all filterable attributes"""
existing_filterables = self.idxref.get_filterable_attributes()
if len(set(existing_filterables).difference(set(filterables))) > 0:
#existing_filterables = self.idxref.get_filterable_attributes()
#if len(set(existing_filterables).difference(set(filterables))) > 0:
taskref = self.idxref.update_filterable_attributes(filterables)
self.client.wait_for_task(taskref.index_uid)
#self.client.wait_for_task(taskref.index_uid)
def search(self, query: str, filters: str = None):
"""Execute a search query on the Meilisearch index.
@@ -90,7 +94,7 @@ class JukeboxSearch:
:returns: A dict containing the results; If no results found, an empty dict."""
q = self.search("", filter)
if q["estimatedTotalHits"] != 0:
return ["hits"][0]
return q["hits"][0]
else:
return dict()
+1 -1
View File
@@ -83,7 +83,7 @@ async def send_messages(to_server_queue):
await asyncio.sleep(0.001)
def websocket_server(to_server_queue, from_server_queue):
start_server = websockets.serve(lambda ws, path: handler(ws, path, to_server_queue, from_server_queue), "localhost", 9000)
start_server = websockets.serve(lambda ws, path: handler(ws, path, to_server_queue, from_server_queue), "0.0.0.0", 9000)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().create_task(send_messages(to_server_queue))
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# This script must run as root!
echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main
https://dl-cdn.alpinelinux.org/alpine/latest-stable/community" > /etc/apk/repositories
apk upgrade
apk add git docker docker-cli-compose
rc-update add docker
service docker start
git clone https://git.myitr.org/Jukebox/jukebox-software
cd jukebox-software
git submodule init
git submodule update
docker compose build
docker compose up -d
+1 -1
View File
@@ -10,7 +10,7 @@ import opcode
import os
import distutils
#distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
build_exe_options = {"include_msvcr": True, "packages": ["camelot", "setuptools"], "optimize": 0, "silent": True, "include_files": ["gs10030w64.exe"], "excludes": ["scipy", "torch"]}
build_exe_options = {"include_msvcr": True, "packages": ["camelot", "setuptools", "segno"], "optimize": 0, "silent": True, "include_files": ["gs10030w64.exe", "GothamCond-Medium.otf", "belden-logo-superhires.png"], "excludes": ["scipy", "torch"]}
# base="Win32GUI" should be used only for Windows GUI app
base = "console"
+76
View File
@@ -0,0 +1,76 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
</tr>
</thead>
<tbody>
<tr>
<th>2</th>
<td></td>
<td></td>
<td></td>
<td>Diameters\n(In)</td>
</tr>
<tr>
<th>4</th>
<td>1) Component\n1\n1 X 1 HOOKUP</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>6</th>
<td>a) Conductor\n24\n(7/32) AWG Tinned Copper</td>
<td></td>
<td></td>
<td>0.024</td>
</tr>
<tr>
<th>8</th>
<td>b)\nInsulation\n0.016" Wall, Nom. PVC</td>
<td></td>
<td></td>
<td>0.056+/-\n0.002</td>
</tr>
<tr>
<th>10</th>
<td></td>
<td>(1) Print</td>
<td>ALPHA WIRE\nE163869-* RU AWM STYLES\n1569\n105C\nOR 1007\n80C 300V VW-1\nIEC 60332-2\n24 AWG\nOR CRU TR-64\n90C FT1 CE ROHS\n{0}\n* = Factory Code</td>
<td></td>
</tr>
<tr>
<th>12</th>
<td></td>
<td>(2) Color(s)</td>
<td>WHITE, BLACK, GREEN,\nYELLOW, BLUE, BROWN, ORANGE\nSLATE, VIOLET, WHITE/BLACK, WHITE/RED</td>
<td></td>
</tr>
<tr>
<th>13</th>
<td></td>
<td></td>
<td>WHITE/GREEN, WHITE/YELLOW, WHITE/BLUE\nWHITE/BROWN, WHITE/ORANGE, WHITE/SLATE\nWHITE/VIOLET, GREEN/YELLOW,\nPINK, DK. BLUE</td>
<td></td>
</tr>
<tr>
<th>14</th>
<td></td>
<td></td>
<td>BROWN/BLACK, WHITE/PINK, BROWN/GREEN, BROWN/BLUE</td>
<td></td>
</tr>
<tr>
<th>15</th>
<td></td>
<td></td>
<td>RED</td>
<td></td>
</tr>
</tbody>
</table>
+46
View File
@@ -0,0 +1,46 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>1</th>
<th>2</th>
</tr>
</thead>
<tbody>
<tr>
<th>2</th>
<td>1) UL</td>
<td>AWM/STYLE\n1007\n80°C /\n300 VRMS</td>
</tr>
<tr>
<th>4</th>
<td></td>
<td>AWM/STYLE\n1569\n105°C /\n300 VRMS</td>
</tr>
<tr>
<th>6</th>
<td></td>
<td>VW-1</td>
</tr>
<tr>
<th>8</th>
<td>2) CSA International</td>
<td>TR-64\n90°C</td>
</tr>
<tr>
<th>10</th>
<td></td>
<td>FT1</td>
</tr>
<tr>
<th>12</th>
<td>3)\nIEC</td>
<td>EN 60332-2\nFlame Behavior</td>
</tr>
<tr>
<th>14</th>
<td>4) CE:</td>
<td>EU Low Voltage Directive\n2014/35/EU</td>
</tr>
</tbody>
</table>
+60
View File
@@ -0,0 +1,60 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>1</th>
<th>2</th>
<th>4</th>
</tr>
</thead>
<tbody>
<tr>
<th>2</th>
<td>1)\nEU Directive\n2011/65/EU(RoHS2),\nEU Directive\n2015/863/EU (RoHS3):</td>
<td></td>
<td></td>
</tr>
<tr>
<th>4</th>
<td></td>
<td></td>
<td>All materials used in the manufacture of\nthis part\nare\nin compliance with European Directive\n2011/65/EU</td>
</tr>
<tr>
<th>5</th>
<td></td>
<td></td>
<td>and the\namending Directive\n2015/863/EU of\n4\nJune\n2015\nregarding the\nrestriction of use of\ncertain</td>
</tr>
<tr>
<th>6</th>
<td></td>
<td></td>
<td>hazardous\nsubstances\nin electrical\nand electronic\nequipment.</td>
</tr>
<tr>
<th>7</th>
<td>2) REACH Regulation (EC 1907/2006):</td>
<td></td>
<td></td>
</tr>
<tr>
<th>8</th>
<td></td>
<td></td>
<td>This product does not\ncontain Substances of Very High Concern (SVHC)\nlisted on the\nEuropean Union's</td>
</tr>
<tr>
<th>9</th>
<td></td>
<td></td>
<td>REACH candidate\nlist\nin excess of\n0.1% mass of\nthe\nitem.</td>
</tr>
<tr>
<th>11</th>
<td></td>
<td>3) California Proposition 65:</td>
<td>This product may\ncontain substances\nknown to the\nState of California\nto cause Cancer or Reproductive\nHarm, but\nis\nexempt\nfrom labeling based on the Consent\nJudgement.\nSee\nthe Alpha Wire website\nfor more\ninformation.</td>
</tr>
</tbody>
</table>
+60
View File
@@ -0,0 +1,60 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<th>2</th>
<td></td>
<td>Physical &amp; Mechanical Properties</td>
<td></td>
</tr>
<tr>
<th>4</th>
<td>1)\nTemperature Range</td>
<td></td>
<td>-40\nto 105°C</td>
</tr>
<tr>
<th>6</th>
<td>2) Bend Radius</td>
<td></td>
<td>10X Cable Diameter</td>
</tr>
<tr>
<th>8</th>
<td>3) Pull\nTension</td>
<td></td>
<td>3.5\nLbs, Maximum</td>
</tr>
<tr>
<th>9</th>
<td></td>
<td>Electrical Properties\n(For\nEngineering purposes only)</td>
<td></td>
</tr>
<tr>
<th>11</th>
<td>1) Voltage Rating</td>
<td></td>
<td>300 VRMS</td>
</tr>
<tr>
<th>13</th>
<td>2)\nInductance</td>
<td></td>
<td>0.07 μH/ft, Nominal</td>
</tr>
<tr>
<th>15</th>
<td>3) Conductor DCR</td>
<td></td>
<td>25 Ω/1000ft @20°C, Nominal</td>
</tr>
</tbody>
</table>
+18
View File
@@ -0,0 +1,18 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>1</th>
</tr>
</thead>
<tbody>
<tr>
<th>2</th>
<td>Packaging\nFlange\nx\nTraverse\nx Barrel\n(inches)</td>
</tr>
<tr>
<th>3</th>
<td>a)\n32800\nFT\n23\nx\n15\nx\n0 Max.\n4\nseparate pieces; Min length/piece\n10000\nFT.\nb)\n10000\nFT\n12\nx\n5.94\nx\n5 Max.\n3\nseparate pieces; Min length/piece\n1000\nFT.\nc)\n5000\nFT\n10.5\nx\n5\nx\n3.5 Continuous\nlength\nd)\n1000\nFT\n6.5\nx\n2\nx\n1.9 Continuous\nlength\ne)\n100\nFT\n2.75\nx\n2\nx\n1.125 Continuous\nlength\n \n[Spool\ndimensions may\nvary\nslightly]\nNotes:\na) Certain color\nand put-up combinations may only be\navailable by\nspecial order. Minimums may\napply.\nb)\nTolerance on 32800\nft. Put-Up is +/-\n10%</td>
</tr>
</tbody>
</table>
BIN
View File
Binary file not shown.
+43 -1
View File
@@ -1,4 +1,46 @@
print("\u001b[37m")
from pyModbusTCP.client import ModbusClient
def get_sensors():
mbconn = ModbusClient(host="192.168.1.20", port=502, auto_open=True, auto_close=True)
"""
port 1: 256
port 2: 272
port 3: 288
port 4: 304
port 5: 320
port 6: 336
port 7: 352
port 8: 368
"""
out = list()
for reg in [352, 288, 304, 368]:
val = mbconn.read_holding_registers(reg)[0] # read only one register
print(val)
if val == 1:
out.append(True)
else:
out.append(False)
return out
def get_open_spot(sensordata):
for x in range(len(sensordata)):
sens = sensordata[x]
if not sens:
return x
# if we get here, every spot is full
return False
testmb = get_sensors()
print(testmb)
print("Spot open", get_open_spot(testmb))
exit()
class Ring:
def __init__(self) -> None:
BIN
View File
Binary file not shown.
+595 -125
View File
@@ -5,53 +5,117 @@ import math
import numpy as np
import time
import os
import logging
from urx.robotiq_two_finger_gripper import Robotiq_Two_Finger_Gripper
#import logging
import yaml
import sys
from util import fprint
from pyModbusTCP.client import ModbusClient
from multiprocessing import Queue
import subprocess
from util import win32
class Rob():
robot = None
#offset_x, offset_y, offset_z = (0, 0, 0.14) # Tool offset
#
rob = None
def __init__(self, config):
self.config = config
armc = config["arm"]
self.ip = armc["ip"]
tool = armc["tool"]
limbs = armc["limbs"]
self.offset_x, self.offset_y, self.offset_z = (tool["offset_x"], tool["offset_y"], tool["offset_z"])
self.limb_base = limbs["limb_base"]
self.limb1 = limbs["limb1"]
self.limb2 = limbs["limb2"]
self.limb3 = limbs["limb3"]
self.limb_wrist = limbs["limb_wrist"]
#self.init_arm()
def init(ip):
global rob
def ping(host):
#Returns True if host (str) responds to a ping request.
# Option for the number of packets as a function of
if win32:
param1 = '-n'
param2 = '-w'
param3 = '250'
else:
param1 = '-c'
param2 = '-W'
param3 = '0.25'
# Building the command. Ex: "ping -c 1 google.com"
command = ['ping', param1, '1', param2, param3, host]
return subprocess.call(command, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) == 0
def powerup_arm(robot):
#sys.stdout = Logger()
fprint("Starting UR5 power up...")
# power up robot here via PCB
# power up robot here
#
# wait for power up (this function runs async)
count = 0
while not ping(robot.ip) and count == 10:
time.sleep(0.5)
count += 1
# trigger auto-initialize
fprint("Arm online. Waiting for calibration.")
# wait for auto-initialize
# init urx
def connect(robot):
if robot.robot is None:
newrobot = Rob(robot.config)
robot = newrobot
ip = robot.ip
fprint("Connecting to arm at " + ip)
trying = True
while trying:
count = 0
while trying and count < 10:
count += 1
try:
rob = urx.Robot(ip)
robot.robot = urx.Robot(ip, use_rt=False)
robot.robot.set_tcp((robot.offset_x, robot.offset_y, robot.offset_z, 0, 0, 0))
# Set weight
robot.robot.set_payload(2, (0, 0, 0.1))
trying = False
except:
time.sleep(1)
robotiqgrip = Robotiq_Two_Finger_Gripper(rob)
time.sleep(0.5)
# Sets robot arm endpoint offset (x,y,z,rx,ry,rz)
rob.set_tcp((0, 0, 0.15, 0, 0, 0))
# Set weight
rob.set_payload(2, (0, 0, 0.1))
return robot
def init_arm(robot):
robot = connect(robot)
# init urx
#rob.set_payload(2, (0, 0, 0.1))
time.sleep(0.2)
fprint("UR5 ready.")
#return robot.robot
def set_pos_abs(x, y, z, xb, yb, zb, threshold=None):
global rob
# setup - in case of fail. open gripper, move up, then go home.
rob = robot.robot
open_gripper()
curr_pos = rob.getl()
new_pos = curr_pos
new_pos[2] += 0.025
rob.movel(new_pos, vel=0.05, acc=1)
curr_j = rob.getj()
curr_j[3] -= 0.2 # radians
rob.movej(curr_j, vel=0.2, acc=1)
move_to_home(robot, speed=0.5)
return True
def set_pos_abs(robot, x, y, z, xb, yb, zb, threshold=None):
rob = robot.robot
new_orientation = m3d.Transform()
new_orientation.orient.rotate_xb(xb) # Replace rx with the desired rotation around X-axis
new_orientation.orient.rotate_yb(yb) # Replace ry with the desired rotation around Y-axis
@@ -67,8 +131,8 @@ def set_pos_abs(x, y, z, xb, yb, zb, threshold=None):
#rob.speedj(0.2, 0.5, 99999)
rob.set_pose(new_trans, acc=2, vel=2, command="movej", threshold=threshold) # apply the new pose
def set_pos_rel_rot_abs(x, y, z, xb, yb, zb):
global rob
def set_pos_rel_rot_abs(robot, x, y, z, xb, yb, zb):
rob = robot.robot
new_orientation = m3d.Transform()
new_orientation.orient.rotate_xb(xb) # Replace rx with the desired rotation around X-axis
new_orientation.orient.rotate_yb(yb) # Replace ry with the desired rotation around Y-axis
@@ -85,8 +149,8 @@ def set_pos_rel_rot_abs(x, y, z, xb, yb, zb):
#rob.speedj(0.2, 0.5, 99999)
rob.set_pose(new_trans, acc=0.1, vel=0.4, command="movej") # apply the new pose
def set_pos_abs_rot_rel(x, y, z, xb, yb, zb):
global rob
def set_pos_abs_rot_rel(robot, x, y, z, xb, yb, zb):
rob = robot.robot
new_orientation = m3d.Transform()
new_orientation.orient.rotate_xb(xb) # Replace rx with the desired rotation around X-axis
new_orientation.orient.rotate_yb(yb) # Replace ry with the desired rotation around Y-axis
@@ -131,9 +195,8 @@ def polar_to_cartesian(r, theta):
y = r * np.sin(theta)
return x, y
def move_to_polar(start_pos, end_pos):
global rob
def move_to_polar(robot, start_pos, end_pos):
rob = robot.robot
# Convert to polar coordinates
start_r, start_theta = cartesian_to_polar(start_pos[0], start_pos[1])
@@ -190,19 +253,35 @@ def move_to_polar(start_pos, end_pos):
return rx_intermediate
def move_to_home():
global rob
def move_to_home(robot, keep_flip=False, speed=2):
rob = robot.robot
if is_flipped(robot) and not keep_flip:
flip(robot)
# Move robot to home position
rob.movej(offset_gripper_angle(robot, *(-0.18, -0.108, 0.25), flip=is_flipped(robot)), vel=2, acc=2) # Move to safe position
return True
def move_to_packup(robot, speed=0.25):
robot = connect(robot)
rob = robot.robot
# known good starting point to reach store position
goto_holder_index(robot, 12, 0.3, flip=False, use_closest_path=False)
# Home position in degrees
home_pos = [0.10421807948612624,
-2.206111555015423,
1.710679229503537,
-1.075834511928354,
-1.569301366430687,
1.675098295930943]
store_pos = [-1.5708,
-1.3,
2.362,
0.7056,
-1.425,
1.5708]
# Move robot
rob.movej(home_pos, acc=2, vel=2)
rob.movej(store_pos, acc=0.1, vel=speed)
return True
def normalize_degree(theta):
# Normalizes degree theta from -1.5pi to 1.5pi
@@ -216,13 +295,14 @@ def normalize_degree(theta):
# Return angle
return normalized_theta
def get_joints_from_xyz_rel(x, y, z, rx=0, ry=-math.pi/2, rz=0, initial_guess = (math.pi/2, math.pi/2, 0)):
def get_joints_from_xyz_rel(robot, x, y, z, rx=0, ry=-math.pi/2, rz=0, initial_guess = (math.pi/2, math.pi/2, 0), l3offset=0):
# Get limbs and offsets
offset_x, offset_y, offset_z = (0, 0, 0.14) # Tool offset
l_bs, l1, l2, l3, l_wt = (0.1333, .425, .39225, .1267, .0997) # Limb lengths
#l3=0.15
l_bs, l1, l2, l3, l_wt = (robot.limb_base, robot.limb1, robot.limb2, robot.limb3, robot.limb_wrist) # Limb lengths
l3 += l3offset # add wrist offset, used for gripper angle calculations
offset_x = robot.offset_x
offset_y = robot.offset_y
offset_z = robot.offset_z
# Calculate base angle and r relative to shoulder joint
def calculate_theta(x, y, a):
# Calculate if we need the + or - in our equations
@@ -238,19 +318,16 @@ def get_joints_from_xyz_rel(x, y, z, rx=0, ry=-math.pi/2, rz=0, initial_guess =
# Calculate tangent line y = mx + b
m = (x*y - math.sqrt(x*x*y*y-(x*x-a*a)*(y*y-a*a)))/(x*x-a*a)
b = flip * a * math.sqrt(1+m*m)
# Calculate equivalent tangent point on circle
cx = (-flip*m*b)/(1+m*m)
cy = m*cx + flip*b
# Calculate base angle, make angle negative if flip=1
theta = math.atan2(cy, cx) + (-math.pi if flip==1 else 0)
return theta
base_theta = calculate_theta(x, y, l_bs)
cx, cy = l_bs*math.cos(base_theta), l_bs*math.sin(l_bs)
r = math.sqrt((x-cx)**2 + (y-cy)**2)
cx, cy = l_bs*math.cos(base_theta), l_bs*math.sin(base_theta)
r = math.sqrt((x+offset_x+cx)**2 + (y+offset_y+cy)**2)
# Formulas to find out joint positions for (r, z)
@@ -264,98 +341,491 @@ def get_joints_from_xyz_rel(x, y, z, rx=0, ry=-math.pi/2, rz=0, initial_guess =
# Normalize angles
base, shoulder, elbow, wrist1 = [normalize_degree(deg) for deg in [base_theta, *fsolve(inv_kin_r_z, initial_guess)]]
wrist1 += rx
# Return result
return base, shoulder, elbow, wrist1, ry, rz
def get_joints_from_xyz_abs(x, y, z, rx=0, ry=-math.pi/2, rz=math.pi/2):
joints = get_joints_from_xyz_rel(x, y, z, rx, ry, rz)
def get_joints_from_xyz_abs(robot, x, y, z, rx=0, ry=-math.pi/2, rz=math.pi/2, l3offset=0, use_closest_path=True):
rob = robot.robot
joints = get_joints_from_xyz_rel(robot, x, y, z, rx, ry, rz, l3offset=l3offset)
# Return current positions if coordinates don't make sense
if z<0:
return rob.getj()
# Joint offsets
# Base, Shoulder, Elbow, Wrist
inverse = [1, -1, 1, 1, 1, 1]
offsets = [-math.pi/2, 0, 0, -math.pi/2, 0, 0]
# Return adjusted joint positions
return [o+j*i for j, o, i in zip(joints, offsets, inverse)]
if math.degrees(joints[1]) > 137:
print("CRASH! Shoulder at", joints[1] * 180/math.pi)
#else:
#print("Shoulder at", joints[1] * 180/math.pi)
# Get adjusted joint positions
adjusted_joints = [o+j*i for j, o, i in zip(joints, offsets, inverse)]
curr_joints = rob.getj()
def get_complimentary_angle(joint_angle):
if joint_angle<0:
new_angle = joint_angle + 2*math.pi
else:
new_angle = joint_angle - 2*math.pi
if abs(new_angle) > math.radians(350):
return joint_angle
else:
return new_angle
# Use closest path (potentially going beyond 180 degrees)
if use_closest_path:
if abs(get_complimentary_angle(adjusted_joints[0])-curr_joints[0]) < abs(adjusted_joints[0]-curr_joints[0]):
adjusted_joints[0] = get_complimentary_angle(adjusted_joints[0])
# final_joint_positions = []
# for curr_joint, adjusted_joint in zip(curr_joints, adjusted_joints):
# if abs(curr_joint - adjusted_joint) < abs(curr_joint - get_complimentary_angle(adjusted_joint)):
# final_joint_positions.append(adjusted_joint)
# else:
# final_joint_positions.append(get_complimentary_angle(adjusted_joint))
# return final_joint_positions
return adjusted_joints
def move_arc(robot, x, y, z, rx=0, ry=-math.pi/2, rz=math.pi/2):
rob = robot.robot
start_joints = rob.getj()
end_joint = get_joints_from_xyz_abs(robot, x, y, z, rx, ry, rz)
n_points = 50
intermediate_joints = []
for i in range(0, 6):
intermediate_joints.append(np.linspace(start_joints[i], end_joint[i], n_points))
joints = [joint_position for joint_position in zip(*intermediate_joints)]
rob.movejs(joints, acc=2, vel=2, radius=0.1)
def offset_gripper_angle(robot, x, y, z, gripperangle=30, gripperlength=0.20+0.018, flip=False, use_closest_path=True, rzoffset=0):
# gripper angle: from vertical
# gripper length: from joint to start of grip
# to flip, you can use flip=True or make gripper angle negative
limb3 = robot.limb3
# Determine tool rotation depending on gripper angle
if gripperangle < 0:
rz = - math.pi / 2
else:
rz = math.pi / 2
if flip:
gripperangle = -math.radians(gripperangle)
grippery = gripperlength - math.cos(gripperangle) * gripperlength
grippery += math.sin(gripperangle) * limb3
gripperx = math.sin(gripperangle) * gripperlength + limb3 * 2
gripperx -= (1-math.cos(gripperangle)) * limb3
rz = math.pi / 2
# flip the whole wrist
return get_joints_from_xyz_abs(robot, x, y, z-grippery, rx=gripperangle + math.radians(180), l3offset=-gripperx, ry=-3*math.pi/2, rz=rz + rzoffset, use_closest_path=use_closest_path)
else:
gripperangle = math.radians(gripperangle)
grippery = gripperlength - math.cos(gripperangle) * gripperlength
grippery -= math.sin(gripperangle) * limb3
gripperx = math.sin(gripperangle) * gripperlength
gripperx += (1-math.cos(gripperangle)) * limb3
return get_joints_from_xyz_abs(robot, x, y, z-grippery, rx=gripperangle, l3offset=-gripperx, rz=rz, use_closest_path=use_closest_path)
def goto_holder_index(robot, idx, z=0.05, gripperangle=30, flip=False, use_closest_path=True, verbose=False):
joint = robot.config["position_map"][idx]
if verbose:
print("Going to cable holder index", joint["index"], "at position", joint["pos"])
safe_move(robot, joint["pos"][0]/1000, joint["pos"][1]/1000, z, use_closest_path=use_closest_path)
#angles = offset_gripper_angle(joint["pos"][1]/1000, joint["pos"][0]/1000, z, gripperangle=gripperangle, flip=flip)
#rob.movej(angles, acc=2, vel=2)
#return angles
#angles = get_joints_from_xyz_abs(joint["pos"][1]/1000, joint["pos"][0]/1000, 0.05, )
return True
def is_flipped(robot):
rob = robot.robot
wrist1 = rob.getj()[3]
if wrist1 > 0:
return True
else:
return False
def flip(robot):
rob = robot.robot
# A list of safe positions to flip
safe_positions = [(-0.18, -0.108, 0.35),
(0.18, -0.108, 0.35)]
# Find the closest safe position
curr_pos = rob.getl()[:3]
def dist_from_robot(pos):
x, y, z = pos
rx, ry, rz = curr_pos
return math.sqrt((rx-x)**2+(ry-y)**2+(rz-z)**2)
pos_dist_pairs = zip(safe_positions, [dist_from_robot(pos) for pos in safe_positions])
safe_pos = min(pos_dist_pairs, key=lambda x:x[1])[0]
# Flip at safe position
rob.movej(offset_gripper_angle(robot, *safe_pos, flip=is_flipped(robot)), vel=2, acc=2) # Move to safe position
rob.movej(offset_gripper_angle(robot, *safe_pos, flip=(not is_flipped(robot))), vel=2, acc=2) # Flip gripper
# print('flip?: ', is_flipped(robot))
return True
def safe_move(robot, x, y, z, use_closest_path=True):
rob = robot.robot
flip_radius = 0.22 # Min radius on which to flip
r = math.sqrt(x**2 + y**2) # Get position radius
# Flip gripper if needed
if (r <= flip_radius and is_flipped(robot)) or (r > flip_radius and not is_flipped(robot)):
flip(robot)
rob.movej(offset_gripper_angle(robot, x, y, z, flip=is_flipped(robot), use_closest_path=use_closest_path), vel=2, acc=2)
return True
def holder_routine(robot, pos_updates, holder_index, pick_up, verbose=False):
robot = connect(robot)
rob = robot.robot
# Don't attempt to place a tube in the camera slot
if holder_index == 49:
return
if verbose:
fprint('Pickup routine for index' + str(holder_index))
# Go to the correct holder
if pick_up:
goto_holder_index(robot, holder_index, 0.05, use_closest_path=False)
else:
goto_holder_index(robot, holder_index, 0.2, use_closest_path=False)
if pick_up:
open_gripper()
# Move down
curr_pos = rob.getl()
new_pos = curr_pos
new_pos[2] = 0.005
rob.movel(new_pos, vel=0.1, acc=1)
if pos_updates is not None:
pos_updates.put(1)
fprint("Triggering LED interface")
# Pick up or drop off
if pick_up:
close_gripper()
else:
open_gripper()
# Move up
new_pos[2] = 0.2
rob.movel(new_pos, vel=2, acc=1)
was_flipped = is_flipped(robot)
if pos_updates is not None:
pos_updates.put(2)
fprint("Triggering LED interface")
# goto_holder_index(robot, 25, z=0.2)
def pick_up_holder(robot, pos_updates, holder_index, verbose=False):
holder_routine(robot, pos_updates, holder_index, True, verbose=verbose)
def drop_off_holder(robot, pos_updates, holder_index, verbose=False):
holder_routine(robot, pos_updates, holder_index, False, verbose=verbose)
def tray_routine(robot, slot=0, pick_up=True):
robot = connect(robot)
rob = robot.robot
# Default to 0 if invalid value
if slot not in [0, 1, 2, 3]:
slot = 0
slot_prepositions = [(-9.93, -112.67, 144.02, -116.69, -54.13, -10.29),
(-12.35, -124.95, 148.61, -107.27, -54.36, -13.26),
(-16.45, -96.97, 137.85, 58.39, -305.08, 161.75),
(-16.66, -97.28, 138.16, 58.54, -305.05, 161.50)]
# Initial position depending on slot and robot orientation
if slot in [0, 1]:
if is_flipped(robot):
flip(robot)
else:
move_to_home(robot, keep_flip=True)
else:
goto_holder_index(robot, 25, z=0.3)
# Align robot to the slot
if slot in [2,3]:
angles = [(-2.77, -99.64, 131.02, 67.67, 70.04-360, 153.03),
slot_prepositions[slot]]
else:
angles = [(-58, -114.45, 100.52, -45.24, -96.95, 120),
(-39.98, -124.92, 132.28, -61.56, -55.60, -50.77),
slot_prepositions[slot]]
angles = [[x*math.pi/180 for x in move] for move in angles]
rob.movejs(angles,vel=2,acc=1)
# Positions for each slot
slot_distance = .052
slot_height = -.015-.0095+0.007 # add 7mm for shim
first_slot = -0.3084+0.01+0.003 # add 3mm for tray adjust
slot_position = [
[first_slot, -0.3426, slot_height, 1.5899, 1.5526, -0.9411],
[first_slot+slot_distance, -0.3426, slot_height, 1.5899, 1.5526, -0.9411],
[first_slot+2*slot_distance, -0.3426, slot_height, 1.5899, 1.5526, -0.9411],
[first_slot+3*slot_distance, -0.3426, slot_height, 1.5899, 1.5526, -0.9411],
]
if pick_up:
open_gripper()
rob.movel(slot_position[slot], vel=0.2, acc=1)
# Place/Grab the tube
if pick_up:
close_gripper()
else:
open_gripper()
# Move back
tilt = 0.3
curr_pos = rob.getl()
new_pos = curr_pos
if slot==3:
new_pos[0] -= 0.05 #x
new_pos[1] += 0.15 #y
new_pos[2] = 0.09 #z
new_pos[3] += tilt
new_pos[4] += tilt
new_pos[5] += tilt
rob.movel(new_pos, vel=0.2, acc=1)
# Go home to safe position
move_to_home(robot, speed=1, keep_flip=True)
def pick_up_tray(robot, slot=0):
tray_routine(robot, slot, True)
def drop_off_tray(robot, slot=0):
tray_routine(robot, slot, False)
def return_routine(robot, slot, holder_index=None, verbose=False):
# OLD UNUSED
robot = connect(robot)
rob = robot.robot
open_gripper()
was_flipped = is_flipped(robot)
if slot is None:
rob.movej(offset_gripper_angle(robot, -0.15, -0.15, 0.3, flip=was_flipped, use_closest_path=False), vel=4, acc=3)
rob.movej(get_joints_from_xyz_abs(robot, -0.35, -0.15, 0.0, math.pi/2, 0.1), vel=4, acc=3)
close_gripper()
else:
xoffset = 0.051 * slot
rob.movej(offset_gripper_angle(robot, -0.15, -0.15, 0.3, flip=was_flipped, use_closest_path=False), vel=4, acc=3)
rob.movej(get_joints_from_xyz_abs(robot, -0.35+xoffset, -0.15, 0.0, math.pi/2, 0.1), vel=4, acc=3)
close_gripper()
if holder_index is not None:
goto_holder_index(robot, holder_index, 0.2, use_closest_path=False)
curr_pos = rob.getl()
new_pos = curr_pos
new_pos[2] = 0.015
rob.movel(new_pos, vel=0.1, acc=1)
open_gripper()
new_pos[2] = 0.1
rob.movel(new_pos, vel=2, acc=1)
return True
else:
# go to camera
rob.movej(offset_gripper_angle(robot, 0.35, -0.35, 0.3, flip=was_flipped, use_closest_path=False), vel=2, acc=2)
return True
def goto_camera(robot, pos_updates):
robot = connect(robot)
goto_holder_index(robot, 49, 0.2)
def tray_to_camera(robot, pos_updates, slot):
pick_up_tray(robot, slot)
goto_camera(robot, pos_updates)
def holder_to_tray(robot, pos_updates, holder_index, slot):
pick_up_holder(robot, pos_updates, holder_index)
drop_off_tray(robot, slot)
def holder_to_camera(robot, pos_updates, holder_index, verbose=False):
robot = connect(robot)
fprint("Bringing tube at " + str(holder_index) + " to camera")
rob = robot.robot
pick_up_holder(robot, pos_updates, holder_index)
goto_camera(robot, pos_updates)
def camera_to_holder(robot, pos_updates, holder_index, verbose=False):
robot = connect(robot)
rob = robot.robot
drop_off_holder(robot, pos_updates, holder_index)
# def open_gripper():
# fprint("Opening gripper")
# c = ModbusClient(host="192.168.1.21", port=502, auto_open=False, auto_close=False)
# c.open()
# while not c.is_open:
# time.sleep(0.01)
# c.write_single_register(112, 0b0)
# # c.write_single_register(435, 0b10000000)
# time.sleep(0.5)
# # c.write_single_register(112, 0b0)
# c.write_single_register(435, 0b10000000)
# time.sleep(0.5)
# c.close()
# #c.close()
# def close_gripper():
# fprint("Closing gripper")
# c = ModbusClient(host="192.168.1.21", port=502, auto_open=False, auto_close=False)
# c.open()
# while not c.is_open:
# time.sleep(0.01)
# c.write_single_register(435, 0b00000000)
# # c.write_single_register(112, 0b1)
# time.sleep(0.5)
# # c.write_single_register(435, 0b00000000)
# c.write_single_register(112, 0b1)
# time.sleep(0.5)
# c.close()
# time.sleep(0.2)
# #
def open_gripper():
fprint("Opening gripper")
c = ModbusClient(host="192.168.1.21", port=502, auto_open=True, auto_close=False)
c.write_single_register(112, 0b0)
c.write_single_register(435, 0b10000000)
c.write_single_register(112, 0b0)
c.write_single_register(435, 0b10000000)
time.sleep(0.5)
c.close()
#c.close()
def close_gripper():
fprint("Closing gripper")
c = ModbusClient(host="192.168.1.21", port=502, auto_open=True, auto_close=False)
c.write_single_register(435, 0b00000000)
c.write_single_register(112, 0b1)
c.write_single_register(435, 0b00000000)
c.write_single_register(112, 0b1)
time.sleep(0.5)
c.close()
#
def get_position_thread(robot, pos_updates):
try:
robot = connect(robot)
rob = robot.robot
oldvals = rob.getl()
deltavals = [0,0,0]
import uptime
t = 0.01
count = 0
while True:
start = uptime.uptime()
if pos_updates.qsize() < 2:
vals = rob.getl()
if vals != oldvals:
if pos_updates is not None:
pos_updates.put(tuple(oldvals))
#time.sleep(0.01)
# deltavals = list()
# deltavals.append(vals[0]-oldvals[0])
# deltavals.append(vals[1]-oldvals[1])
# deltavals.append(vals[2]-oldvals[2])
# count = 0
oldvals = vals
# else:
# count += 0.2
# if count < 1:
# tmpvals = vals
# tmpvals[0] = oldvals[0] + deltavals[0]*count
# tmpvals[1] = oldvals[1] + deltavals[1]*count
# tmpvals[2] = oldvals[2] + deltavals[2]*count
# pos_updates.put(tuple(tmpvals))
while start + t > uptime.uptime():
time.sleep(0.0001)
except:
pass
if __name__ == "__main__":
#rob.movej((0, 0, 0, 0, 0, 0), 0.1, 0.2)
#rob.movel((x, y, z, rx, ry, rz), a, v)
init("192.168.1.145")
with open('config.yml', 'r') as fileread:
#global config
config = yaml.safe_load(fileread)
robot = Rob(config) # robot of type Rob is the custom class above
#powerup_arm(robot)
robot = connect(robot)
init_arm(robot)
rob = robot.robot # rob is robot.robot is the urx robot class, what we've been using previously
#move_to_packup(robot)
move_to_home(robot)
pick_up_holder(robot, None, 8)
#drop_off_tray(robot, 0)
# drop_off_tray(robot, 1)
# drop_off_tray(robot, 2)
# drop_off_tray(robot, 3)
# pick_up_tray(robot, 1)
# drop_off_holder(robot, 5)
# pick_up_holder(robot, 26)
# drop_off_tray(robot, 3)
# for i in range(0,54):
# pick_up_holder(robot, None, i)
# #print('Drop off', i+1)
# drop_off_tray(robot, 0)
# #input()
# # holder_to_camera(robot, 0)
# # camera_to_holder(robot, 0)
print("Current tool pose is: ", rob.getl())
move_to_home()
home_pose = [-0.4999999077032916,
-0.2000072960336574,
0.40002172976662786,
0,
-3.14152741295329,
math.radians(62)]
# time.sleep(.5)
p1 = [0,
0.6,
.4,
0.2226,
3.1126,
0.0510]
p2 = [0.171,
-0.115,
0.2,
0.2226,
3.1126,
0.0510]
curr_pos = rob.getl()
# up/down,
# tool rotation
# tool angle (shouldn't need)
# rob.set_pos(p1[0:3], acc=0.5, vel=0.5)
config = None
# set_pos_abs(*home_pose)
angles = get_joints_from_xyz_abs(-0.7, 0, 0)
rob.movej(angles, acc=2, vel=2)
# joints = []
# for i in np.linspace(-0.3, -0.7, 50):
# joints.append(get_joints_from_xyz_abs(i, 0, 0))
# rob.movejs(joints, acc=2, vel=2)
# time.sleep(5)
# angles = get_joints_from_xyz_abs(0, -0.6, 0)
# rob.movej(angles, acc=2, vel=2)
# set_pos_abs(*p1)
# move = move_to_polar(p1, p2)
# for p in move:
# print(math.degrees(p))
# print("Safe? :", is_safe_move(p1, p2))
# #set_pos_rel_rot_abs(0, 0, -0.2, math.pi, 0, -math.pi)
# set_pos_abs(0.3, -0.2, 0.5, math.pi, 0, -math.pi)
# set_pos_abs(0, 0.2, 0.6, math.pi, 0, -math.pi)
# set_pos_abs(-0.5, -0.2, 0.4, math.pi, 0, -math.pi)
# #set_pos_rel_rot_abs(0, 0, 0, math.pi, 0, -math.pi)
# print("Current tool pose is: ", rob.getl())
# print("getj(): ", rob.getj())
# move_to_home()
rob.stop()
os.kill(os.getpid(), 9) # dirty kill of self
+2 -2
View File
@@ -26,8 +26,8 @@ if win32:
#if not getattr(sys, "frozen", False):
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # hide powershell window
res = subprocess.check_output(["WMIC", "ComputerSystem", "GET", "UserName"], universal_newlines=True, startupinfo=startupinfo)
_, username = res.strip().rsplit("\n", 1)
userid, sysdom = username.rsplit("\\", 1)
# _, username = res.strip().rsplit("\n", 1)
# userid, sysdom = username.rsplit("\\", 1)
if linux or macos:
sysid = hex(uuid.getnode())
+2 -2
View File
@@ -81,7 +81,7 @@
socket.send(message);
console.log('Message sent', message);
}
setInterval(ping, 1500);
//setInterval(ping, 1500);
// setInterval(() => {
// updateServiceStatus('serviceA', 'down');
@@ -150,7 +150,7 @@
setInterval(updateClock, 100);
</script>
<iframe src="http://192.168.1.12:3000/d-solo/cdiqwmlr8c9ogf/sensors?orgId=1&refresh=5s&from=1714431825720&to=1714433625721&theme=light&panelId=7" width="450" height="200" frameborder="0"></iframe>
</body>
</html>