Well I've answered my own question and let me tell ya it wasn't the easiest so I'm going to share it so that it might help someone else in the future.
the code will allow the cobot to search using force, I'm sure there may be an easier way to do it but i have broken it down so that it might be easier to understand it, I hope.
# 1. Move to initial posj
q0 = posj(-1.41,38.48,55.68,0.02,84.79,178.6) """These are my cobots positions, you'll have to add your own"""""""""
set_velj(10.0)
set_accj(60.0)
movej(q0)
# 2. Approach to the position to start force control set_velx(75.0)
set_accx(10.0)
delta_approach = [0.0, 0.0, -100.0, 0.0, 0.0, 0.0]
movel(delta_approach, mod=DR_MV_MOD_REL)
# 3. Start force control (apply -20N force along Base–z direction)
k_d = [3000.0, 3000.0, 3000.0, 200.0, 200.0, 200.0]
task_compliance_ctrl(k_d)
force_desired = 20.0
f_d = [0.0, 0.0, -force_desired, 0.0, 0.0, 0.0]
f_dir = [0, 0, 1, 0, 0, 0]
set_desired_force(f_d, f_dir)
# 4. Force & compliance control after detecting external force
force_check = 20.0
force_condition = check_force_condition(DR_AXIS_Z, max=force_check)
while (force_condition):
force_condition = check_force_condition(DR_AXIS_Z, max=force_check)
if force_condition == 0:
break
delta_motion = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0]
movel(delta_motion, mod=DR_MV_MOD_REL)
# 5. Retract 150mm in Base-z direction and move to initial posj release_force()
wait(0.5)
delta_retract = [0.0, 0.0, 150.0, 0.0, 0.0, 0.0]
release_compliance_ctrl()
movel(delta_retract, mod=DR_MV_MOD_REL)