Update CustomFactors.md to more clearly specify types required

release/4.3a0
Clark Taylor 2023-09-01 14:12:47 -04:00 committed by GitHub
parent 98d1ceedc6
commit 3d6e2fc81c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import gtsam
import numpy as np import numpy as np
from typing import List from typing import List
def error_func(this: gtsam.CustomFactor, v: gtsam.Values, H: List[np.ndarray]): def error_func(this: gtsam.CustomFactor, v: gtsam.Values, H: List[np.ndarray]) -> np.ndarray:
... ...
``` ```
@ -21,7 +21,7 @@ def error_func(this: gtsam.CustomFactor, v: gtsam.Values, H: List[np.ndarray]):
If `H` is `None`, it means the current factor evaluation does not need Jacobians. For example, the `error` If `H` is `None`, it means the current factor evaluation does not need Jacobians. For example, the `error`
method on a factor does not need Jacobians, so we don't evaluate them to save CPU. If `H` is not `None`, method on a factor does not need Jacobians, so we don't evaluate them to save CPU. If `H` is not `None`,
each entry of `H` can be assigned a `numpy` array, as the Jacobian for the corresponding variable. each entry of `H` can be assigned a (2D) `numpy` array, as the Jacobian for the corresponding variable.
After defining `error_func`, one can create a `CustomFactor` just like any other factor in GTSAM: After defining `error_func`, one can create a `CustomFactor` just like any other factor in GTSAM:
@ -42,7 +42,7 @@ from typing import List
expected = Pose2(2, 2, np.pi / 2) expected = Pose2(2, 2, np.pi / 2)
def error_func(this: CustomFactor, v: gtsam.Values, H: List[np.ndarray]): def error_func(this: CustomFactor, v: gtsam.Values, H: List[np.ndarray]) -> np.ndarray:
""" """
Error function that mimics a BetweenFactor Error function that mimics a BetweenFactor
:param this: reference to the current CustomFactor being evaluated :param this: reference to the current CustomFactor being evaluated