This paper presents a novel real-time collision-free speed alteration strategy using a danger index and an elite real-coded genetic algorithm (ERGA) for environments in which humans and robots coexist or cooperate, in order to guarantee the safety of an operator who works with a collaborative robot. A danger index based on ellipsoid modeling of the operator and robot describes the degree of safety during human-robot interactions. The ERGA and a penalty function are used to solve the constrained nonlinear optimization problem to change the handling speed of the robot. Comparative simulation results show the superiority of the proposed method by comparing to two existing methods. The applicability of the proposed method is verified using two experiments involving a 6-DoF industrial manipulator with an EtherCAT network protocol, an RGB-D sensor and a real-time operation system. INDEX TERMS Collaborative robot, danger index, ellipsoid modeling, elite real-coded genetic algorithm (ERGA), human-robot coexistence, human-robot cooperation, RGB-D sensor, speed alteration.