diff --git a/dexarm.py b/dexarm.py index 399a4ab..02198fc 100644 --- a/dexarm.py +++ b/dexarm.py @@ -62,13 +62,21 @@ def go_home1(self): #This is a personal test. #self._send_cmd1("X0 Y0 Z-10 E0\r") - #def set_relative1(self): + def set_relativeDown1(self): #This is a personal test. - #self._send_cmd1("G91\r") + self._send_cmd1("G91\r") + self._send_cmd1("G0 Z-5\n") + self._send_cmd1("G90\r") - #def set_absolute1(self): + def set_relativeUp1(self): #This is a personal test. - #self._send_cmd1("G90\r") + self._send_cmd1("G91\r") + self._send_cmd1("G0 Z5\n") + self._send_cmd1("G90\r") + + def set_absolute1(self): + #This is a personal test. + self._send_cmd1("G90\r") def read_test1(self): #This is a personal test. @@ -343,4 +351,7 @@ def close1(self): """ self.ser1.close() -print('Dexarm class loaded') \ No newline at end of file +print('Dexarm class loaded') + + +execfile('resource/Dexarm/scripts/example.py') \ No newline at end of file diff --git a/example.py b/example.py index 19fe06e..8d10571 100644 --- a/example.py +++ b/example.py @@ -2,18 +2,21 @@ # Basic script for coordinating 2 dexarms with MRL # for virtual testing -runtime.setVirtual(True) +runtime.setVirtual(False) # variables dexarmPort1 = 'COM3' dexarmPort2 = 'COM4' # joystick map -joy_move_to = "Num 3" # "Num 3" -joy_exec_file = "Num 9" joy_test1 = "Num 1" +joy_go_home = "Num 2" +joy_move_to = "Num 3" # "Num 3" joy_disconnect = "Num 5" joy_set_work_origin = "Num 8" +joy_exec_file = "Num 9" +joy_down_dexarm2 = "Down" +joy_up_dexarm2 = "Up" # start 2 dexarms dexarm1 = Dexarm('serial1', dexarmPort1) @@ -22,6 +25,7 @@ # start the services python = Runtime.start("python","Python") joy = Runtime.start("joy","Joystick") +swing = Runtime.start("swing","SwingGui") #this set which kind of controller you want to poll data from #it is the number you can see in the Joystick GUI when you open the list of devices @@ -39,38 +43,51 @@ def onJoystickInput(data): if (data.id == joy_move_to): if (data.value == 1): print(joy_move_to, "was pressed its value is", data.value) - # dexarm1.read_test1() dexarm1.move_to1(50, 300, 0) - # dexarm1.read_Gcode1() + #dexarm1.read_Gcode1() print('moved dexarm1 to 50, 300, 0') - elif (data.id == "Num 9"): - print("script example.py", data.value) - execfile(RuningFolder+'/Dexarm/scripts/example.py') - elif (data.id == "Num 1"): - print("test1", data.value) - dexarm2.move_to2(0, 220, 50) - dexarm1.set_module_type1(0) - dexarm1.read_Gcode1() - elif (data.id == "Num 2"): - print("Go home", data.value) - dexarm1.go_home1() - dexarm2.go_home2() - elif (data.id == "Num 5"): - print("Disconnect", data.value) - dexarm1.disconnect1() - dexarm2.disconnect2() - #elif (data.id == "Num 4"): - #print("Moving down", data.value) - #dexarm.move_down() - #elif (data.id == "Num 7"): - #print("Moving down", data.value) - #dexarm.set_relative() - #elif (data.id == "Num 6"): - #print("Moving down", data.value) - #dexarm.set_absolute() - elif (data.id == "Num 8"): - print("Set work origin", data.value) - dexarm1.set_workorigin1() - + #print('moved dexarm1 to test1.gcode') + elif (data.id == joy_exec_file): + if (data.value == 1): + print("executing script example.py", data.value) + execfile(RuningFolder+'/Dexarm/scripts/example.py') + elif (data.id == joy_test1): + if (data.value == 1): + print("reading test1.gcode", data.value) + dexarm2.move_to1(0, 220, 50) + dexarm1.set_module_type1(0) + dexarm1.read_Gcode1() + elif (data.id == joy_go_home): + if (data.value == 1): + print("Go home", data.value) + dexarm1.go_home1() + dexarm2.go_home1() + elif (data.id == joy_disconnect): + if (data.value == 1): + print("Disconnect", data.value) + dexarm1.disconnect1() + dexarm2.disconnect1() + elif (data.id == joy_set_work_origin): + if (data.value == 1): + print(joy_set_work_origin, "Work origin is set", data.value) + dexarm1.set_workorigin1() + elif (data.id == joy_down_dexarm2): + if (data.value == 1): + print("Moving down dexarm2", data.value) + dexarm2.set_relativeDown1() + elif (data.id == joy_up_dexarm2): + if (data.value == 1): + print("Moving up dexarm2", data.value) + dexarm2.set_relativeUp1() +''' + elif (data.id == "Down"): + if (data.value == 1): + print("Moving down dexarm1", data.value) + dexarm1.set_relativeDown1() + elif (data.id == "Up"): + if (data.value == 1): + print("Moving up dexarm1", data.value) + dexarm1.set_relativeUp1() +''' print('example script loaded')