Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes multibody/constraint private within examples/rod2d #21445

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions doc/doxygen_cxx/doxygen.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ namespace solvers {
*/
} // namespace solvers

/**
@defgroup constraint_overview Multibody Dynamics Constraints
@ingroup multibody
*/

// TODO(russt): Take a thorough pass through the algorithms group
// documentation, adding brief descriptions of each and tagging the relevant
// algorithms throughout the code.
Expand Down
28 changes: 25 additions & 3 deletions examples/rod2d/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ load(

package(default_visibility = ["//visibility:private"])

drake_cc_library(
name = "constraint_solver",
srcs = ["constraint_solver.cc"],
hdrs = [
"constraint_problem_data.h",
"constraint_solver.h",
],
deps = [
"//common:essential",
"//solvers:moby_lcp_solver",
],
)

drake_cc_library(
name = "rod2d_state_vector",
srcs = ["rod2d_state_vector.cc"],
Expand Down Expand Up @@ -45,11 +58,10 @@ drake_cc_library(
hdrs = [
"rod2d.h",
],
visibility = ["//multibody/constraint:__pkg__"],
deps = [
":constraint_solver",
":rod2d_state_vector",
"//common:essential",
"//multibody/constraint",
"//solvers:mathematical_program",
"//systems/framework:leaf_system",
],
Expand Down Expand Up @@ -77,14 +89,24 @@ drake_cc_library(

# === test/ ===

drake_cc_googletest(
name = "constraint_solver_test",
deps = [
":constraint_solver",
":rod2d",
"//solvers:moby_lcp_solver",
"//solvers:unrevised_lemke_solver",
],
)

drake_cc_googletest(
name = "rod2d_test",
deps = [
":constraint_solver",
":rod2d",
"//common:essential",
"//common/test_utilities:eigen_matrix_compare",
"//common/test_utilities:expect_no_throw",
"//multibody/constraint",
"//systems/analysis:simulator",
],
)
Expand Down
287 changes: 146 additions & 141 deletions multibody/constraint/constraint_doxygen.h → examples/rod2d/README.md

Large diffs are not rendered by default.

515 changes: 515 additions & 0 deletions examples/rod2d/constraint_problem_data.h

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions examples/rod2d/constraint_solver.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "drake/examples/rod2d/constraint_solver.h"

namespace drake {
namespace multibody {
namespace constraint {

template class ConstraintSolver<double>;

} // namespace constraint
} // namespace multibody
} // namespace drake
2,557 changes: 2,557 additions & 0 deletions examples/rod2d/constraint_solver.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/rod2d/rod2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <utility>
#include <vector>

#include "drake/examples/rod2d/constraint_problem_data.h"
#include "drake/examples/rod2d/constraint_solver.h"
#include "drake/examples/rod2d/rod2d_state_vector.h"
#include "drake/multibody/constraint/constraint_problem_data.h"
#include "drake/multibody/constraint/constraint_solver.h"
#include "drake/solvers/moby_lcp_solver.h"
#include "drake/systems/framework/leaf_system.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "drake/multibody/constraint/constraint_solver.h"
#include "drake/examples/rod2d/constraint_solver.h"

#include <cmath>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions examples/rod2d/test/rod2d_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "drake/common/test_utilities/eigen_matrix_compare.h"
#include "drake/common/test_utilities/expect_no_throw.h"
#include "drake/multibody/constraint/constraint_problem_data.h"
#include "drake/multibody/constraint/constraint_solver.h"
#include "drake/examples/rod2d/constraint_problem_data.h"
#include "drake/examples/rod2d/constraint_solver.h"
#include "drake/systems/analysis/simulator.h"

using drake::multibody::constraint::ConstraintAccelProblemData;
Expand Down
14 changes: 0 additions & 14 deletions multibody/constraint/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
load("//tools/lint:lint.bzl", "add_lint_tests")
load(
"//tools/skylark:drake_cc.bzl",
"drake_cc_binary",
"drake_cc_googletest",
"drake_cc_library",
"drake_cc_package_library",
)
Expand Down Expand Up @@ -40,16 +38,4 @@ drake_cc_library(
],
)

# === test/ ===

drake_cc_googletest(
name = "constraint_solver_test",
deps = [
":constraint_solver",
"//examples/rod2d",
"//solvers:moby_lcp_solver",
"//solvers:unrevised_lemke_solver",
],
)

add_lint_tests(enable_clang_format_lint = False)
14 changes: 14 additions & 0 deletions multibody/constraint/constraint_problem_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

#include <Eigen/Core>

#include "drake/common/drake_deprecated.h"
#include "drake/common/eigen_types.h"

namespace drake {
namespace multibody {
namespace constraint {
namespace internal {

/// Structure for holding constraint data for computing forces due to
/// constraints and the resulting multibody accelerations.
Expand Down Expand Up @@ -510,6 +512,18 @@ struct ConstraintVelProblemData {
std::function<MatrixX<T>(const MatrixX<T>&)> solve_inertia;
};

} // namespace internal

template <class T>
using ConstraintAccelProblemData
DRAKE_DEPRECATED("2024-09-01", "This class is being removed from Drake.")
= internal::ConstraintAccelProblemData<T>;

template <class T>
using ConstraintVelProblemData
DRAKE_DEPRECATED("2024-09-01", "This class is being removed from Drake.")
= internal::ConstraintVelProblemData<T>;

} // namespace constraint
} // namespace multibody
} // namespace drake
2 changes: 2 additions & 0 deletions multibody/constraint/constraint_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace drake {
namespace multibody {
namespace constraint {
namespace internal {

template class ConstraintSolver<double>;

} // namespace internal
} // namespace constraint
} // namespace multibody
} // namespace drake
9 changes: 9 additions & 0 deletions multibody/constraint/constraint_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>
#include <vector>

#include "drake/common/drake_deprecated.h"
#include "drake/common/fmt_eigen.h"
#include "drake/common/text_logging.h"
#include "drake/multibody/constraint/constraint_problem_data.h"
Expand All @@ -15,6 +16,7 @@
namespace drake {
namespace multibody {
namespace constraint {
namespace internal {

/// Solves constraint problems for constraint forces. Specifically, given
/// problem data corresponding to a rigid or multi-body system constrained
Expand Down Expand Up @@ -2552,6 +2554,13 @@ void ConstraintSolver<T>::CalcContactForcesInContactFrames(
}
}

} // namespace internal

template <typename T>
using ConstraintSolver
DRAKE_DEPRECATED("2024-09-01", "This class is being removed from Drake.")
= internal::ConstraintSolver<T>;

} // namespace constraint
} // namespace multibody
} // namespace drake