Skip to content

Commit a8af9c1

Browse files
committed
1.Exit if control force fails;2.Cancel counter string
1 parent 60d0ea3 commit a8af9c1

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

example/wrapper/common/8003-force_control.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,35 @@
4646

4747
# set pid parameters for force control
4848
Kp = 0.005 # range: 0 ~ 0.05
49-
Ki = 0.00006 # range: 0 ~ 0.0005
50-
Kd = 0.000 # range: 0 ~ 0.05
51-
v_max = 100.0 # max adjust velocity(mm/s), range: 0 ~ 200
52-
arm.set_force_control_pid([Kp]*6, [Ki]*6, [Kd]*6, [v_max]*6)
49+
Ki = 0.00005 # range: 0 ~ 0.0005
50+
Kd = 0.05 # range: 0 ~ 0.1
51+
linear_v_max = 200.0 # max adjust velocity(mm/s), range: 0 ~ 200
52+
rot_v_max = 0.35 # rad/s range: 0~pi/4
53+
arm.set_force_control_pid([Kp]*6, [Ki]*6, [Kd]*6, [linear_v_max, linear_v_max, linear_v_max, rot_v_max, rot_v_max, rot_v_max])
5354

5455
ref_frame = 1 # 0 : base , 1 : tool
5556
force_axis = [0, 0, 1, 0, 0, 0] # only control force along z axis
5657
# MAKE SURE reference frame and force target sign are correct !!
5758
force_ref = [0, 0, 5.0, 0, 0, 0] # the force(N) that xArm will apply to the environment
58-
arm.config_force_control(ref_frame, force_axis, force_ref, [0]*6) # limits are reserved, just give zeros
59+
code = arm.config_force_control(ref_frame, force_axis, force_ref, [0]*6) # limits are reserved, just give zeros
60+
if code == 0 and arm.error_code == 0:
5961

60-
# enable ft sensor communication
61-
arm.ft_sensor_enable(1)
62+
# enable ft sensor communication
63+
arm.ft_sensor_enable(1)
6264

63-
# will overwrite previous sensor zero and payload configuration
64-
arm.ft_sensor_set_zero() # remove this if zero_offset and payload already identified & compensated!
65-
time.sleep(0.2) # wait for writing zero operation to take effect, do not remove
65+
# will overwrite previous sensor zero and payload configuration
66+
arm.ft_sensor_set_zero() # remove this if zero_offset and payload already identified & compensated!
67+
time.sleep(0.2) # wait for writing zero operation to take effect, do not remove
6668

67-
# move robot in force control
68-
arm.ft_sensor_app_set(2)
69-
# will start after set_state(0)
70-
arm.set_state(0)
69+
# move robot in force control
70+
arm.ft_sensor_app_set(2)
71+
# will start after set_state(0)
72+
arm.set_state(0)
7173

72-
# keep for 5 secs
73-
time.sleep(5)
74+
# keep for 5 secs
75+
time.sleep(5)
7476

75-
# remember to reset ft_sensor_app when finished
76-
arm.ft_sensor_app_set(0)
77-
arm.ft_sensor_enable(0)
77+
# remember to reset ft_sensor_app when finished
78+
arm.ft_sensor_app_set(0)
79+
arm.ft_sensor_enable(0)
7880
arm.disconnect()

xarm/tools/blockly/_blockly_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _get_condition_expression(self, value_block, arg_map=None):
214214
direction = fields[0].text
215215
return 'self._arm.get_joints_torque()[1][{}]'.format(direction_li.index(direction))
216216
elif block.attrib['type'] == 'get_counter':
217-
return 'str(self._arm.count)'
217+
return 'self._arm.count'
218218

219219

220220
def __get_logic_compare(self, block, arg_map=None):

0 commit comments

Comments
 (0)