5 #include "gtest/gtest.h" 64 FramePoint p(model->bodyFrames[model->mBodyNameMap[
"body_c"]], 0., 0., -3.);
65 FramePoint p_com(model->bodyCenteredFrames[model->mBodyNameMap[
"body_c"]], 0., 0., 0.);
67 Vector3d expected_c_com = 1 / (2 * fixed_body.mMass + body_c.mMass) *
68 ((fixed_body.mCenterOfMass + X_fixed_c.r) * fixed_body.mMass + (X_fixed_c.r + X_fixed_c2.r + fixed_body.mCenterOfMass) * fixed_body.mMass +
69 body_c.mCenterOfMass * body_c.mMass);
76 FramePoint p_com_point(model->bodyFrames[model->mBodyNameMap[
"body_c"]], expected_c_com);
83 p.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_b"]]);
87 p.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_c"]]);
91 p_com.
changeFrame(model->bodyCenteredFrames[model->mBodyNameMap[
"body_c"]]);
95 double j1Angle = M_PI_2;
96 double j2Angle = -M_PI_2;
111 p_com_point.
setIncludingFrame(expected_c_com, model->bodyFrames[model->mBodyNameMap[
"body_c"]]);
134 p.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_b"]]);
138 p.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_c"]]);
142 p.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_a"]]);
146 FramePoint p2(model->bodyFrames[model->mBodyNameMap[
"body_c"]], 1., 1., 1.);
154 EXPECT_STREQ(e.
what(),
"Reference frames do not match!");
157 EXPECT_STREQ(model->getReferenceFrame(
"body_a")->getName().c_str(),
"body_a");
158 EXPECT_STREQ(model->getReferenceFrame(
"body_b")->getName().c_str(),
"body_b");
159 EXPECT_STREQ(model->getReferenceFrame(
"body_c")->getName().c_str(),
"body_c");
160 EXPECT_FALSE(model->getReferenceFrame(
"body_d"));
177 FramePoint pFixedFrameOrigin(model->fixedBodyFrames[0], 0., 0., 0.);
178 FramePoint pFixedFrameOrigin_2(model->fixedBodyFrames[1], 0., 0., 0.);
186 double j1Angle = M_PI_2;
187 double j2Angle = -M_PI_2;
229 FramePoint pFixedFrameOrigin(model->fixedBodyFrames[0], 0., 0., 0.);
230 FramePoint pFixedFrameOrigin_2(model->fixedBodyFrames[1], 0., 0., 0.);
238 double j1Angle = M_PI_2;
239 double j2Angle = -M_PI_2;
407 FramePoint p1_end_effector(model->bodyFrames[model->mBodyNameMap[
"body_1"]], 0., 0., -1.);
408 FramePoint p2_end_effector(model->bodyFrames[model->mBodyNameMap[
"body_2"]], 0., 0., 1.);
409 FramePoint root_origin(model->bodyFrames[model->mBodyNameMap[
"floating_body"]], 0., 0., 0.);
413 p2_end_effector.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_1"]]);
414 root_origin.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"body_2"]]);
426 world_origin.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"floating_body"]]);
448 world_origin.
changeFrame(model->bodyFrames[model->mBodyNameMap[
"floating_body"]]);
455 EXPECT_TRUE(model_fixed->bodyCenteredFrames[1]->getTransformToParent().r[0] == -1.);
456 EXPECT_TRUE(model_fixed->bodyCenteredFrames[1]->getTransformToParent().r[1] == -0.5);
457 EXPECT_TRUE(model_fixed->bodyCenteredFrames[1]->getTransformToParent().r[2] == 0.);
476 int main(
int argc,
char** argv)
478 ::testing::InitGoogleTest(&argc, argv);
479 return RUN_ALL_TESTS();
File containing the FramePoint<T> object definition.
A FramePoint is a 3D point that is expressed in a ReferenceFrame. To change the ReferenceFrame a Fram...
Describes all properties of a single body.
A custom exception for frame operations.
Matrix3d Matrix3dIdentity
SpatialTransform Xroty(const double &yrot)
Get transform with zero translation and pure rotation about y axis.
Fixture that contains two models of which one has one joint fixed.
SpatialTransform Xtrans(const Vector3d &r)
Get pure translation transform.
Fixed joint which causes the inertial properties to be merged with.
TEST_F(FixedBase3DoFPlanar, testPlanar3LinkPendulum)
static ReferenceFramePtr getWorldFrame()
Get a pointer to the world frame.
unsigned int appendBody(const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Adds a Body to the model such that the previously added Body is the Parent.
virtual const char * what() const
unsigned int addBody(const unsigned int parent_id, const Math::SpatialTransform &joint_frame, const Joint &joint, const Body &body, std::string body_name="")
Connects a given body to the model.
SpatialTransform Xrotz(const double &zrot)
Get transform with zero translation and pure rotation about z axis.
EIGEN_STRONG_INLINE void setIncludingFrame(const Math::Vector3d &v, ReferenceFramePtr referenceFrame)
Set both the ReferenceFrame this object is expressed in as well as the (x,y,z) coordinates of the poi...
EIGEN_STRONG_INLINE Math::Vector3d vec() const
virtual void changeFrame(ReferenceFramePtr desiredFrame)
Change the ReferenceFrame this FrameObject is expressed in.
A FrameVector is a 3D vector with a ReferenceFrame, and all operations between FrameVectors and other...
Describes a joint relative to the predecessor body.
SpatialTransform Xrotx(const double &xrot)
Get transform with zero translation and pure rotation about x axis.
void updateKinematics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot)
Updates and computes velocities and accelerations of the bodies.
std::map< std::string, ReferenceFramePtr > referenceFrameMap
Contains all information about the rigid body model.
void updateKinematicsCustom(Model &model, const Math::VectorNd *Q, const Math::VectorNd *QDot=nullptr, const Math::VectorNd *QDDot=nullptr)
Selectively updates model internal states of body positions, velocities and/or accelerations.
int main(int argc, char **argv)
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)
void inverseDynamics(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot, Math::VectorNd &Tau, Math::SpatialForceV *f_ext=nullptr, bool update_kinematics=true)
Namespace for all structures of the RobotDynamics library.
static bool checkMatrix3dEpsilonClose(const RobotDynamics::Math::Matrix3d &t1, const RobotDynamics::Math::Matrix3d &t2, const double epsilon)