Optimize on-manifold: Left or Right Plus in LocalParameterization::Plus()?

398 views
Skip to first unread message
Message has been deleted

f2020 l_

unread,
Apr 22, 2021, 6:05:37 PM4/22/21
to ceres-...@googlegroups.com
Hi,
I am new to ceres solver. I have some question about writing LocalParameterization:
When I read the tutorials and other researchers' open source projects, I saw their LocalParameterization parts are different.

If using 7D quaternion + translation (qx qy qz qw tx ty tz) as global variables, and 6D Lie algebra (tx ty tz r1 r2 r3) as local variables, for the code: 

-------------------------------------------------------------
class LocalParameterizationSE3 : public ceres::LocalParameterization
{
public:
  virtual ~LocalParameterizationSE3(){}
  virtual bool Plus
  (
    float const* T_raw, 
    float const* delta_raw, 
    float* T_plus_delta_raw
  ) const
  {
    Eigen::Map<Sophus::SE3f const> const pose_se3(T_raw);
    // Eigen::Map<Eigen::Matrix<float, 6, 1, Eigen::RowMajor> const> delta(delta_raw);
    Eigen::Map<Eigen::Vector6f const> delta(delta_raw);
    Eigen::Map<Sophus::SE3f> T_plus_delta(T_plus_delta_raw);
    T_plus_delta = pose_se3 * Sophus::SE3f::exp(delta);

    return true;
  }

private:
  virtual bool ComputeJacobian
  (
    float const* T_raw,
    float* jacobian_raw
  ) const
  {
    Eigen::Map<Sophus::SE3f const> pose_se3(T_raw);
    Eigen::Map<Eigen::Matrix<float, 7, 6, Eigen::RowMajor>> jacobian(jacobian_raw);
    jacobian = pose_se3.Dx_this_mul_exp_x_at_0();
    return true;
  }
}
-----------------------------------------------------------------

Q1: What time do I use left plus or right plus? Or I can choose either one that I prefer, and then write corresponding ComputeJacobian()?
left plus: out_T = exp(delta_T) * T
right plus: out_T = T * exp(delta_T)

Q2: Are the jacobians the same for right/left plus?

Q3: Is there any material about computing the jacobian of `T * exp(delta_T)` and `exp(delta_T) * T` ?

Sameer Agarwal

unread,
Apr 23, 2021, 12:30:52 PM4/23/21
to ceres-...@googlegroups.com
you can choose left or right and then have the Jacobian accordingly.


On Thu, Apr 22, 2021 at 3:08 PM f2020 l_ <lanfeiy...@gmail.com> wrote:
Hi,
I am new to ceres solver. I have some question about writing LocalParameterization:
When I read the tutorials and other researchers' open source projects, I saw their LocalParameterization parts are different.

If using 7D quaternion + translation (qx qy qz qw tx ty tz) as global variables, and 6D Lie algebra (tx ty tz r1 r2 r3) as local variables, for the code: (Sorry I don't know how to insert code block in google group)

Screenshot from 2021-04-22 23-07-42.png

Q1: What time do I use left plus or right plus? Or I can choose either one that I prefer, and then write corresponding ComputeJacobian()?
left plus: out_T = exp(delta_T) * T
right plus: out_T = T * exp(delta_T)

Q2: Are the jacobians the same for right/left plus?

Q3: Is there any material about computing the jacobian of `T * exp(delta_T)` and `exp(delta_T) * T` ?

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/4f7c9a47-7a76-4e65-93f0-c788aa27e3afn%40googlegroups.com.

Sameer Agarwal

unread,
Apr 23, 2021, 12:51:50 PM4/23/21
to ceres-...@googlegroups.com
https://arxiv.org/abs/1107.1119

Is what you want to read.
Sameer


On Thu, Apr 22, 2021 at 2:59 PM f2020 l_ <lanfeiy...@gmail.com> wrote:
Hi,
I am new to ceres solver. I have some question about writing LocalParameterization:
When I read the tutorials and other researchers' open source projects, I saw their LocalParameterization parts are different.

If using 7D quaternion + translation (qx qy qz qw tx ty tz) as global variables, and 6D Lie algebra (tx ty tz r1 r2 r3) as local variables, for the code: 

<pre style='color:#000000;background:#ffffff;'><span style='color:#800000; font-weight:bold; '>class</span> LocalParameterizationSE3 <span style='color:#800080; '>:</span> <span style='color:#800000; font-weight:bold; '>public</span> ceres<span style='color:#800080; '>::</span>LocalParameterization
<span style='color:#800080; '>{</span>
<span style='color:#800000; font-weight:bold; '>public</span><span style='color:#e34adc; '>:</span>
  <span style='color:#800000; font-weight:bold; '>virtual</span> <span style='color:#808030; '>~</span>LocalParameterizationSE3<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>{</span><span style='color:#800080; '>}</span>
  <span style='color:#800000; font-weight:bold; '>virtual</span> <span style='color:#800000; font-weight:bold; '>bool</span> Plus
  <span style='color:#808030; '>(</span>
    <span style='color:#800000; font-weight:bold; '>float</span> <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#808030; '>*</span> T_raw<span style='color:#808030; '>,</span> 
    <span style='color:#800000; font-weight:bold; '>float</span> <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#808030; '>*</span> delta_raw<span style='color:#808030; '>,</span> 
    <span style='color:#800000; font-weight:bold; '>float</span><span style='color:#808030; '>*</span> T_plus_delta_raw
  <span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>const</span>
  <span style='color:#800080; '>{</span>
    Eigen<span style='color:#800080; '>::</span>Map<span style='color:#800080; '>&lt;</span>Sophus<span style='color:#800080; '>::</span>SE3f <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#800080; '>></span> <span style='color:#800000; font-weight:bold; '>const</span> pose_se3<span style='color:#808030; '>(</span>T_raw<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#696969; '>// Eigen::Map&lt;Eigen::Matrix&lt;float, 6, 1, Eigen::RowMajor> const> delta(delta_raw);</span>
    Eigen<span style='color:#800080; '>::</span>Map<span style='color:#800080; '>&lt;</span>Eigen<span style='color:#800080; '>::</span>Vector6f <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#800080; '>></span> delta<span style='color:#808030; '>(</span>delta_raw<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    Eigen<span style='color:#800080; '>::</span>Map<span style='color:#800080; '>&lt;</span>Sophus<span style='color:#800080; '>::</span>SE3f<span style='color:#800080; '>></span> T_plus_delta<span style='color:#808030; '>(</span>T_plus_delta_raw<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    T_plus_delta <span style='color:#808030; '>=</span> pose_se3 <span style='color:#808030; '>*</span> Sophus<span style='color:#800080; '>::</span>SE3f<span style='color:#800080; '>::</span><span style='color:#603000; '>exp</span><span style='color:#808030; '>(</span>delta<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#800000; font-weight:bold; '>return</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
  <span style='color:#800080; '>}</span>

<span style='color:#800000; font-weight:bold; '>private</span><span style='color:#e34adc; '>:</span>
  <span style='color:#800000; font-weight:bold; '>virtual</span> <span style='color:#800000; font-weight:bold; '>bool</span> ComputeJacobian
  <span style='color:#808030; '>(</span>
    <span style='color:#800000; font-weight:bold; '>float</span> <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#808030; '>*</span> T_raw<span style='color:#808030; '>,</span>
    <span style='color:#800000; font-weight:bold; '>float</span><span style='color:#808030; '>*</span> jacobian_raw
  <span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>const</span>
  <span style='color:#800080; '>{</span>
    Eigen<span style='color:#800080; '>::</span>Map<span style='color:#800080; '>&lt;</span>Sophus<span style='color:#800080; '>::</span>SE3f <span style='color:#800000; font-weight:bold; '>const</span><span style='color:#800080; '>></span> pose_se3<span style='color:#808030; '>(</span>T_raw<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    Eigen<span style='color:#800080; '>::</span>Map<span style='color:#808030; '>&lt;</span>Eigen<span style='color:#800080; '>::</span>Matrix<span style='color:#808030; '>&lt;</span><span style='color:#800000; font-weight:bold; '>float</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>7</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>6</span><span style='color:#808030; '>,</span> Eigen<span style='color:#800080; '>::</span>RowMajor<span style='color:#808030; '>></span><span style='color:#808030; '>></span> jacobian<span style='color:#808030; '>(</span>jacobian_raw<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    jacobian <span style='color:#808030; '>=</span> pose_se3<span style='color:#808030; '>.</span>Dx_this_mul_exp_x_at_0<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>return</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
  <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
<!--Created using ToHtml.com on 2021-04-22 21:54:18 UTC -->

Q1: What time do I use left plus or right plus? Or I can choose either one that I prefer, and then write corresponding ComputeJacobian()?
left plus: out_T = exp(delta_T) * T
right plus: out_T = T * exp(delta_T)

Q2: Are the jacobians the same for right/left plus?

Q3: Is there any material about computing the jacobian of `T * exp(delta_T)` and `exp(delta_T) * T` ?





--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.

Alex Stewart

unread,
Apr 23, 2021, 3:19:32 PM4/23/21
to ceres-...@googlegroups.com
For Q2 no, they are not - Jose Blanco has a tech-report here that gives the forms for both left and right jacobians.

For Q3 yes, Ethan Eade has a tutorial here, Tim Barfoot's book is also a very good and thorough reference for this (and many other things).

Reply all
Reply to author
Forward
0 new messages