Skip to content

Commit 286a0ee

Browse files
cdtwiggfacebook-github-bot
authored andcommitted
VertexVertexDistanceErrorFunction. (#577)
Summary: Pull Request resolved: #577 We want to be able to pin certain vertices to be a specific distance apart. This has some similarities to the PointTriangleVertexErrorFunction since it is a mesh-mesh distance, but should work better for long distances. Recall that the point-triangle error function defines a local space using the triangle plane and normal, and the target point is rigidly attached in this space. This works well when you are close to the triangle, but as you get far away from the triangle you end up with a very large moment arm torquing the triangle (basically the error function may "prefer" to rotate the triangle rather than actually changing the distance). For this reason it makes sense to have a much simpler point-to-point error that just acts on vertices, it won't be able to constrain the location rigidly in the same way (since there is no rigid frame defined on an individual vertex) but it should be numerically well-behaved. Reviewed By: jeongseok-meta Differential Revision: D82848960 fbshipit-source-id: 723f84b58fa365ee269f793033ff4081bb0f8bd1
1 parent a56d07a commit 286a0ee

File tree

6 files changed

+786
-26
lines changed

6 files changed

+786
-26
lines changed

cmake/build_variables.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ character_solver_public_headers = [
227227
"character_solver/normal_error_function.h",
228228
"character_solver/orientation_error_function.h",
229229
"character_solver/plane_error_function.h",
230+
"character_solver/point_triangle_vertex_error_function.h",
230231
"character_solver/pose_prior_error_function.h",
231232
"character_solver/position_error_function.h",
232233
"character_solver/projection_error_function.h",
@@ -240,7 +241,7 @@ character_solver_public_headers = [
240241
"character_solver/trust_region_qr.h",
241242
"character_solver/vertex_error_function.h",
242243
"character_solver/vertex_projection_error_function.h",
243-
"character_solver/point_triangle_vertex_error_function.h",
244+
"character_solver/vertex_vertex_distance_error_function.h",
244245
]
245246

246247
character_solver_sources = [
@@ -255,6 +256,7 @@ character_solver_sources = [
255256
"character_solver/normal_error_function.cpp",
256257
"character_solver/orientation_error_function.cpp",
257258
"character_solver/plane_error_function.cpp",
259+
"character_solver/point_triangle_vertex_error_function.cpp",
258260
"character_solver/pose_prior_error_function.cpp",
259261
"character_solver/position_error_function.cpp",
260262
"character_solver/projection_error_function.cpp",
@@ -267,7 +269,7 @@ character_solver_sources = [
267269
"character_solver/trust_region_qr.cpp",
268270
"character_solver/vertex_error_function.cpp",
269271
"character_solver/vertex_projection_error_function.cpp",
270-
"character_solver/point_triangle_vertex_error_function.cpp",
272+
"character_solver/vertex_vertex_distance_error_function.cpp",
271273
]
272274

273275
character_solver_test_sources = [

momentum/character_solver/fwd.h

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,31 @@ using PlaneErrorFunctiond_const_p = ::std::shared_ptr<const PlaneErrorFunctiond>
608608
using PlaneErrorFunctiond_const_u = ::std::unique_ptr<const PlaneErrorFunctiond>;
609609
using PlaneErrorFunctiond_const_w = ::std::weak_ptr<const PlaneErrorFunctiond>;
610610

611+
template <typename T>
612+
class PointTriangleVertexErrorFunctionT;
613+
using PointTriangleVertexErrorFunction = PointTriangleVertexErrorFunctionT<float>;
614+
using PointTriangleVertexErrorFunctiond = PointTriangleVertexErrorFunctionT<double>;
615+
616+
using PointTriangleVertexErrorFunction_p = ::std::shared_ptr<PointTriangleVertexErrorFunction>;
617+
using PointTriangleVertexErrorFunction_u = ::std::unique_ptr<PointTriangleVertexErrorFunction>;
618+
using PointTriangleVertexErrorFunction_w = ::std::weak_ptr<PointTriangleVertexErrorFunction>;
619+
using PointTriangleVertexErrorFunction_const_p =
620+
::std::shared_ptr<const PointTriangleVertexErrorFunction>;
621+
using PointTriangleVertexErrorFunction_const_u =
622+
::std::unique_ptr<const PointTriangleVertexErrorFunction>;
623+
using PointTriangleVertexErrorFunction_const_w =
624+
::std::weak_ptr<const PointTriangleVertexErrorFunction>;
625+
626+
using PointTriangleVertexErrorFunctiond_p = ::std::shared_ptr<PointTriangleVertexErrorFunctiond>;
627+
using PointTriangleVertexErrorFunctiond_u = ::std::unique_ptr<PointTriangleVertexErrorFunctiond>;
628+
using PointTriangleVertexErrorFunctiond_w = ::std::weak_ptr<PointTriangleVertexErrorFunctiond>;
629+
using PointTriangleVertexErrorFunctiond_const_p =
630+
::std::shared_ptr<const PointTriangleVertexErrorFunctiond>;
631+
using PointTriangleVertexErrorFunctiond_const_u =
632+
::std::unique_ptr<const PointTriangleVertexErrorFunctiond>;
633+
using PointTriangleVertexErrorFunctiond_const_w =
634+
::std::weak_ptr<const PointTriangleVertexErrorFunctiond>;
635+
611636
template <typename T>
612637
class PosePriorErrorFunctionT;
613638
using PosePriorErrorFunction = PosePriorErrorFunctionT<float>;
@@ -872,28 +897,28 @@ using VertexProjectionErrorFunctiond_const_w =
872897
::std::weak_ptr<const VertexProjectionErrorFunctiond>;
873898

874899
template <typename T>
875-
class PointTriangleVertexErrorFunctionT;
876-
using PointTriangleVertexErrorFunction = PointTriangleVertexErrorFunctionT<float>;
877-
using PointTriangleVertexErrorFunctiond = PointTriangleVertexErrorFunctionT<double>;
878-
879-
using PointTriangleVertexErrorFunction_p = ::std::shared_ptr<PointTriangleVertexErrorFunction>;
880-
using PointTriangleVertexErrorFunction_u = ::std::unique_ptr<PointTriangleVertexErrorFunction>;
881-
using PointTriangleVertexErrorFunction_w = ::std::weak_ptr<PointTriangleVertexErrorFunction>;
882-
using PointTriangleVertexErrorFunction_const_p =
883-
::std::shared_ptr<const PointTriangleVertexErrorFunction>;
884-
using PointTriangleVertexErrorFunction_const_u =
885-
::std::unique_ptr<const PointTriangleVertexErrorFunction>;
886-
using PointTriangleVertexErrorFunction_const_w =
887-
::std::weak_ptr<const PointTriangleVertexErrorFunction>;
888-
889-
using PointTriangleVertexErrorFunctiond_p = ::std::shared_ptr<PointTriangleVertexErrorFunctiond>;
890-
using PointTriangleVertexErrorFunctiond_u = ::std::unique_ptr<PointTriangleVertexErrorFunctiond>;
891-
using PointTriangleVertexErrorFunctiond_w = ::std::weak_ptr<PointTriangleVertexErrorFunctiond>;
892-
using PointTriangleVertexErrorFunctiond_const_p =
893-
::std::shared_ptr<const PointTriangleVertexErrorFunctiond>;
894-
using PointTriangleVertexErrorFunctiond_const_u =
895-
::std::unique_ptr<const PointTriangleVertexErrorFunctiond>;
896-
using PointTriangleVertexErrorFunctiond_const_w =
897-
::std::weak_ptr<const PointTriangleVertexErrorFunctiond>;
900+
class VertexVertexDistanceErrorFunctionT;
901+
using VertexVertexDistanceErrorFunction = VertexVertexDistanceErrorFunctionT<float>;
902+
using VertexVertexDistanceErrorFunctiond = VertexVertexDistanceErrorFunctionT<double>;
903+
904+
using VertexVertexDistanceErrorFunction_p = ::std::shared_ptr<VertexVertexDistanceErrorFunction>;
905+
using VertexVertexDistanceErrorFunction_u = ::std::unique_ptr<VertexVertexDistanceErrorFunction>;
906+
using VertexVertexDistanceErrorFunction_w = ::std::weak_ptr<VertexVertexDistanceErrorFunction>;
907+
using VertexVertexDistanceErrorFunction_const_p =
908+
::std::shared_ptr<const VertexVertexDistanceErrorFunction>;
909+
using VertexVertexDistanceErrorFunction_const_u =
910+
::std::unique_ptr<const VertexVertexDistanceErrorFunction>;
911+
using VertexVertexDistanceErrorFunction_const_w =
912+
::std::weak_ptr<const VertexVertexDistanceErrorFunction>;
913+
914+
using VertexVertexDistanceErrorFunctiond_p = ::std::shared_ptr<VertexVertexDistanceErrorFunctiond>;
915+
using VertexVertexDistanceErrorFunctiond_u = ::std::unique_ptr<VertexVertexDistanceErrorFunctiond>;
916+
using VertexVertexDistanceErrorFunctiond_w = ::std::weak_ptr<VertexVertexDistanceErrorFunctiond>;
917+
using VertexVertexDistanceErrorFunctiond_const_p =
918+
::std::shared_ptr<const VertexVertexDistanceErrorFunctiond>;
919+
using VertexVertexDistanceErrorFunctiond_const_u =
920+
::std::unique_ptr<const VertexVertexDistanceErrorFunctiond>;
921+
using VertexVertexDistanceErrorFunctiond_const_w =
922+
::std::weak_ptr<const VertexVertexDistanceErrorFunctiond>;
898923

899924
} // namespace momentum

0 commit comments

Comments
 (0)