forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrick_static_equilibrium_constraint.h
72 lines (63 loc) · 2.84 KB
/
brick_static_equilibrium_constraint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <utility>
#include <vector>
#include "drake/examples/planar_gripper/gripper_brick.h"
#include "drake/multibody/plant/multibody_plant.h"
#include "drake/solvers/constraint.h"
#include "drake/solvers/mathematical_program.h"
namespace drake {
namespace examples {
namespace planar_gripper {
/** Given the set of contacts between the fingertips and the brick, impose the
* static equilibrium as a nonlinear constraint, that the total force/torque
* applied on the brick is 0. The decision variables are (q, f_Cb_B) where q is
* the generalized position, and f_Cb_B are the contact force (y, z) component
* applied to the point Cb on the brick, expressed in the brick frame B.
* The constraint are
*
* 0 = R_BW * m * g_W + ∑ᵢ f_Cbi_B
* 0 = ∑ᵢp_Cbi_B.cross(f_Cbi_B)
* Notice that since the gripper/brick system is planar, the first equation is
* only on the (y, z) component of the total force, and the second equation is
* only on the x component of the torque.
*
* The constraint evaluates the right-hand side of the two equations above.
*/
class BrickStaticEquilibriumNonlinearConstraint : public solvers::Constraint {
public:
BrickStaticEquilibriumNonlinearConstraint(
const GripperBrickHelper<double>& gripper_brick_system,
std::vector<std::pair<Finger, BrickFace>> finger_face_contacts,
systems::Context<double>* plant_mutable_context);
private:
template<typename T>
void DoEvalGeneric(const Eigen::Ref<const VectorX<T>> &x,
VectorX<T> *y) const;
void DoEval(const Eigen::Ref<const Eigen::VectorXd> &x,
Eigen::VectorXd *y) const;
void DoEval(const Eigen::Ref<const AutoDiffVecXd> &x, AutoDiffVecXd *y) const;
void DoEval(const Eigen::Ref<const VectorX<symbolic::Variable>> &,
VectorX<symbolic::Expression> *) const;
const GripperBrickHelper<double>& gripper_brick_system_;
double brick_mass_;
std::vector<std::pair<Finger, BrickFace>> finger_face_contacts_;
systems::Context<double> *plant_mutable_context_;
};
/**
* Given the assignment of contacts between fingers and faces, add the following
* constraints/variables to the program:
* 1. Decision variables representing the finger contact force on the brick,
* expressed in the brick frame.
* 2. The static equilibrium constraint ensuring that the total wrench on the
* brick is 0.
* 3. The constraint that the contact force is within a friction cone.
*/
Matrix2X<symbolic::Variable> AddBrickStaticEquilibriumConstraint(
const GripperBrickHelper<double>& gripper_brick_system,
const std::vector<std::pair<Finger, BrickFace>>& finger_face_contacts,
const Eigen::Ref<const VectorX<symbolic::Variable>>& q_vars,
systems::Context<double>* plant_mutable_context,
solvers::MathematicalProgram* prog);
} // namespace planar_gripper
} // namespace examples
} // namespace drake