Real-time trajectory scaling for robot manipulators