UnfortunatelyJayanta's suggestion will not work. A cam connection restricts motion to one plane. The two curves used to create a cam pair must lie in the same plane and be expected to operate within this same plane. If surfaces are used then the motion is restricted to the plane perpendicular to the extrusion direction for both of these surfaces. Therefore, it is not possible to provide the proper range of motion even if you create a second cam pair perpendicular to the first. My previous suggestion provides the only three methods I believe are possible. To clarify this further, the combination joint of a ball and a planar must be done with 3 bodies in order to provide the proper motion - the first "motion" body is connected to the "ground", or flat plate, by means of a planar joint. The third body must then be connected to the second with a "ball" joint. You will not be able to resolve directions using a ball joint, so if this is important, your only choice isto use a 6DOF with one translation constrained by a motor or joint limit. 6DOFs track all translation and rotation degrees of freedom and allow you to create measures of motion and loading in all 6 DOFs. The 6DOF lets you connect just two bodies to provide the desired motion. The point on a plane "general" joint will allow you to resolve results in only the two translations, so this may not be desirable either but will provide the proper range of motion between just two bodies.
Regards,
Kaz Z06