Trajectory planning is a fundamental problem for industrial robots. It is particularly challenging for robot manipulators that transfer silicon wafers in an equipment front end module (EFEM) of a semiconductor manufacturing machine where the work space is extremely limited. Existing methods cannot give satisfactory performance since they usually solve the problem partially. Motivated by this demand in industrial applications and to solve all aspects of the problem, this paper proposes to learn the work environment beforehand by probabilistic roadmap (PRM) method for collision avoidance. The cycle time preference and the robot kinematic hard constraints are considered properly. A constrained optimization problem is formulated with the shortest path searched from the roadmap and parametrized by a cubic B-spline curve, which simplifies the optimization process.