Created
September 13, 2018 22:55
-
-
Save pvazteixeira/df8ca6f71e6c2bdd1e64ba8e14f4d448 to your computer and use it in GitHub Desktop.
Pose3Pose3Offset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN: | |
""" | |
$(SIGNATURES) | |
A factor for sensor offset calibration, connecting three variable nodes: platform, sensor, and offset. The measurement should be centered around zero. | |
# Examples | |
```julia-repl | |
``` | |
""" | |
mutable struct Pose3Pose3Offset <: FunctorPairwise | |
diff::IIF.SamplableBelief | |
Pose3Pose3Offset = new() | |
Pose3Pose3Offset(z::SamplableBelief) = new(z) | |
end | |
# get samples from the factor | |
function getSample(f::Pose3Pose3Offset, N::Int=1)::Tuple{Array{Float64,2}} | |
y = rand(diff, N) | |
return (y,) | |
end | |
# compute the residual based on the current estimates | |
function( f::Pose3Pose3Offset)( | |
res::Vector{Float64}, | |
userdata::FactorMetadata, | |
idx::Int, | |
meas::Tuple{Array{Float64,2}}, | |
platform::Array{Float64,2}, | |
sensor::Array{Float64,2}, | |
offset::Array{Float64,2}) | |
# platform pose | |
wTp = compose(Translation(platform[1:3,idx]),RotXYZ(platform[4:6,idx])) | |
# sensor pose | |
wTs = compose(Translation(sensor[1:3,idx]),RotXYZ(sensor[4:6,idx])) | |
# offset | |
pTs = compose(Translation(offset[1:3,idx]),RotXYZ(offset[4:6,idx])) | |
# identity | |
pTp = compose(wTp,compose(inv(wTs),pTs)) | |
res = [pTp.translation; RotXYZ(pTp.linear)] | |
end |
FunctorPairwiseMinimize
requires you return one Float with the objective value
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FunctorPairwise
returns::Void
, so you want to do this instead: