|
46 | 46 |
|
47 | 47 | # set pid parameters for force control
|
48 | 48 | 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]) |
53 | 54 |
|
54 | 55 | ref_frame = 1 # 0 : base , 1 : tool
|
55 | 56 | force_axis = [0, 0, 1, 0, 0, 0] # only control force along z axis
|
56 | 57 | # MAKE SURE reference frame and force target sign are correct !!
|
57 | 58 | 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: |
59 | 61 |
|
60 |
| -# enable ft sensor communication |
61 |
| -arm.ft_sensor_enable(1) |
| 62 | + # enable ft sensor communication |
| 63 | + arm.ft_sensor_enable(1) |
62 | 64 |
|
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 |
66 | 68 |
|
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) |
71 | 73 |
|
72 |
| -# keep for 5 secs |
73 |
| -time.sleep(5) |
| 74 | + # keep for 5 secs |
| 75 | + time.sleep(5) |
74 | 76 |
|
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) |
78 | 80 | arm.disconnect()
|
0 commit comments