In this paper, we propose a constrained optimization formulation of SLAM and a robust incremental SLAM framework. The new SLAM formulation is derived from the nonlinear least squares (NLS) formulation by mathematically formulating loop-closure cycles as constraints. Under the constrained SLAM formulation, we study the robustness of an incremental SLAM algorithm against local minima and outliers as a constraint/loopclosure cycle selection problem. We find a constraint metric that can predict the objective function growth after including the constraint. By the virtue of the constraint metric, we select constraints into the incremental SLAM according to a least objective function growth principle to increase robustness against local minima, and perform χ 2 difference test on the constraint metric to increase robustness against outliers. Finally, using sequential quadratic programming (SQP) as the solver, an incremental SLAM algorithm (iSQP) is proposed. Experimental validations are provided to illustrate the accuracy of the constraint metric, and the robustness of the proposed incremental SLAM algorithm. Nonetheless, the proposed approach is currently confined to datasets with sparse loop-closures due to its computational cost.