An imitation learning method for a multi-axis manipulator, wherein said multi-axis manipulator is infinitely redundant in a Cartesian space, the method carried out by a computing device comprising the steps of: capturing, at a set of successive waypoints (10,11) in a teach-in trajectory of a user-operated training tool, spatial data comprising position and orientation of the training tool in said Cartesian space; selecting, from among said set of successive waypoints (10,11), a subset of waypoints starting from a first waypoint of said set of successive waypoints (10,11), wherein for each subsequent waypoint to be selected a difference in position and/or orientation with respect to a last previously selected waypoint exceeds a predetermined threshold; fitting a set trajectory in said Cartesian space to said selected subset of waypoints; and converting said set trajectory into motion commands in a joint space of said multi-axis manipulator, wherein an optimal path of redundant joint positions maximizing Yoshikawa index values for the multi-axis manipulator along the set trajectory is calculated by: selecting a plurality of alternative initial redundant joint positions for a first waypoint in said set trajectory; calculating, for each one of said alternative initial redundant joint positions, a path of successive redundant joint positions by selecting, for each successive waypoint in the set trajectory, the redundant joint position resulting in the highest Yoshikawa index value for the multi-axis manipulator and complying with predetermined speed and/or acceleration limits with respect to the previous redundant joint position in the same path of successive redundant joint positions; interpolating, between said paths of successive redundant joint positions, a plurality of polynomial redundant joint trajectories; and extracting said optimal path from redundant joint positions in said plurality of polynomial redundant joint trajectories. capturing, at a set of successive waypoints (10,11) in a teach-in trajectory of a user-operated training tool, spatial data comprising position and orientation of the training tool in said Cartesian space; selecting, from among said set of successive waypoints (10,11), a subset of waypoints starting from a first waypoint of said set of successive waypoints (10,11), wherein for each subsequent waypoint to be selected a difference in position and/or orientation with respect to a last previously selected waypoint exceeds a predetermined threshold; fitting a set trajectory in said Cartesian space to said selected subset of waypoints; and converting said set trajectory into motion commands in a joint space of said multi-axis manipulator, wherein an optimal path of redundant joint positions maximizing Yoshikawa index values for the multi-axis manipulator along the set trajectory is calculated by: selecting a plurality of alternative initial redundant joint positions for a first waypoint in said set trajectory; calculating, for each one of said alternative initial redundant joint positions, a path of successive redundant joint positions by selecting, for each successive waypoint in the set trajectory, the redundant joint position resulting in the highest Yoshikawa index value for the multi-axis manipulator and complying with predetermined speed and/or acceleration limits with respect to the previous redundant joint position in the same path of successive redundant joint positions; interpolating, between said paths of successive redundant joint positions, a plurality of polynomial redundant joint trajectories; and extracting said optimal path from redundant joint positions in said plurality of polynomial redundant joint trajectories. selecting a plurality of alternative initial redundant joint positions for a first waypoint in said set trajectory; calculating, for each one of said alternative initial redundant joint positions, a path of successive redundant joint positions by selecting, for each successive waypoint in the set trajectory, the redundant joint position resulting in the highest Yoshikawa index value for the multi-axis manipulator and complying with predetermined speed and/or acceleration limits with respect to the previous redundant joint position in the same path of successive redundant joint positions; interpolating, between said paths of successive redundant joint positions, a plurality of polynomial redundant joint trajectories; and extracting said optimal path from redundant joint positions in said plurality of polynomial redundant joint trajectories.