def on_palm(sim):
    """ Determines if the cube is on the palm of the hand."""
    sim.forward()
    cube_middle_idx = sim.model.site_name2id("cube:center")
    cube_middle_pos = sim.data.site_xpos[cube_middle_idx]
    is_on_palm = cube_middle_pos[2] > 0.04
    return is_on_palm