1 #include <gtest/gtest.h> 31 joint_rotzyx =
Joint(
SpatialVector(0., 0., 1., 0., 0., 0.),
SpatialVector(0., 1., 0., 0., 0., 0.),
SpatialVector(1., 0., 0., 0., 0., 0.));
32 base_id = model->addBody(0,
Xtrans(
Vector3d(0., 0., 0.)), joint_rotzyx, base);
36 child_id = model->addBody(base_id,
Xtrans(
Vector3d(1., 0., 0.)), joint_rotzyx, child);
38 Q = VectorNd::Zero(model->dof_count);
39 QDot = VectorNd::Zero(model->dof_count);
40 QDDot = VectorNd::Zero(model->dof_count);
41 Tau = VectorNd::Zero(model->dof_count);
43 contact_body_id = child_id;
44 contact_point =
Vector3d(0., 1., 0.);
45 contact_normal =
Vector3d(0., 1., 0.);
72 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(1., 0., 0.), NULL, 0.);
73 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.), NULL, 0.);
74 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 0., 1.), NULL, 0.);
76 constraint_set.bind(*model);
78 constraint_set.v_plus[0] = 0.;
79 constraint_set.v_plus[1] = 0.;
80 constraint_set.v_plus[2] = 0.;
92 point_velocity =
calcPointVelocity(*model,
Q, qdot_post, contact_body_id, contact_point,
true);
100 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(1., 0., 0.), NULL, 0.);
101 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.), NULL, 0.);
102 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 0., 1.), NULL, 0.);
104 constraint_set.bind(*model);
106 constraint_set.v_plus[0] = 0.;
107 constraint_set.v_plus[1] = 0.;
108 constraint_set.v_plus[2] = 0.;
127 point_velocity =
calcPointVelocity(*model,
Q, qdot_post, contact_body_id, contact_point,
true);
134 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(1., 0., 0.), NULL, 1.);
135 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.), NULL, 2.);
136 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 0., 1.), NULL, 3.);
138 constraint_set.bind(*model);
140 constraint_set.v_plus[0] = 1.;
141 constraint_set.v_plus[1] = 2.;
142 constraint_set.v_plus[2] = 3.;
161 point_velocity =
calcPointVelocity(*model,
Q, qdot_post, contact_body_id, contact_point,
true);
179 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(1., 0., 0.), NULL, 1.);
180 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.), NULL, 2.);
181 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 0., 1.), NULL, 3.);
183 constraint_set.bind(*model);
185 constraint_set.v_plus[0] = 1.;
186 constraint_set.v_plus[1] = 2.;
187 constraint_set.v_plus[2] = 3.;
190 constraint_set_rangespace = constraint_set.
Copy();
191 constraint_set_rangespace.
bind(*model);
199 Vector3d point_velocity_rangespace =
calcPointVelocity(*model,
Q, qdot_post_rangespace, contact_body_id, contact_point,
true);
221 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(1., 0., 0.), NULL, 1.);
222 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 1., 0.), NULL, 2.);
223 constraint_set.addConstraint(contact_body_id, contact_point,
Vector3d(0., 0., 1.), NULL, 3.);
225 constraint_set.bind(*model);
227 constraint_set.v_plus[0] = 1.;
228 constraint_set.v_plus[1] = 2.;
229 constraint_set.v_plus[2] = 3.;
232 constraint_set_nullspace = constraint_set.
Copy();
233 constraint_set_nullspace.
bind(*model);
250 int main(
int argc,
char** argv)
252 ::testing::InitGoogleTest(&argc, argv);
253 return RUN_ALL_TESTS();
static bool checkVectorNdEpsilonClose(const RobotDynamics::Math::VectorNd &v1, const RobotDynamics::Math::VectorNd &v2, const double epsilon)
TEST_F(RdlImpulsesFixture, TestContactImpulse)
Describes all properties of a single body.
ConstraintSet Copy()
Copies the constraints and resets its ConstraintSet::bound flag.
SpatialTransform Xtrans(const Vector3d &r)
Get pure translation transform.
Math::MotionVector gravity
the cartesian vector of the gravity
Math::FrameVector calcPointVelocity(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics=true)
Computes the velocity of a point on a body.
unsigned int contact_body_id
Structure that contains both constraint information and workspace memory.
Describes a joint relative to the predecessor body.
ConstraintSet constraint_set
int main(int argc, char **argv)
Contains all information about the rigid body model.
bool bind(const Model &model)
Initializes and allocates memory for the constraint set.
Math types such as vectors and matrices and utility functions.
static bool checkVector3dEpsilonClose(const RobotDynamics::Math::Vector3d &v1, const RobotDynamics::Math::Vector3d &v2, const double epsilon)
Namespace for all structures of the RobotDynamics library.