Generic factors API
I'm currently working with FactorRelative2d
and FactorRelative2dWithExtrinsics
and the derived factor FactorLoopclosure2d
(in this laser issue).
I realized that the API is not exactly the same.
FactorRelativePose2dWithExtrinsics(const FeatureBasePtr& _ftr_ptr,
const FrameBasePtr& _frame_other_ptr,
const ProcessorBasePtr& _processor_ptr,
bool _apply_loss_function,
FactorStatus _status = FAC_ACTIVE)
FactorRelativePose2d(const std::string& _tp,
const FeatureBasePtr& _ftr_ptr,
const FrameBasePtr& _frame_other_ptr,
const ProcessorBasePtr& _processor_ptr,
bool _apply_loss_function,
FactorStatus _status = FAC_ACTIVE)
The second one allows derived factors to specify the type of the factor while the first doesn't. Also, there is the getTopology()
function that is implemented in both factors (the first one returns "MOTION" and the second one "GEOM").
I think that both factors should be able to be used directly (without need of deriving them in a specific factor) and also deriving them. I think this would require:
- 2 constructors, with and without the input string
_tp
. - Both constructors should have an input string for the topology (maybe with a default value "GEOM", just before the
_status
).
FactorRelativePose2dWithExtrinsics(const FeatureBasePtr& _ftr_ptr,
const FrameBasePtr& _frame_other_ptr,
const ProcessorBasePtr& _processor_ptr,
bool _apply_loss_function,
const std::string& _topo = "GEOM",
FactorStatus _status = FAC_ACTIVE) :
FactorRelativePose2dWithExtrinsics("FactorRelativePose2dWithExtrinsics",
_ftr_ptr,
_frame_other_ptr,
_processor_ptr,
_apply_loss_function,
_topo, status)
{
}
FactorRelativePose2dWithExtrinsics(const std::string& _tp,
const FeatureBasePtr& _ftr_ptr,
const FrameBasePtr& _frame_other_ptr,
const ProcessorBasePtr& _processor_ptr,
bool _apply_loss_function,
const std::string& _topo = "GEOM",
FactorStatus _status = FAC_ACTIVE){/* whatever */}
And the analogous for FactorRelativePose2d
.