# E2-VINS: An Event-Enhanced Visual-Inertial SLAM Scheme for Dynamic Environments
## 3 Methodology
### Event-Based Dynamicity-Adaptive Bundle Adjustment  
* Dynamicity-adaptive Objective Function In the conventional SLAM scheme [2], the visual-inertial BA formulation is defined as follows: \[\min_{\mathcal{X}}\Biggl{\{}\left\|\mathbf{r}_{p}-\mathbf{H}_{p}\mathcal{X} \right\|^{2}+\sum_{k\in\mathcal{B}}\Bigl{\|}\mathbf{r}_{S}\Bigl{(}\mathbf{z} _{h_{k+1}}^{h_{k}},\mathcal{X}\Bigr{)}\Bigr{\|}_{\mathbf{P}_{h_{k+1}}^{h_{k} }}^{2}+\sum_{(l,j)\in\mathcal{C}}\rho\Bigl{(}\left\|\mathbf{r}_{c}\Bigl{(} \mathbf{z}_{l}^{c_{j}},\mathcal{X}\Bigr{)}\right\|_{\mathbf{P}_{l}^{c_{j}}}^{2} \Bigr{)}\Biggr{\}},\] (7)  
Figure 4: Illustration of self-motion compensation when the rotation angle on the Y axis is \(\theta_{k}\). The Y axis compensation displacement occurs when the initial coordinate of an event is not at \(\mathbf{o}\). \(\mathbf{u}_{k}\) is the coordinate of the event triggered by the object \(\mathbf{p}\). After the camera rotates by an angle \(\theta_{k}\) around the Y axis, \(\mathbf{u}_{k}\) moves to \(\mathbf{u}_{k}^{\prime}\). This process can be seen as the motion of 3D point \(\mathbf{p}\) to the point \(\mathbf{p}^{\prime}\), which corresponds to \(\mathbf{u}_{k}^{\prime}\) in the original pose. In this view, the incident angles before and after the movement are \(\xi_{x}+\theta_{k}\) and \(\xi_{x}\), respectively. The angle \(\xi_{x}\) can be calculated using Equation 6. Furthermore, the compensation displacement \(\mathbf{t}_{z}\) in the pixel plane can be obtained. where \(\mathcal{X}\) represents the full state vector containing the poses and velocities of keyframes, IMU biases (i.e., acceleration and gyroscope biases), and the estimated depths of features, as detailed in [2]. The terms \(\mathbf{r}_{p}\), \(\mathbf{r}_{B}\), and \(\mathbf{r}_{C}\) represent residuals for marginalization, IMU, and visual reprojection measurements, respectively. \(\hat{\mathbf{z}}_{b_{k+1}}^{b_{k}}\) and \(\hat{\mathbf{z}}_{l}^{c_{j}}\) denote the observations of the IMU and feature points, respectively. \(\mathbf{H}_{p}\) denotes the measurement matrix for marginalization, and \(\rho\) is the Huber loss function. \(\|\mathbf{r}\|_{\mathbf{P}}^{2}=\sqrt{\mathbf{r}^{T}\mathbf{Pr}}\) represents the Mahalanobis distance for residual term \(\mathbf{r}\), where \(\mathbf{P}\) denotes the covariance matrix of the term. The Mahalanobis distance is an effective distance measurement method for two sets of points in multidimensional space, considering their correlation. For convenience, we denote \(\mathbf{r}_{B}\Big{(}\hat{\mathbf{z}}_{b_{k+1}}^{b_{k}},\mathcal{X}\Big{)}\) and \(\mathbf{r}_{C}\Big{(}\hat{\mathbf{z}}_{l}^{c_{j}},\mathcal{X}\Big{)}\) as \(\mathbf{r}_{B}^{k}\) and \(\mathbf{r}_{C}^{l,j}\), respectively. In dynamic environments, the Huber loss cannot entirely reject the residuals from outliers [36]. To effectively address this issue, we propose assigning dynamicity-adaptive weights (dynamicity weights) to the visual residuals \(\mathbf{r}_{C}\) of different pixels, thereby filtering out dynamic features through soft thresholding. Specifically, the visual residual term is modified to a novel loss function \(\dot{\rho}\):  
\[\dot{\rho}(w_{ev}^{l},\mathbf{r}_{C}^{l})=w_{ev}^{l}{}^{2}\mathbf{r}_{C}^{l}+ \lambda_{ev}(1-w_{ev}^{l})^{2}. \tag{8}\]  
According to the Black-Rangarajan duality [37], the loss function \(\dot{\rho}\) is equivalent to the original visual residual term \(\mathbf{r}_{C}\). In Equation (8), \(\mathbf{r}_{C}^{l}\) is computed as \(\mathbf{r}_{C}^{l}=\sum_{j\in\mathcal{C}(f_{l})}\left\|\mathbf{r}_{C}^{l,j} \right\|^{2}\), where \(\mathbf{r}_{C}^{l,j}\) represents the residual for the \(j\)-th observation of the \(l\)-th feature, and \(\mathcal{C}(f_{l})\) denotes the set of observations associated with feature \(f_{l}\). \(w_{ev}^{l}\) represents the dynamicity weight for feature \(f_{l}\). Features with weights close to \(1\) are considered static, while those with weights close to \(0\) are considered dynamic.