You can use a composed joint to control the motion of two bodies using specific degrees of freedom (also called joint states).
You can decide to move and rotate the joint freely along and about any of the axes from the first body.