@@ -90,15 +90,16 @@ Matrix NumericalDerivativeActionWrtGroup(
9090// / Apply group action to the sensor sub-state.
9191SensorState sensorStateGroupAction (const VioGroup& X,
9292 const SensorState& sensor) {
93- const Pose3 A = APose (X);
94- const Vector3 w = AW (X);
93+ const Pose3 i0Ti1 = APose (X);
94+ const Pose3 c0Tc1 = B_cameraExtrinsics (X);
95+ const Vector3 velocityShift = AW (X);
9596
9697 SensorState out;
9798 out.inputBias = sensor.inputBias + Beta_biasOffset (X);
98- out.pose = sensor.pose .compose (A );
99- out.velocity = A .rotation ().unrotate (sensor.velocity - w );
99+ out.pose = sensor.pose .compose (i0Ti1 );
100+ out.velocity = i0Ti1 .rotation ().unrotate (sensor.velocity - velocityShift );
100101 out.cameraOffset =
101- A .inverse ().compose (sensor.cameraOffset ).compose (B_cameraExtrinsics (X) );
102+ i0Ti1 .inverse ().compose (sensor.cameraOffset ).compose (c0Tc1 );
102103 return out;
103104}
104105
@@ -191,25 +192,25 @@ Vector liftVelocity(const State& state, const IMUInput& velocity) {
191192VioGroup liftVelocityDiscrete (const State& state, const IMUInput& velocity,
192193 double dt) {
193194 const SensorState& sensor = state.sensor ;
195+ const Pose3& wTi0 = sensor.pose ;
196+ const Pose3& iTc = sensor.cameraOffset ;
194197 const IMUInput v_est = velocity - sensor.inputBias ;
195198
196199 const Rot3 dR = Rot3::Expmap (dt * v_est.gyr );
197- const Vector3 dXWorld =
198- dt * (sensor. pose .rotation () * sensor.velocity ) +
200+ const Vector3 deltaWorld =
201+ dt * (wTi0 .rotation () * sensor.velocity ) +
199202 0.5 * dt * dt *
200- (sensor. pose .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT));
201- const Point3 dXBody = sensor. pose . rotation ().unrotate (dXWorld );
202- const Pose3 A_pose (dR, dXBody );
203+ (wTi0 .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT));
204+ const Point3 deltaBody = wTi0. rotation ().unrotate (deltaWorld );
205+ const Pose3 i0Ti1 (dR, deltaBody );
203206
204207 const Vector3 bodyVelocityDiff =
205208 v_est.acc - sensor.gravityDir () * GRAVITY_CONSTANT;
206- const Vector3 w = sensor.velocity - (sensor.velocity + dt * bodyVelocityDiff);
209+ const Vector3 velocityShift =
210+ sensor.velocity - (sensor.velocity + dt * bodyVelocityDiff);
207211
208- const Pose3 B = sensor.cameraOffset .inverse ().compose (A_pose).compose (
209- sensor.cameraOffset );
210- const Pose3 cameraPoseChangeInv = sensor.cameraOffset .inverse ()
211- .compose (A_pose.inverse ())
212- .compose (sensor.cameraOffset );
212+ const Pose3 c0Tc1 = iTc.inverse ().compose (i0Ti1).compose (iTc);
213+ const Pose3 c1Tc0 = c0Tc1.inverse ();
213214
214215 // Construct the landmark transform velocities
215216 std::vector<SOT3> q;
@@ -218,7 +219,7 @@ VioGroup liftVelocityDiscrete(const State& state, const IMUInput& velocity,
218219 const Landmark& lm0 = state.cameraLandmarks [i];
219220 Landmark lm1;
220221 lm1.id = lm0.id ;
221- lm1.p = cameraPoseChangeInv .transformFrom (lm0.p );
222+ lm1.p = c1Tc0 .transformFrom (lm0.p );
222223
223224 const Rot3 R = RotationFromTwoVectors (lm1.p , lm0.p );
224225 const double a = lm0.p .norm () / lm1.p .norm ();
@@ -227,49 +228,48 @@ VioGroup liftVelocityDiscrete(const State& state, const IMUInput& velocity,
227228
228229 LandmarkGroup Q (q);
229230 const Bias beta (dt * velocity.accBiasVel , dt * velocity.gyrBiasVel );
230- const Se23 A = MakeA (A_pose .rotation (), A_pose .translation (), w );
231- return makeVioGroup (A, beta, B , Q);
231+ const Se23 A = MakeA (i0Ti1 .rotation (), i0Ti1 .translation (), velocityShift );
232+ return makeVioGroup (A, beta, c0Tc1 , Q);
232233}
233234
234235// / Integrate system dynamics over dt using IMU input.
235236State integrateSystemFunction (const State& state, const IMUInput& velocity,
236237 double dt) {
237238 State out;
238239 const SensorState& sensor = state.sensor ;
240+ const Pose3& wTi0 = sensor.pose ;
241+ const Pose3& iTc = sensor.cameraOffset ;
239242 const IMUInput v_est = velocity - sensor.inputBias ;
240243
241244 out.sensor .inputBias = Bias (
242245 sensor.inputBias .accelerometer () + dt * velocity.accBiasVel ,
243246 sensor.inputBias .gyroscope () + dt * velocity.gyrBiasVel );
244247
245248 const Rot3 dR = Rot3::Expmap (dt * v_est.gyr );
246- const Vector3 dXWorld =
247- dt * (sensor. pose .rotation () * sensor.velocity ) +
249+ const Vector3 deltaWorld =
250+ dt * (wTi0 .rotation () * sensor.velocity ) +
248251 0.5 * dt * dt *
249- (sensor. pose .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT));
250- const Point3 dXBody = sensor. pose . rotation ().unrotate (dXWorld );
251- const Pose3 poseChange (dR, dXBody );
252+ (wTi0 .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT));
253+ const Point3 deltaBody = wTi0. rotation ().unrotate (deltaWorld );
254+ const Pose3 i0Ti1 (dR, deltaBody );
252255
253- out.sensor .pose = sensor. pose . compose (poseChange );
256+ out.sensor .pose = wTi0. compose (i0Ti1 );
254257
255258 const Vector3 inertialVelocityDiff =
256- sensor. pose .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT);
259+ wTi0 .rotation () * v_est.acc + Vector3 (0 , 0 , -GRAVITY_CONSTANT);
257260 out.sensor .velocity = out.sensor .pose .rotation ().unrotate (
258- sensor. pose .rotation () * sensor.velocity + dt * inertialVelocityDiff);
261+ wTi0 .rotation () * sensor.velocity + dt * inertialVelocityDiff);
259262
260- const Pose3 cameraPoseChangeInv = sensor.cameraOffset .inverse ()
261- .compose (poseChange.inverse ())
262- .compose (sensor.cameraOffset );
263+ const Pose3 c1Tc0 = iTc.inverse ().compose (i0Ti1.inverse ()).compose (iTc);
263264 out.cameraLandmarks .resize (state.n ());
264265
265266 // Transform the body-fixed landmarks
266267 for (size_t i = 0 ; i < state.n (); ++i) {
267- out.cameraLandmarks [i].p =
268- cameraPoseChangeInv.transformFrom (state.cameraLandmarks [i].p );
268+ out.cameraLandmarks [i].p = c1Tc0.transformFrom (state.cameraLandmarks [i].p );
269269 out.cameraLandmarks [i].id = state.cameraLandmarks [i].id ;
270270 }
271271
272- out.sensor .cameraOffset = sensor. cameraOffset ;
272+ out.sensor .cameraOffset = iTc ;
273273 return out;
274274}
275275
@@ -299,20 +299,21 @@ State VIOSymmetry::operator()(
299299 const int d = xi.dim ();
300300 H_xi->setZero (d, d);
301301
302- const Pose3 A = APose (X);
302+ const Pose3 i0Ti1 = APose (X);
303+ const Pose3 c0Tc1 = B_cameraExtrinsics (X);
303304
304305 Matrix66 Hpose;
305- xi.sensor .pose .compose (A , Hpose, {});
306+ xi.sensor .pose .compose (i0Ti1 , Hpose, {});
306307 H_xi->block <6 , 6 >(6 , 6 ) = Hpose;
307308
308309 Matrix66 HtmpCamera, Hcamera;
309- const Pose3 tmp = A. inverse (). compose (xi. sensor . cameraOffset , {},
310- HtmpCamera);
311- (void )tmp .compose (B_cameraExtrinsics (X) , Hcamera, {});
310+ const Pose3 i1Tc0 =
311+ i0Ti1. inverse (). compose (xi. sensor . cameraOffset , {}, HtmpCamera);
312+ (void )i1Tc0 .compose (c0Tc1 , Hcamera, {});
312313 H_xi->block <6 , 6 >(15 , 15 ) = Hcamera * HtmpCamera;
313314
314315 H_xi->block <6 , 6 >(0 , 0 ).setIdentity ();
315- H_xi->block <3 , 3 >(12 , 12 ) = A .rotation ().matrix ().transpose ();
316+ H_xi->block <3 , 3 >(12 , 12 ) = i0Ti1 .rotation ().matrix ().transpose ();
316317
317318 // Compute the Jacobian of the landmark transform velocities
318319 for (size_t i = 0 ; i < xi.n (); ++i) {
0 commit comments