Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot arm #94

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6fe9973
Add uploading firmware for product Hunter in FirmwareUploader.py
JasonWong08 Jul 16, 2024
1400930
Adjust the layout of the Cabibrator interface for Hunter.
JasonWong08 Jul 19, 2024
8f04e4f
Optimize layout code according to different products
JasonWong08 Jul 23, 2024
2a1bbcf
Further optimization of layout code
JasonWong08 Jul 23, 2024
733a89c
After the firmware upload fails, an information prompt box pops up an…
JasonWong08 Jul 27, 2024
abd3323
update the pictures of Bittle X wire connection.
JasonWong08 Jul 27, 2024
95b29f9
Modify the lables of the robot arm
JasonWong08 Jul 27, 2024
1753631
fix the bug after the model name change to "BittleX"
JasonWong08 Jul 29, 2024
746cc9a
fix the bug for NyBoard
JasonWong08 Aug 1, 2024
e12e2a3
Modify Firmware upload process for BiBoard
JasonWong08 Aug 1, 2024
b2e15b4
Merge branch 'PetoiCamp:main' into main
JasonWong08 Aug 2, 2024
3ed90a6
A bug in the SkillComposer
JasonWong08 Aug 6, 2024
222e47d
fix modelName; rebuild controller
borntoleave Aug 6, 2024
29b8bf9
fix modelname and changing model or language bug
JasonWong08 Aug 6, 2024
786da2f
fix calibrator and menu
borntoleave Aug 6, 2024
5786cd5
fix typo; allow space in displayName
borntoleave Aug 6, 2024
65d9ee1
Keep the model naming rules consistent
JasonWong08 Aug 7, 2024
2b3e306
Display different wring picture according to different Board version …
JasonWong08 Aug 8, 2024
bc5cd4b
fix running error
JasonWong08 Aug 8, 2024
66daa1e
update the firmware files
JasonWong08 Aug 12, 2024
0d7511e
update pics and support to robot arm for NyBoard
JasonWong08 Sep 9, 2024
5e11111
update calibration related pictures
JasonWong08 Sep 11, 2024
83ec687
Add auto calibrate robotic claw function
JasonWong08 Sep 14, 2024
3a46886
update firmwares and pictures
JasonWong08 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@

.idea/*
pyUI/.idea/*
pyUI/logfile*
pyUI/genApp4Mac/*
pyUI/genApp4Win/*
pyUI/lib/*
*.DS_Store
*.pyc
pyUI/defaultConfig.txt
pyUI/README.txt
pyUI/README_Mac.txt
pyUI/README_Windows.txt
pyUI/PetoiDesktopApp/*
*.cfg
*.svd
ModuleTests/testDoubleLight/debug_custom.json
Expand Down
168 changes: 140 additions & 28 deletions pyUI/Calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@

language = languageList['English']

BittleRWinSet = {
"imageW": 360, # The width of image
"sliderW": 260, # The width of the slider rail corresponding to joint numbers 0 to 3
"rowJoint1": 2, # The row number of the label with joint number 2 and 3
"sliderLen": 260, # The length of the slider rail corresponding to joint numbers 4 to 15
"rowJoint2": 4 # The row number of the label with joint number 4 or 15 is located
}

RegularWinSet = {
"imageW": 250,
"sliderW": 200,
"rowJoint1": 11,
"sliderLen": 150,
"rowJoint2": 2
}

BittleRMacSet = {
"imageW": 300, # The width of image
"sliderW": 200, # The width of the slider rail corresponding to joint numbers 0 to 3
"rowJoint1": 2, # The row number of the label with joint number 2 and 3
"sliderLen": 200, # The length of the slider rail corresponding to joint numbers 4 to 15
"rowJoint2": 4 # The row number of the label with joint number 4 or 15 is located
}

RegularMacSet = {
"imageW": 190,
"sliderW": 140,
"rowJoint1": 11,
"sliderLen": 140,
"rowJoint2": 2
}

parameterWinSet = {
"Nybble": RegularWinSet,
"Bittle": RegularWinSet,
"BittleR": BittleRWinSet,
"DoF16": RegularWinSet,
}

parameterMacSet = {
"Nybble": RegularMacSet,
"Bittle": RegularMacSet,
"BittleR": BittleRMacSet,
"DoF16": RegularMacSet,
}

frontJointIdx = [4, 5, 8, 9, 12, 13]

def txt(key):
return language.get(key, textEN[key])

Expand All @@ -18,9 +66,18 @@ def __init__(self,model,lan):
while config.model_ == '':
if time.time() - start > 5:
config.model_ = model
config.version_ = "N_210101"
print('Use the model set in the UI interface.')
time.sleep(0.01)
self.model = config.model_
self.configName = config.model_
self.boardVersion = config.version_
config.model_ = config.model_.replace(' ', '')
if config.model_ == 'BittleX':
self.model = 'Bittle'
elif config.model_ == 'BittleRN':
self.model = 'BittleR'
else:
self.model = config.model_

self.winCalib = Tk()
self.winCalib.title(txt('calibTitle'))
Expand Down Expand Up @@ -50,11 +107,33 @@ def __init__(self,model,lan):
abortButton.grid(row=11, column=2)
# quitButton.grid(row=11, column=2)

imageW = 250
self.imgWiring = createImage(self.frameCalibButtons, resourcePath + self.model + 'Wire.jpeg', imageW)
self.OSname = self.winCalib.call('tk', 'windowingsystem')
print(self.OSname)
if self.OSname == 'win32':
self.parameterSet = parameterWinSet[self.model]
else:
self.parameterSet = parameterMacSet[self.model]

if self.model == 'BittleR':
# self.parameterSet = parameterSet['BittleR']
scaleNames = BittleRScaleNames
else:
# self.parameterSet = parameterSet['Regular']
scaleNames = RegularScaleNames

if "B" in self.boardVersion:
self.imgWiring = createImage(self.frameCalibButtons,
resourcePath + config.model_ + self.boardVersion[1] + '_Wire.jpeg',
self.parameterSet['imageW'])
else:
self.imgWiring = createImage(self.frameCalibButtons,
resourcePath + config.model_ + '_Wire.jpeg',
self.parameterSet['imageW'])

self.imgWiring.grid(row=0, column=0, rowspan=5, columnspan=3)
Hovertip(self.imgWiring, txt('tipImgWiring'))
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + 'Ruler.jpeg', imageW)

self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + '_Ruler.jpeg', self.parameterSet['imageW'])
self.imgPosture.grid(row=7, column=0, rowspan=3, columnspan=3)

for i in range(16):
Expand All @@ -64,14 +143,15 @@ def __init__(self,model,lan):
if i < 2:
ROW = 0
else:
ROW = 11
ROW = self.parameterSet['rowJoint1']

if 0 < i < 3:
COL = 4
else:
COL = 0
rSPAN = 1
ORI = HORIZONTAL
LEN = 200
LEN = self.parameterSet['sliderW']
ALIGN = 'we'

else:
Expand All @@ -81,14 +161,18 @@ def __init__(self,model,lan):
upperQ = i / 4 < 3

rSPAN = 3
ROW = 2 + (1 - frontQ) * (rSPAN + 2)
cSPAN = 1
ROW = self.parameterSet['rowJoint2'] + (1 - frontQ) * (rSPAN + 2)

if leftQ:
COL = 3 - i // 4
ALIGN = 'sw'
else:
COL = 3 + i // 4
ALIGN = 'se'
ORI = VERTICAL
LEN = 150
ALIGN = 'sw'
LEN = self.parameterSet['sliderLen']
# ALIGN = 'sw'
stt = NORMAL
if i in NaJoints[self.model]:
clr = 'light yellow'
Expand All @@ -102,12 +186,27 @@ def __init__(self,model,lan):
text=sideLabel + '(' + str(i) + ')\n' + txt(scaleNames[i]))

value = DoubleVar()
sliderBar = Scale(self.winCalib, state=stt, fg='blue', bg=clr, variable=value, orient=ORI,
borderwidth=2, relief='flat', width=8, from_=-25 * tickDirection, to=25 * tickDirection,
length=LEN, tickinterval=10, resolution=1, repeatdelay=100, repeatinterval=100,
command=lambda value, idx=i: self.setCalib(idx, value))
if i in frontJointIdx:
if self.model == 'BittleR':
LEN = LEN + 30
sliderBar = Scale(self.winCalib, state=stt, fg='blue', bg=clr, variable=value, orient=ORI,
borderwidth=2, relief='flat', width=8, from_=-25 * tickDirection,
to=25 * tickDirection,
length=LEN, tickinterval=10, resolution=1, repeatdelay=100, repeatinterval=100,
command=lambda value, idx=i: self.setCalib(idx, value))
else:
sliderBar = Scale(self.winCalib, state=stt, fg='blue', bg=clr, variable=value, orient=ORI,
borderwidth=2, relief='flat', width=8, from_=-25 * tickDirection, to=25 * tickDirection,
length=LEN, tickinterval=10, resolution=1, repeatdelay=100, repeatinterval=100,
command=lambda value, idx=i: self.setCalib(idx, value))
self.calibSliders.append(sliderBar)
label.grid(row=ROW, column=COL, columnspan=cSPAN, pady=2, sticky=ALIGN)
if i == 2 and scaleNames == BittleRScaleNames:
autoCalibButton = Button(self.winCalib, text=txt('Auto'), fg='blue',
width=self.calibButtonW, command=lambda cmd='c-2': self.calibFun(cmd))
label.grid(row=ROW, column=COL, columnspan=2, pady=2, sticky='e')
autoCalibButton.grid(row=ROW, column=COL+2, pady=2, sticky='w') # padx=5,
else:
label.grid(row=ROW, column=COL, columnspan=cSPAN, pady=2, sticky=ALIGN)
sliderBar.grid(row=ROW + 1, column=COL, rowspan=rSPAN, columnspan=cSPAN, sticky=ALIGN)
time.sleep(3) # wait for the robot to reboot
self.calibFun('c')
Expand All @@ -119,42 +218,55 @@ def __init__(self,model,lan):

def calibFun(self, cmd):
# global ports
imageW = 250
imageW = self.parameterSet['imageW']

self.imgPosture.destroy()
if cmd == 'c':
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + 'Ruler.jpeg', imageW)
result = send(goodPorts, ['c', 0])
if cmd == 'c' or cmd == 'c-2':
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + '_Ruler.jpeg', imageW)
if cmd == 'c-2':
send(goodPorts, ['c', [-2], 0])
time.sleep(1)
result = send(goodPorts, ['c', 0])
else:
result = send(goodPorts, [cmd, 0])

if result != -1:
offsets = result[1]
printH('re',result)
printH('of',offsets)
# printH('re',result)
# printH('of',offsets)
idx = offsets.find(',')
l1 = offsets[:idx].split()[-1]
offsets = ''.join(offsets[idx + 1:].split()).split(',')[:15]
offsets.insert(0, l1)
# print(offsets)
# print(len(offsets))
print(offsets)
# print(len(offsets))
else:
offsets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]
for i in range(16):
self.calibSliders[i].set(offsets[i])

if cmd == 'c-2':
printH("offset2:", offsets[2])
if int(offsets[2]) > 25:
tk.messagebox.showwarning(title=txt('Warning'), message=txt('AutoCali failed'))
else:
self.calibSliders[2].set(offsets[2])
else:
for i in range(16):
self.calibSliders[i].set(offsets[i])
elif cmd == 'd':
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + 'Rest.jpeg', imageW)
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + '_Rest.jpeg', imageW)
send(goodPorts, ['d', 0])
elif cmd == 'balance':
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + 'Stand.jpeg', imageW)
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + '_Stand.jpeg', imageW)
send(goodPorts, ['kbalance', 0])
elif cmd == 'walk':
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + 'Walk.jpeg', imageW)
self.imgPosture = createImage(self.frameCalibButtons, resourcePath + self.model + '_Walk.jpeg', imageW)
send(goodPorts, ['kwkF', 0])
self.imgPosture.grid(row=7, column=0, rowspan=3, columnspan=3)
Hovertip(self.imgPosture, txt('tipImgPosture'))
self.winCalib.update()

def setCalib(self, idx, value):
if self.calibratorReady:
# global ports
value = int(value)
send(goodPorts, ['c', [idx, value], 0])

Expand Down
16 changes: 7 additions & 9 deletions pyUI/Debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(self,model,lan):
start = time.time()
while config.model_ == '':
if time.time() - start > 5:
config.model_ = model
print('Use the model set in the UI interface.')
config.model_ = model # If can not get the model name, use the model set in the UI interface.
time.sleep(0.01)
self.model = config.model_
self.configName = config.model_


self.winDebug = Tk()
self.debuggerReady = False
Expand All @@ -47,7 +47,7 @@ def __init__(self,model,lan):
self.winDebug.title(txt('Debugger'))
self.createMenu()
bw = 23
self.modelLabel = Label(self.winDebug, text=self.model, font=self.myFont)
self.modelLabel = Label(self.winDebug, text=displayName(self.configName), font=self.myFont)
self.modelLabel.grid(row=0, column=0, pady=10)
voiceResetButton = Button(self.winDebug, text=txt('Reset voice module'), font=self.myFont, fg='blue', width=bw, relief='raised',
command=lambda: self.resetVoice())
Expand All @@ -66,8 +66,8 @@ def createMenu(self):
self.menubar = Menu(self.winDebug, background='#ff8000', foreground='black', activebackground='white',
activeforeground='black')
file = Menu(self.menubar, tearoff=0, background='#ffcc99', foreground='black')
for key in NaJoints:
file.add_command(label=key, command=lambda model=key: self.changeModel(model))
for m in modelOptions:
file.add_command(label=m, command=lambda model=m: self.changeModel(model))
self.menubar.add_cascade(label=txt('Model'), menu=file)

lan = Menu(self.menubar, tearoff=0)
Expand All @@ -83,9 +83,7 @@ def createMenu(self):


def changeModel(self, modelName):
self.model = copy.deepcopy(modelName)
self.modelLabel.configure(text=self.model)
print(self.model)
self.modelLabel.configure(text=modelName)


def changeLan(self, l):
Expand Down
Loading