Energy based Control Barrier Functions for Robotic Systems