  Control barrier functions (CBFs) are widely used in safety-critical
controllers. However, constructing a valid CBF is challenging, especially under
nonlinear or non-convex constraints and for high relative degree systems.
Meanwhile, finding a conservative CBF that only recovers a portion of the true
safe set is usually possible. In this work, starting from a "conservative"
handcrafted CBF (HCBF), we develop a method to find a CBF that recovers a
reasonably larger portion of the safe set. Since the learned CBF controller is
not guaranteed to be safe during training iterations, we use a model predictive
controller (MPC) to ensure safety during training. Using the collected
trajectory data containing safe and unsafe interactions, we train a neural
network to estimate the difference between the HCBF and a CBF that recovers a
closer solution to the true safe set. With our proposed approach, we can
generate safe controllers that are less conservative and computationally more
efficient. We validate our approach on two systems: a second-order integrator
and a ball-on-beam.
