| 145 | } |
| 146 | |
| 147 | struct FourDOFError { |
| 148 | FourDOFError(double t_x, double t_y, double t_z, double relative_yaw, double pitch_i, double roll_i) |
| 149 | : t_x(t_x), t_y(t_y), t_z(t_z), relative_yaw(relative_yaw), pitch_i(pitch_i), roll_i(roll_i) {} |
| 150 | |
| 151 | template <typename T> |
| 152 | bool operator()(const T* const yaw_i, const T* ti, const T* yaw_j, const T* tj, T* residuals) const { |
| 153 | T t_w_ij[3]; |
| 154 | t_w_ij[0] = tj[0] - ti[0]; |
| 155 | t_w_ij[1] = tj[1] - ti[1]; |
| 156 | t_w_ij[2] = tj[2] - ti[2]; |
| 157 | |
| 158 | // euler to rotation |
| 159 | T w_R_i[9]; |
| 160 | YawPitchRollToRotationMatrix(yaw_i[0], T(pitch_i), T(roll_i), w_R_i); |
| 161 | // rotation transpose |
| 162 | T i_R_w[9]; |
| 163 | RotationMatrixTranspose(w_R_i, i_R_w); |
| 164 | // rotation matrix rotate point |
| 165 | T t_i_ij[3]; |
| 166 | RotationMatrixRotatePoint(i_R_w, t_w_ij, t_i_ij); |
| 167 | |
| 168 | residuals[0] = (t_i_ij[0] - T(t_x)); |
| 169 | residuals[1] = (t_i_ij[1] - T(t_y)); |
| 170 | residuals[2] = (t_i_ij[2] - T(t_z)); |
| 171 | residuals[3] = NormalizeAngle(yaw_j[0] - yaw_i[0] - T(relative_yaw)); |
| 172 | |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | static ceres::CostFunction* Create(const double t_x, |
| 177 | const double t_y, |
| 178 | const double t_z, |
| 179 | const double relative_yaw, |
| 180 | const double pitch_i, |
| 181 | const double roll_i) { |
| 182 | return (new ceres::AutoDiffCostFunction<FourDOFError, 4, 1, 3, 1, 3>( |
| 183 | new FourDOFError(t_x, t_y, t_z, relative_yaw, pitch_i, roll_i))); |
| 184 | } |
| 185 | |
| 186 | double t_x, t_y, t_z; |
| 187 | double relative_yaw, pitch_i, roll_i; |
| 188 | }; |
| 189 | |
| 190 | struct FourDOFWeightError { |
| 191 | FourDOFWeightError(double t_x, double t_y, double t_z, double relative_yaw, double pitch_i, double roll_i) |
nothing calls this directly
no outgoing calls
no test coverage detected