  This paper introduces differentiable higher-order control barrier functions
(CBF) that are end-to-end trainable together with learning systems. CBFs are
usually overly conservative, while guaranteeing safety. Here, we address their
conservativeness by softening their definitions using environmental
dependencies without loosing safety guarantees, and embed them into
differentiable quadratic programs. These novel safety layers, termed a
BarrierNet, can be used in conjunction with any neural network-based
controller, and can be trained by gradient descent. BarrierNet allows the
safety constraints of a neural controller be adaptable to changing
environments. We evaluate them on a series of control problems such as traffic
merging and robot navigations in 2D and 3D space, and demonstrate their
effectiveness compared to state-of-the-art approaches.
