I'm doing a pick and place task using UR3 in webots. I need the robot to go to Pick position, grasp the object (close its fingers), and go to Place position. Something like following code:
while (wb_robot_step(TIME_STEP) != -1) {
// 1. Go to Pick position
for (i = 0; i < 6; ++i)
wb_motor_set_position(ur_motors[i], pick_position[i]);
// 2. Grasp the object
for (i = 0; i < 2; ++i)
wb_motor_set_position(finger_motors[i], 0.5);
// 3. Go to Place position
for (i = 0; i < 6; ++i)
wb_motor_set_position(ur_motors[i], place_position[i]);
}
However, when I run the code, I see that while robot is going to Pick position, fingers also get closed. I read in documentations that "the wb_motor_set_position function stores the new position, but it does not immediately actuate the motor". So I want to know how I can add a delay between step 1 and 2, i.e., fingers get closed only after motor actuation reached the desired position. I used sleep but didn't help.