@@ -94,9 +94,13 @@ def clear(self) -> None:
9494 self ._phi_buf .clear ()
9595
9696 def _smooth (self ):
97- if len (self ._x_buf ) <= 1 :
98- self ._x = np .asarray_chkfinite (self ._x_buf )
99- self ._P = np .asarray_chkfinite (self ._P_buf )
97+ if len (self ._x_buf ) == 0 :
98+ self ._x = np .empty ((0 , 16 ), dtype = "float64" )
99+ self ._P = np .empty ((0 , * self ._ains .P .shape ), dtype = "float64" )
100+ return
101+ elif len (self ._x_buf ) == 1 :
102+ self ._x = np .asarray_chkfinite (self ._x_buf ).copy ()
103+ self ._P = np .asarray_chkfinite (self ._P_buf ).copy ()
100104 elif len (self ._x_buf ) != len (self ._x ):
101105 self ._x , self ._P = self ._backward_sweep (
102106 self ._x_buf ,
@@ -150,7 +154,7 @@ def position(self) -> NDArray:
150154 """
151155 x = self .x
152156 if x .size == 0 :
153- return np .empty ((0 , 3 ))
157+ return np .empty ((0 , 3 ), dtype = "float64" )
154158 return self .x [:, :3 ]
155159
156160 def velocity (self ) -> NDArray :
@@ -165,7 +169,7 @@ def velocity(self) -> NDArray:
165169 """
166170 x = self .x
167171 if x .size == 0 :
168- return np .empty ((0 , 3 ))
172+ return np .empty ((0 , 3 ), dtype = "float64" )
169173 return self .x [:, 3 :6 ]
170174
171175 def quaternion (self ) -> NDArray :
@@ -180,7 +184,7 @@ def quaternion(self) -> NDArray:
180184 """
181185 x = self .x
182186 if x .size == 0 :
183- return np .empty ((0 , 4 ))
187+ return np .empty ((0 , 4 ), dtype = "float64" )
184188 return self .x [:, 6 :10 ]
185189
186190 def bias_acc (self ) -> NDArray :
@@ -195,7 +199,7 @@ def bias_acc(self) -> NDArray:
195199 """
196200 x = self .x
197201 if x .size == 0 :
198- return np .empty ((0 , 3 ))
202+ return np .empty ((0 , 3 ), dtype = "float64" )
199203 return x [:, 10 :13 ]
200204
201205 def bias_gyro (self , degrees : bool = False ) -> NDArray :
@@ -210,7 +214,7 @@ def bias_gyro(self, degrees: bool = False) -> NDArray:
210214 """
211215 x = self .x
212216 if x .size == 0 :
213- return np .empty ((0 , 3 ))
217+ return np .empty ((0 , 3 ), dtype = "float64" )
214218
215219 bg = self .x [:, 13 :16 ]
216220 return np .degrees (bg ) if degrees else bg
@@ -227,7 +231,7 @@ def euler(self, degrees: bool = False) -> NDArray:
227231 """
228232 q = self .quaternion ()
229233 if q .size == 0 :
230- return np .empty ((0 , 3 ))
234+ return np .empty ((0 , 3 ), dtype = "float64" )
231235
232236 theta = np .array ([_euler_from_quaternion (q_i ) for q_i in q ])
233237 return np .degrees (theta ) if degrees else theta
0 commit comments