  This work proposes an optimal safe controller minimizing an infinite horizon
cost functional subject to control barrier functions (CBFs) safety conditions.
The constrained optimal control problem is reformulated as a minimization
problem of the Hamilton-Jacobi-Bellman (HJB) equation subjected to the safety
constraints. By solving the optimization problem, we are able to construct a
closed form solution that satisfies optimality and safety conditions. The
proposed solution is shown to be continuous and thus it renders the safe set
forward invariant while minimizing the given cost. Hence, optimal
stabilizability and safety objectives are achieved simultaneously. To
synthesize the optimal safe controller, we present a modified Galerkin
successive approximation approach which guarantees an optimal safe solution
given a stabilizing safe initialization. The proposed algorithm is implemented
on a constrained nonlinear system to show its efficacy.
