My function is below, during compilation, it says:
invalid static_cast from type ‘const ceres::Jet<double, 3>’ to type ‘float’Because I'm using external function inside, and I have to convert to type float to keep consistent. Is therer a way to do that?template <typename T> bool operator()(const T* parameters, T* residuals) const { Eigen::Matrix<T, 3, 1> pose(parameters[0],parameters[1],parameters[2]); Eigen::Vector3f pose1 = pose.cast<float>(); Eigen::Affine2f transform = occ->getTransformForState(pose1); // transform: rotation->translation Eigen::Vector3f tmp1 = occ->interpMapValueWithDerivatives( transform * currPoint); Eigen::Matrix<T, 3, 1> transformedPointData(tmp1.cast<T>()); /// {M,dM/dx,dM/dy} T funVal = T(1) - transformedPointData[0]; residuals[0] = funVal; return true; }
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/6f7da7c3-1e09-47b1-a38f-bcb430e58f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Fundamentally, you cannot convert from Jet to Double without breaking your CostFunction (and your optimization), since that will discard the derivative information. You must use the adapter cost_function_to_functor.h functionality to do this.Take a look at include/ceres/cost_function_to_functor.h. You will have to provide the derivatives of the wrapped cost function. One approach is to use the NumericDiffCostFunction, then wrap that with a CostFunctionToFunctor.
On Fri, Dec 29, 2017 at 2:23 PM, <3658...@qq.com> wrote:
My function is below, during compilation, it says:invalid static_cast from type ‘const ceres::Jet<double, 3>’ to type ‘float’Because I'm using external function inside, and I have to convert to type float to keep consistent. Is therer a way to do that?template <typename T> bool operator()(const T* parameters, T* residuals) const { Eigen::Matrix<T, 3, 1> pose(parameters[0],parameters[1],parameters[2]); Eigen::Vector3f pose1 = pose.cast<float>(); Eigen::Affine2f transform = occ->getTransformForState(pose1); // transform: rotation->translation Eigen::Vector3f tmp1 = occ->interpMapValueWithDerivatives( transform * currPoint); Eigen::Matrix<T, 3, 1> transformedPointData(tmp1.cast<T>()); /// {M,dM/dx,dM/dy} T funVal = T(1) - transformedPointData[0]; residuals[0] = funVal; return true; }
--
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/CADpYijE5HJ%2BUbtsdOYbF%3DCX%3DtUjTEoE%3DoFYSpaGtyp5y3s99Hw%40mail.gmail.com.
Isn't another option to use template for everything? All the things in your cost function can be converted to an Eigen::Matrix<T,row,col>. If you do this conversion for each of the class members you use in your cost function, you will not need cost_function_to_functor.h (which makes things slower than autodiff).Albert Palomer Vila
2017-12-30 22:41 GMT+01:00 Keir Mierle <mie...@gmail.com>:
Fundamentally, you cannot convert from Jet to Double without breaking your CostFunction (and your optimization), since that will discard the derivative information. You must use the adapter cost_function_to_functor.h functionality to do this.Take a look at include/ceres/cost_function_to_functor.h. You will have to provide the derivatives of the wrapped cost function. One approach is to use the NumericDiffCostFunction, then wrap that with a CostFunctionToFunctor.
On Fri, Dec 29, 2017 at 2:23 PM, <3658...@qq.com> wrote:
My function is below, during compilation, it says:invalid static_cast from type ‘const ceres::Jet<double, 3>’ to type ‘float’Because I'm using external function inside, and I have to convert to type float to keep consistent. Is therer a way to do that?template <typename T> bool operator()(const T* parameters, T* residuals) const { Eigen::Matrix<T, 3, 1> pose(parameters[0],parameters[1],parameters[2]); Eigen::Vector3f pose1 = pose.cast<float>(); Eigen::Affine2f transform = occ->getTransformForState(pose1); // transform: rotation->translation Eigen::Vector3f tmp1 = occ->interpMapValueWithDerivatives( transform * currPoint); Eigen::Matrix<T, 3, 1> transformedPointData(tmp1.cast<T>()); /// {M,dM/dx,dM/dy} T funVal = T(1) - transformedPointData[0]; residuals[0] = funVal; return true; }
--
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/6f7da7c3-1e09-47b1-a38f-bcb430e58f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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/CADpYijE5HJ%2BUbtsdOYbF%3DCX%3DtUjTEoE%3DoFYSpaGtyp5y3s99Hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
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/CAD3_OrXvwL5JJvUN8zNA8E4xC%3DXUh%3DFNktWBd%3DUNzLOzLSPAdw%40mail.gmail.com.
Isn't another option to use template for everything? All the things in your cost function can be converted to an Eigen::Matrix<T,row,col>. If you do this conversion for each of the class members you use in your cost function, you will not need cost_function_to_functor.h (which makes things slower than autodiff).
Albert Palomer Vila
2017-12-30 22:41 GMT+01:00 Keir Mierle <mie...@gmail.com>:
Fundamentally, you cannot convert from Jet to Double without breaking your CostFunction (and your optimization), since that will discard the derivative information. You must use the adapter cost_function_to_functor.h functionality to do this.Take a look at include/ceres/cost_function_to_functor.h. You will have to provide the derivatives of the wrapped cost function. One approach is to use the NumericDiffCostFunction, then wrap that with a CostFunctionToFunctor.
On Fri, Dec 29, 2017 at 2:23 PM, <3658...@qq.com> wrote:
My function is below, during compilation, it says:invalid static_cast from type ‘const ceres::Jet<double, 3>’ to type ‘float’Because I'm using external function inside, and I have to convert to type float to keep consistent. Is therer a way to do that?template <typename T> bool operator()(const T* parameters, T* residuals) const { Eigen::Matrix<T, 3, 1> pose(parameters[0],parameters[1],parameters[2]); Eigen::Vector3f pose1 = pose.cast<float>(); Eigen::Affine2f transform = occ->getTransformForState(pose1); // transform: rotation->translation Eigen::Vector3f tmp1 = occ->interpMapValueWithDerivatives( transform * currPoint); Eigen::Matrix<T, 3, 1> transformedPointData(tmp1.cast<T>()); /// {M,dM/dx,dM/dy} T funVal = T(1) - transformedPointData[0]; residuals[0] = funVal; return true; }
--
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/6f7da7c3-1e09-47b1-a38f-bcb430e58f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
Isn't another option to use template for everything? All the things in your cost function can be converted to an Eigen::Matrix<T,row,col>. If you do this conversion for each of the class members you use in your cost function, you will not need cost_function_to_functor.h (which makes things slower than autodiff).
Albert Palomer Vila
2017-12-30 22:41 GMT+01:00 Keir Mierle <mie...@gmail.com>:
Fundamentally, you cannot convert from Jet to Double without breaking your CostFunction (and your optimization), since that will discard the derivative information. You must use the adapter cost_function_to_functor.h functionality to do this.Take a look at include/ceres/cost_function_to_functor.h. You will have to provide the derivatives of the wrapped cost function. One approach is to use the NumericDiffCostFunction, then wrap that with a CostFunctionToFunctor.
On Fri, Dec 29, 2017 at 2:23 PM, <3658...@qq.com> wrote:
My function is below, during compilation, it says:invalid static_cast from type ‘const ceres::Jet<double, 3>’ to type ‘float’Because I'm using external function inside, and I have to convert to type float to keep consistent. Is therer a way to do that?template <typename T> bool operator()(const T* parameters, T* residuals) const { Eigen::Matrix<T, 3, 1> pose(parameters[0],parameters[1],parameters[2]); Eigen::Vector3f pose1 = pose.cast<float>(); Eigen::Affine2f transform = occ->getTransformForState(pose1); // transform: rotation->translation Eigen::Vector3f tmp1 = occ->interpMapValueWithDerivatives( transform * currPoint); Eigen::Matrix<T, 3, 1> transformedPointData(tmp1.cast<T>()); /// {M,dM/dx,dM/dy} T funVal = T(1) - transformedPointData[0]; residuals[0] = funVal; return true; }
--
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/6f7da7c3-1e09-47b1-a38f-bcb430e58f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
Thanks for making it clear. I'm not sure if its possible to add this feature in the future because g2o doesnt need to consider such type conversion. But I believe ceres will be promising.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/3368cdd5-71ed-437b-bf11-f9efd587e3fd%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/cead520b-d651-4f18-9cfb-7cc5888d340a%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/71306284-7c70-40ec-bee9-c5014b4443f6%40googlegroups.com.