1
1
#!/usr/bin/env python
2
- # Copyright (c) 2016, Universal Robots A/S,
2
+ # Copyright (c) 2016-2022 , Universal Robots A/S,
3
3
# All rights reserved.
4
4
# Redistribution and use in source and binary forms, with or without
5
5
# modification, are permitted provided that the following conditions are met:
72
72
watchdog .input_int_register_0 = 0
73
73
74
74
75
- def setp_to_list (setp ):
76
- list = []
75
+ def setp_to_list (sp ):
76
+ sp_list = []
77
77
for i in range (0 , 6 ):
78
- list .append (setp .__dict__ ["input_double_register_%i" % i ])
79
- return list
78
+ sp_list .append (sp .__dict__ ["input_double_register_%i" % i ])
79
+ return sp_list
80
80
81
81
82
- def list_to_setp (setp , list ):
82
+ def list_to_setp (sp , list ):
83
83
for i in range (0 , 6 ):
84
- setp .__dict__ ["input_double_register_%i" % i ] = list [i ]
85
- return setp
84
+ sp .__dict__ ["input_double_register_%i" % i ] = list [i ]
85
+ return sp
86
86
87
87
88
88
# start data synchronization
89
89
if not con .send_start ():
90
90
sys .exit ()
91
91
92
92
# control loop
93
+ move_completed = True
93
94
while keep_running :
94
95
# receive the current state
95
96
state = con .receive ()
@@ -98,11 +99,18 @@ def list_to_setp(setp, list):
98
99
break
99
100
100
101
# do something...
101
- if state .output_int_register_0 != 0 :
102
+ if move_completed and state .output_int_register_0 == 1 :
103
+ move_completed = False
102
104
new_setp = setp1 if setp_to_list (setp ) == setp2 else setp2
103
105
list_to_setp (setp , new_setp )
106
+ print ("New pose = " + str (new_setp ))
104
107
# send new setpoint
105
108
con .send (setp )
109
+ watchdog .input_int_register_0 = 1
110
+ elif not move_completed and state .output_int_register_0 == 0 :
111
+ print ("Move to confirmed pose = " + str (state .target_q ))
112
+ move_completed = True
113
+ watchdog .input_int_register_0 = 0
106
114
107
115
# kick watchdog
108
116
con .send (watchdog )
0 commit comments