In production robots are moved at maximum speed whenever possible in order to achieve the shortest overall cycle time. This can lead to individual waiting times, especially in interlinked production processes. These waiting times offer opportunities for optimization. Due to high energy prices and political efforts, energy efficiency has become the focus of trajectory optimization in recent years. Robot cells with a common intermediate circuit offer the possibility of energy exchange across individual axes or robots. By adapting the robot trajectories, the total power consumption of a robotic cell on the grid side can be significantly reduced. This paper focuses on trajectory optimization, whereby a detailed collision detection of individual robots is included within the analysis. It is shown that with collision detection energy optimization for cramped robot cells becomes possible and the losses in efficiency compared to the optimization without it are minute.