Different performance between effort control and position control

Recently, we test the API gym.apply_actor_dof_efforts and gym.set_actor_dof_position_targets using following invocations, and get different performance.

props = gym.get_actor_dof_properties(env, actor_handle)
if not is_pos:
    props["stiffness"] = [0] * num_dofs
    props["damping"] = [0] * num_dofs
    props["driveMode"].fill(gymapi.DOF_MODE_EFFORT)
else:
    props["stiffness"] = stiffness
    props["damping"] = damping
    props["driveMode"].fill(gymapi.DOF_MODE_POS)
gym.set_actor_dof_properties(env, actor_handle, props)

while not gym.query_viewer_has_closed(viewer):
    gym.simulate(sim)
    gym.fetch_results(sim, True)

    gym.step_graphics(sim)
    gym.draw_viewer(viewer, sim, True)

    dof_states = gym.get_actor_dof_states(env, actor_handle, gymapi.STATE_ALL)
    actual_pos.append(list(dof_states["pos"]))
    actual_vel = dof_states["vel"]
    
    if not is_pos:
        for i in range(num_dofs):
            target_effort[i] = stiffness[i] * (target_pos[i] - actual_pos[-1][i])+ damping[i] * actual_vel[i]
        gym.apply_actor_dof_efforts(env, actor_handle, target_effort)
    else:
        gym.set_actor_dof_position_targets(env, actor_handle, target_pos)

    gym.sync_frame_time(sim)
gym.destroy_viewer(viewer)
gym.destroy_sim(sim)

Then we check the docs, and found that position control is propotional to posError * stiffness + velError * damping, but we don’t know the coefficent. Therefore, we want to know the specific underlying implementation of the position controller, is there any difference between two controllers using the same stiffness and damping parameters?

Look forward to a reply!

2022-07-14T00:00:00Z