Safe Learning-Based Control of Elastic Joint Robots via Control Barrier Functions