This is some code that I wanted to send to somebody ( @Lathe Adventures ) who asked me how to record the AR4's current position by pushing a button.
I extracted this code from my modified AR4 program. I was working on customizing the rough calibration and fine calibration of the robot. The variables XcurPos, YcurPos, ZcurPos, RzcurPos, RycurPos, RxcurPos, and J1AngCur, J2AngCur, J3AngCur, J4AngCur, J5AngCur, J6AngCur in the code are part of Chris Annin's overall program. They are constantly updated to reflect the AR4's current position and orientation, and joint angles. As you can see, all this function does is delete and then write to 12 small entry fields (6 for the position and orientation, and 6 for the joint angles). The
code below includes the Python function and the statements for creating the display fields. It also includes the definition for the button which executes the function. It should be able to inserted in Chris' AR4 source code file pretty much anywhere and compiled. I put my customization code after line 236 (after the "def setCom2():" code). The button and display fields are placed on the lower right corner of the "calibration"tab
(I couldn't upload the python file so here it is)
########################################################
def SaveCurPosToFC():
# this function writes the current pose and angle position to the fine calibration position element fields
global XcurPos, YcurPos, ZcurPos, RzcurPos, RycurPos, RxcurPos
global J1AngCur, J2AngCur, J3AngCur, J4AngCur, J5AngCur, J6AngCur
global FCxEntryField, FCyEntryField, FCzEntryField, FCrzEntryField, FCryEntryField, FCrxEntryField
global FCj1EntryField, FCj2EntryField, FCj3EntryField, FCj4EntryField, FCj5EntryField, FCj6EntryField
FCxEntryField.delete(0, "end")
FCxEntryField.insert(0, XcurPos)
FCyEntryField.delete(0, "end")
FCyEntryField.insert(0, YcurPos)
FCzEntryField.delete(0, "end")
FCzEntryField.insert(0, ZcurPos)
FCrzEntryField.delete(0, "end")
FCrzEntryField.insert(0, RzcurPos)
FCryEntryField.delete(0, "end")
FCryEntryField.insert(0, RycurPos)
FCrxEntryField.delete(0, "end")
FCrxEntryField.insert(0, RxcurPos)
FCj1EntryField.delete(0, "end")
FCj1EntryField.insert(0, J1AngCur)
FCj2EntryField.delete(0, "end")
FCj2EntryField.insert(0, J2AngCur)
FCj3EntryField.delete(0, "end")
FCj3EntryField.insert(0, J3AngCur)
FCj4EntryField.delete(0, "end")
FCj4EntryField.insert(0, J4AngCur)
FCj5EntryField.delete(0, "end")
FCj5EntryField.insert(0, J5AngCur)
FCj6EntryField.delete(0, "end")
FCj6EntryField.insert(0, J6AngCur)
################ statements to create the pose and joint position display fields #############3
# fine calibration joint angle labels
FCj1Lab = Label(tab2, font=("Arial", 11), text = "J1")
FCj1Lab.place(x=920, y=440)
FCj2Lab = Label(tab2, font=("Arial", 11), text = "J2")
FCj2Lab.place(x=960, y=440)
FCj3Lab = Label(tab2, font=("Arial", 11), text = "J3")
FCj3Lab.place(x=1000, y=440)
FCj4Lab = Label(tab2, font=("Arial", 11), text = "J4")
FCj4Lab.place(x=1040, y=440)
FCj5Lab = Label(tab2, font=("Arial", 11), text = "J5")
FCj5Lab.place(x=1080, y=440)
FCj6Lab = Label(tab2, font=("Arial", 11), text = "J6")
FCj6Lab.place(x=1120, y=440)
# fine calibration joint angle element fields
FCj1EntryField = Entry(tab2,width=5)
FCj1EntryField.place(x=910, y=465)
FCj2EntryField = Entry(tab2,width=5)
FCj2EntryField.place(x=950, y=465)
FCj3EntryField = Entry(tab2,width=5)
FCj3EntryField.place(x=990, y=465)
FCj4EntryField = Entry(tab2,width=5)
FCj4EntryField.place(x=1030, y=465)
FCj5EntryField = Entry(tab2,width=5)
FCj5EntryField.place(x=1070, y=465)
FCj6EntryField = Entry(tab2,width=5)
FCj6EntryField.place(x=1110, y=465)
# fine calibration pose element labels
FCxLab = Label(tab2, font=("Arial", 11), text = "X")
FCxLab.place(x=920, y=490)
FCyLab = Label(tab2, font=("Arial", 11), text = "Y")
FCyLab.place(x=960, y=490)
FCzLab = Label(tab2, font=("Arial", 11), text = "Z")
FCzLab.place(x=1000, y=490)
FCRxLab = Label(tab2, font=("Arial", 11), text = "Rz")
FCRxLab.place(x=1040, y=490)
FCRyLab = Label(tab2, font=("Arial", 11), text = "Ry")
FCRyLab.place(x=1080, y=490)
FCRzLab = Label(tab2, font=("Arial", 11), text = "Rx")
FCRzLab.place(x=1120, y=490)
# fine calibration pose element fields
FCxEntryField = Entry(tab2,width=5)
FCxEntryField.place(x=910, y=515)
FCyEntryField = Entry(tab2,width=5)
FCyEntryField.place(x=950, y=515)
FCzEntryField = Entry(tab2,width=5)
FCzEntryField.place(x=990, y=515)
FCrzEntryField = Entry(tab2,width=5)
FCrzEntryField.place(x=1030, y=515)
FCryEntryField = Entry(tab2,width=5)
FCryEntryField.place(x=1070, y=515)
FCrxEntryField = Entry(tab2,width=5)
FCrxEntryField.place(x=1110, y=515)
# button to initiate loading current position to display fields
FCSaveBut = Button(tab2, text="Save Curr Pos as FC", command = SaveCurPosToFC)
FCSaveBut.place(x=1165, y=405)
Thank you Ray! im just trying to work out how to compile it now fml never done it before