本文整理汇总了C++中Vector6d::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector6d::transpose方法的具体用法?C++ Vector6d::transpose怎么用?C++ Vector6d::transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector6d
的用法示例。
在下文中一共展示了Vector6d::transpose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeTorques
/* ******************************************************************************************** */
void computeTorques (const Vector6d& state, double& ul, double& ur) {
// Set reference based on the mode
Vector6d refState;
if(locoMode == 1 || locoMode == 2) refState << 0.0, 0.0, state0(2), 0.0, state0(4), 0.0;
else {
ul = ur = 0.0;
return;
}
// Set the gains
Vector6d K;
if(locoMode == 1) K = K_stand;
else if(locoMode == 2) K = K_bal;
else assert(false);
if(dbg) cout << "K: " << K.transpose() << endl;
// Compute the error
Vector6d error = state - refState;
if(dbg) cout << "error: " << error.transpose() << endl;
// Compute the forward and spin torques
double u_x = K(2)*error(2) + K(3)*error(3);
double u_spin = K.bottomLeftCorner<2,1>().dot(error.bottomLeftCorner<2,1>());
double u_theta = K.topLeftCorner<2,1>().dot(error.topLeftCorner<2,1>());
// Limit the output torques
if(dbg) printf("u_theta: %lf, u_x: %lf, u_spin: %lf\n", u_theta, u_x, u_spin);
u_spin = max(-10.0, min(10.0, u_spin));
ul = u_theta + u_x + u_spin;
ur = u_theta + u_x - u_spin;
ul = max(-50.0, min(50.0, ul));
ur = max(-50.0, min(50.0, ur));
}
示例2: run
/// The main loop
void run() {
// start some timers
Vector6d state;
size_t c_ = 0;
struct timespec t_now, t_prev = aa_tm_now();
int lastLocoMode = locoMode;
while(!somatic_sig_received) {
pthread_mutex_lock(&mutex);
dbg = (c_++ % 20 == 0);
if(dbg) cout << "\nmode: " << locoMode << endl;
// Update times
t_now = aa_tm_now();
double dt = (double)aa_tm_timespec2sec(aa_tm_sub(t_now, t_prev));
t_prev = t_now;
if(dbg) cout << "dt: " << dt << endl;
// Get the locomotion state
getState(state, dt);
if(dbg) cout << "state: " << state.transpose() << endl;
// Check if the arm has reached the goal position or if the body is moving
bool armReached = (fabs(hw->arms[LEFT]->pos[0] - (-1.8)) < 0.05);
bool baseMoved = (hw->imu > -1.8);
if(dbg) cout << "armReached: " << armReached << ", baseMoved: " << baseMoved << endl;
if((armReached || baseMoved) && (locoMode == 0)) {
locoMode = 1;
state0 = state;
}
if(dbg) cout << "state0: " << state0.transpose() << endl;
// Switch the mode if necessary
switchModes(state);
// Compute the torques based on the state and the mode
double ul, ur;
computeTorques(state, ul, ur);
// Apply the torque
double input [2] = {ul, ur};
if(dbg) cout << "start: " << start << "\nu: {" << ul << ", " << ur << "}" << endl;
if(!start) input[0] = input[1] = 0.0;
// somatic_motor_cmd(&daemon_cx, hw->amc, SOMATIC__MOTOR_PARAM__MOTOR_CURRENT, input, 2, NULL);
// Update the locomotion mode
lastLocoMode = locoMode;
pthread_mutex_unlock(&mutex);
}
}
示例3: readGains
/// Read file for gains
void readGains () {
// Get the gains
Vector6d* kgains [] = {&K_stand, &K_bal};
ifstream file ("/home/cerdogan/Documents/Software/project/krang/iser/data/gains-03.txt");
assert(file.is_open());
char line [1024];
for(size_t k_idx = 0; k_idx < 2; k_idx++) {
*kgains[k_idx] = Vector6d::Zero();
file.getline(line, 1024);
std::stringstream stream(line, std::stringstream::in);
size_t i = 0;
double newDouble;
while ((i < 6) && (stream >> newDouble)) (*kgains[k_idx])(i++) = newDouble;
}
cout << "K_stand: " << K_stand.transpose() << endl;
cout << "K_bal: " << K_bal.transpose() << endl;
file.close();
}
示例4: motionSubspaceDotTimesV
void RollPitchYawFloatingJoint::motionSubspaceDotTimesV(const Eigen::Ref<const VectorXd>& q, const Eigen::Ref<const VectorXd>& v,
Vector6d& motion_subspace_dot_times_v,
Gradient<Vector6d, Eigen::Dynamic>::type* dmotion_subspace_dot_times_vdq,
Gradient<Vector6d, Eigen::Dynamic>::type* dmotion_subspace_dot_times_vdv) const
{
motion_subspace_dot_times_v.resize(TWIST_SIZE, 1);
auto rpy = q.middleRows<RPY_SIZE>(SPACE_DIMENSION);
double roll = rpy(0);
double pitch = rpy(1);
double yaw = rpy(2);
auto pd = v.middleRows<SPACE_DIMENSION>(0);
double xd = pd(0);
double yd = pd(1);
double zd = pd(2);
auto rpyd = v.middleRows<RPY_SIZE>(SPACE_DIMENSION);
double rolld = rpyd(0);
double pitchd = rpyd(1);
double yawd = rpyd(2);
using namespace std;
double cr = cos(roll);
double sr = sin(roll);
double cp = cos(pitch);
double sp = sin(pitch);
double cy = cos(yaw);
double sy = sin(yaw);
motion_subspace_dot_times_v.transpose() << -pitchd * yawd * cp, rolld * yawd * cp * cr - pitchd * yawd * sp * sr - pitchd * rolld * sr, -pitchd * rolld * cr - pitchd * yawd * cr * sp - rolld * yawd * cp * sr, yd * (yawd * cp * cy - pitchd * sp * sy) - xd * (pitchd * cy * sp + yawd * cp * sy)
- pitchd * zd * cp, zd * (rolld * cp * cr - pitchd * sp * sr) + xd * (rolld * (sr * sy + cr * cy * sp) - yawd * (cr * cy + sp * sr * sy) + pitchd * cp * cy * sr) - yd * (rolld * (cy * sr - cr * sp * sy) + yawd * (cr * sy - cy * sp * sr) - pitchd * cp * sr * sy), xd
* (rolld * (cr * sy - cy * sp * sr) + yawd * (cy * sr - cr * sp * sy) + pitchd * cp * cr * cy) - zd * (pitchd * cr * sp + rolld * cp * sr) + yd * (yawd * (sr * sy + cr * cy * sp) - rolld * (cr * cy + sp * sr * sy) + pitchd * cp * cr * sy);
if (dmotion_subspace_dot_times_vdq) {
dmotion_subspace_dot_times_vdq->resize(motion_subspace_dot_times_v.rows(), getNumPositions());
dmotion_subspace_dot_times_vdq->transpose() << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -pitchd * rolld * cr - pitchd * yawd * cr * sp - rolld * yawd * cp * sr, pitchd * rolld * sr + pitchd * yawd * sp * sr - rolld * yawd * cp * cr, 0.0, xd
* (rolld * (cr * sy - cy * sp * sr) + yawd * (cy * sr - cr * sp * sy) + pitchd * cp * cr * cy) - zd * (pitchd * cr * sp + rolld * cp * sr) + yd * (-rolld * (cr * cy + sp * sr * sy) + yawd * (sr * sy + cr * cy * sp) + pitchd * cp * cr * sy), -zd * (rolld * cp * cr - pitchd * sp * sr)
- xd * (rolld * (sr * sy + cr * cy * sp) - yawd * (cr * cy + sp * sr * sy) + pitchd * cp * cy * sr) + yd * (rolld * (cy * sr - cr * sp * sy) + yawd * (cr * sy - cy * sp * sr) - pitchd * cp * sr * sy), pitchd * yawd * sp, -pitchd * yawd * cp * sr - rolld * yawd * cr * sp, rolld * yawd * sp
* sr - pitchd * yawd * cp * cr, -xd * (pitchd * cp * cy - yawd * sp * sy) - yd * (pitchd * cp * sy + yawd * cy * sp) + pitchd * zd * sp, -zd * (pitchd * cp * sr + rolld * cr * sp) - xd * (-rolld * cp * cr * cy + pitchd * cy * sp * sr + yawd * cp * sr * sy)
+ yd * (rolld * cp * cr * sy + yawd * cp * cy * sr - pitchd * sp * sr * sy), -zd * (pitchd * cp * cr - rolld * sp * sr) - xd * (pitchd * cr * cy * sp + rolld * cp * cy * sr + yawd * cp * cr * sy) - yd * (-yawd * cp * cr * cy + pitchd * cr * sp * sy + rolld * cp * sr * sy), 0.0, 0.0, 0.0, -xd
* (yawd * cp * cy - pitchd * sp * sy) - yd * (pitchd * cy * sp + yawd * cp * sy), yd * (rolld * (sr * sy + cr * cy * sp) - yawd * (cr * cy + sp * sr * sy) + pitchd * cp * cy * sr) + xd * (rolld * (cy * sr - cr * sp * sy) + yawd * (cr * sy - cy * sp * sr) - pitchd * cp * sr * sy), yd
* (rolld * (cr * sy - cy * sp * sr) + yawd * (cy * sr - cr * sp * sy) + pitchd * cp * cr * cy) - xd * (-rolld * (cr * cy + sp * sr * sy) + yawd * (sr * sy + cr * cy * sp) + pitchd * cp * cr * sy);
}
if (dmotion_subspace_dot_times_vdv) {
dmotion_subspace_dot_times_vdv->resize(motion_subspace_dot_times_v.rows(), getNumVelocities());
dmotion_subspace_dot_times_vdv->transpose() << 0.0, 0.0, 0.0, -pitchd * cy * sp - yawd * cp * sy, rolld * (sr * sy + cr * cy * sp) - yawd * (cr * cy + sp * sr * sy) + pitchd * cp * cy * sr, rolld * (cr * sy - cy * sp * sr) + yawd * (cy * sr - cr * sp * sy) + pitchd * cp * cr * cy, 0.0, 0.0, 0.0, yawd * cp
* cy - pitchd * sp * sy, -rolld * (cy * sr - cr * sp * sy) - yawd * (cr * sy - cy * sp * sr) + pitchd * cp * sr * sy, -rolld * (cr * cy + sp * sr * sy) + yawd * (sr * sy + cr * cy * sp) + pitchd * cp * cr * sy, 0.0, 0.0, 0.0, -pitchd * cp, rolld * cp * cr - pitchd * sp * sr, -pitchd * cr
* sp - rolld * cp * sr, 0.0, -pitchd * sr + yawd * cp * cr, -pitchd * cr - yawd * cp * sr, 0.0, xd * (sr * sy + cr * cy * sp) - yd * (cy * sr - cr * sp * sy) + zd * cp * cr, xd * (cr * sy - cy * sp * sr) - yd * (cr * cy + sp * sr * sy) - zd * cp * sr, -yawd * cp, -sr * (rolld + yawd * sp), -cr
* (rolld + yawd * sp), -zd * cp - xd * cy * sp - yd * sp * sy, sr * (-zd * sp + xd * cp * cy + yd * cp * sy), cr * (-zd * sp + xd * cp * cy + yd * cp * sy), -pitchd * cp, rolld * cp * cr - pitchd * sp * sr, -pitchd * cr * sp - rolld * cp * sr, cp * (yd * cy - xd * sy), -xd
* (cr * cy + sp * sr * sy) - yd * (cr * sy - cy * sp * sr), xd * (cy * sr - cr * sp * sy) + yd * (sr * sy + cr * cy * sp);
}
}
示例5: moveFoot
/* ********************************************************************************************* */
void moveFoot(const Eigen::VectorXd& dx, bool left, Vector6d& dq) {
// Get the jacobian
Eigen::MatrixXd J = hubo->getBodyNode(left ? "leftFoot" : "rightFoot")
->getWorldJacobian().bottomRightCorner<6,6>();
Eigen::MatrixXd temp = J.topRightCorner<3,6>();
J.topRightCorner<3,6>() = J.bottomRightCorner<3,6>();
J.bottomRightCorner<3,6>() = temp;
for(size_t i = 0; i < 6; i++) J(i,i) += 0.005;
if(dbg) std::cout << "J= [\n" << J << "];\n";
// Compute the inverse
Eigen::MatrixXd JInv;
JInv = J;
aa_la_inv(6, JInv.data());
// Compute joint space velocity
if(dbg) cout << "dxRightLeg: " << dx.transpose() << endl;
dq = (JInv * dx);
if(dq.norm() > max_step_size) dq = dq.normalized() * max_step_size;
if(dbg) cout << "dqRightLeg: " << dq.transpose() << endl;
}
示例6: computeResiduals
double SparseImgAlign::computeResiduals(
const SE3& T_cur_from_ref,
bool linearize_system,
bool compute_weight_scale)
{
// Warp the (cur)rent image such that it aligns with the (ref)erence image
const cv::Mat& cur_img = cur_frame_->img_pyr_.at(level_);
if(linearize_system && display_)
resimg_ = cv::Mat(cur_img.size(), CV_32F, cv::Scalar(0));
if(have_ref_patch_cache_ == false)
precomputeReferencePatches();
// compute the weights on the first iteration
std::vector<float> errors;
if(compute_weight_scale)
errors.reserve(visible_fts_.size());
const int stride = cur_img.cols;
const int border = patch_halfsize_+1;
const float scale = 1.0f/(1<<level_);
const Vector3d ref_pos(ref_frame_->pos());
float chi2 = 0.0;
size_t feature_counter = 0; // is used to compute the index of the cached jacobian
std::vector<bool>::iterator visiblity_it = visible_fts_.begin();
for(auto it=ref_frame_->fts_.begin(); it!=ref_frame_->fts_.end();
++it, ++feature_counter, ++visiblity_it)
{
// check if feature is within image
if(!*visiblity_it)
continue;
// compute pixel location in cur img
const double depth = ((*it)->point->pos_ - ref_pos).norm();
const Vector3d xyz_ref((*it)->f*depth);
const Vector3d xyz_cur(T_cur_from_ref * xyz_ref);
const Vector2f uv_cur_pyr(cur_frame_->cam_->world2cam(xyz_cur).cast<float>() * scale);
const float u_cur = uv_cur_pyr[0];
const float v_cur = uv_cur_pyr[1];
const int u_cur_i = floorf(u_cur);
const int v_cur_i = floorf(v_cur);
// check if projection is within the image
if(u_cur_i < 0 || v_cur_i < 0 || u_cur_i-border < 0 || v_cur_i-border < 0 || u_cur_i+border >= cur_img.cols || v_cur_i+border >= cur_img.rows)
continue;
// compute bilateral interpolation weights for the current image
const float subpix_u_cur = u_cur-u_cur_i;
const float subpix_v_cur = v_cur-v_cur_i;
const float w_cur_tl = (1.0-subpix_u_cur) * (1.0-subpix_v_cur);
const float w_cur_tr = subpix_u_cur * (1.0-subpix_v_cur);
const float w_cur_bl = (1.0-subpix_u_cur) * subpix_v_cur;
const float w_cur_br = subpix_u_cur * subpix_v_cur;
float* ref_patch_cache_ptr = reinterpret_cast<float*>(ref_patch_cache_.data) + patch_area_*feature_counter;
size_t pixel_counter = 0; // is used to compute the index of the cached jacobian
for(int y=0; y<patch_size_; ++y)
{
uint8_t* cur_img_ptr = (uint8_t*) cur_img.data + (v_cur_i+y-patch_halfsize_)*stride + (u_cur_i-patch_halfsize_);
for(int x=0; x<patch_size_; ++x, ++pixel_counter, ++cur_img_ptr, ++ref_patch_cache_ptr)
{
// compute residual
const float intensity_cur = w_cur_tl*cur_img_ptr[0] + w_cur_tr*cur_img_ptr[1] + w_cur_bl*cur_img_ptr[stride] + w_cur_br*cur_img_ptr[stride+1];
const float res = intensity_cur - (*ref_patch_cache_ptr);
// used to compute scale for robust cost
if(compute_weight_scale)
errors.push_back(fabsf(res));
// robustification
float weight = 1.0;
if(use_weights_) {
weight = weight_function_->value(res/scale_);
}
chi2 += res*res*weight;
n_meas_++;
if(linearize_system)
{
// compute Jacobian, weighted Hessian and weighted "steepest descend images" (times error)
const Vector6d J(jacobian_cache_.col(feature_counter*patch_area_ + pixel_counter));
H_.noalias() += J*J.transpose()*weight;
Jres_.noalias() -= J*res*weight;
if(display_)
resimg_.at<float>((int) v_cur+y-patch_halfsize_, (int) u_cur+x-patch_halfsize_) = res/255.0;
}
}
}
}
// compute the weights on the first iteration
if(compute_weight_scale && iter_ == 0)
scale_ = scale_estimator_->compute(errors);
return chi2/n_meas_;
}
示例7: compareAccelerations
//.........这里部分代码省略.........
// Calculation of velocities and Jacobian at (k+1)-th time step
skeleton->setState(xNext, true, true, false);
skeleton->setGenAccs(ddq, true);
Vector6d vBody2 = bn->getBodyVelocity();
Vector6d vWorld2 = bn->getWorldVelocity();
MatrixXd JBody2 = bn->getBodyJacobian();
MatrixXd JWorld2 = bn->getWorldJacobian();
Isometry3d T2 = bn->getWorldTransform();
// Get accelerations and time derivatives of Jacobians at k-th time step
Vector6d aBody2 = bn->getBodyAcceleration();
Vector6d aWorld2 = bn->getWorldAcceleration();
MatrixXd dJBody2 = bn->getBodyJacobianTimeDeriv();
MatrixXd dJWorld2 = bn->getWorldJacobianTimeDeriv();
// Calculation of approximated accelerations and time derivatives of
// Jacobians
Vector6d aBodyApprox = (vBody2 - vBody1) / timeStep;
Vector6d aWorldApprox = (vWorld2 - vWorld1) / timeStep;
// TODO(JS): Finite difference of Jacobian test is not implemented yet.
// MatrixXd dJBodyApprox = (JBody2 - JBody1) / timeStep;
// MatrixXd dJWorldApprox = (JWorld2 - JWorld1) / timeStep;
// MatrixXd dJBodyApprox = MatrixXd::Zero(6, nDepGenCoord);
// MatrixXd dJWorldApprox = MatrixXd::Zero(6, nDepGenCoord);
// for (int l = 0; l < nDepGenCoord; ++l)
// {
// skeleton->setConfig(q);
// Jacobian JBody_a = bn->getBodyJacobian();
// int idx = bn->getDependentGenCoordIndex(l);
// VectorXd qGrad = q;
// qGrad[idx] = qNext[idx];
// skeleton->setConfig(qGrad);
// Jacobian JBody_b = bn->getBodyJacobian();
// Jacobian dJBody_dq = (JBody_b - JBody_a) / (qNext[idx] - q[idx]);
// dJBodyApprox += dJBody_dq * dq[idx];
// }
// Comparing two velocities
EXPECT_TRUE(equals(aBody1, aBodyApprox, TOLERANCE));
EXPECT_TRUE(equals(aBody2, aBodyApprox, TOLERANCE));
EXPECT_TRUE(equals(aWorld1, aWorldApprox, TOLERANCE));
EXPECT_TRUE(equals(aWorld2, aWorldApprox, TOLERANCE));
// EXPECT_TRUE(equals(dJBody1, dJBodyApprox, TOLERANCE));
// EXPECT_TRUE(equals(dJBody2, dJBodyApprox, TOLERANCE));
// EXPECT_TRUE(equals(dJWorld1, dJWorldApprox, TOLERANCE));
// EXPECT_TRUE(equals(dJWorld2, dJWorldApprox, TOLERANCE));
// Debugging code
if (!equals(aBody1, aBodyApprox, TOLERANCE))
{
cout << "aBody1 :" << aBody1.transpose() << endl;
cout << "aBodyApprox:" << aBodyApprox.transpose() << endl;
}
if (!equals(aBody2, aBodyApprox, TOLERANCE))
{
cout << "aBody2 :" << aBody2.transpose() << endl;
cout << "aBodyApprox:" << aBodyApprox.transpose() << endl;
}
if (!equals(aWorld1, aWorldApprox, TOLERANCE))
{
cout << "aWorld1 :" << aWorld1.transpose() << endl;
cout << "aWorldApprox:" << aWorldApprox.transpose() << endl;
}
if (!equals(aWorld2, aWorldApprox, TOLERANCE))
{
cout << "aWorld2 :" << aWorld2.transpose() << endl;
cout << "aWorldApprox:" << aWorldApprox.transpose() << endl;
}
// if (!equals(dJBody1, dJBodyApprox, TOLERANCE))
// {
// cout << "Name :" << bn->getName() << endl;
// cout << "dJBody1 :" << endl << dJBody1 << endl;
// cout << "dJBodyApprox:" << endl << dJBodyApprox << endl;
// }
// if (!equals(dJBody2, dJBodyApprox, TOLERANCE))
// {
// cout << "dJBody2:" << endl << dJBody2.transpose() << endl;
// cout << "dJBodyApprox:" << endl << dJBodyApprox.transpose() << endl;
// }
// if (!equals(dJWorld1, dJWorldApprox, TOLERANCE))
// {
// cout << "dJWorld1 :" << endl << dJWorld1 << endl;
// cout << "dJWorldApprox:" << endl << dJWorldApprox << endl;
// }
// if (!equals(dJWorld2, dJWorldApprox, TOLERANCE))
// {
// cout << "dJWorld2 :" << endl << dJWorld2 << endl;
// cout << "dJWorldApprox:" << endl << dJWorldApprox << endl;
// }
}
}
}
delete world;
}
示例8: compareVelocities
//==============================================================================
void DynamicsTest::compareVelocities(const std::string& _fileName)
{
using namespace std;
using namespace Eigen;
using namespace dart;
using namespace math;
using namespace dynamics;
using namespace simulation;
using namespace utils;
//----------------------------- Settings -------------------------------------
const double TOLERANCE = 1.0e-6;
#ifndef NDEBUG // Debug mode
int nRandomItr = 10;
#else
int nRandomItr = 1;
#endif
double qLB = -0.5 * DART_PI;
double qUB = 0.5 * DART_PI;
double dqLB = -0.5 * DART_PI;
double dqUB = 0.5 * DART_PI;
double ddqLB = -0.5 * DART_PI;
double ddqUB = 0.5 * DART_PI;
Vector3d gravity(0.0, -9.81, 0.0);
// load skeleton
World* world = SkelParser::readWorld(_fileName);
assert(world != NULL);
world->setGravity(gravity);
//------------------------------ Tests ---------------------------------------
for (int i = 0; i < world->getNumSkeletons(); ++i)
{
Skeleton* skeleton = world->getSkeleton(i);
assert(skeleton != NULL);
int dof = skeleton->getNumGenCoords();
for (int j = 0; j < nRandomItr; ++j)
{
// Generate a random state
VectorXd q = VectorXd(dof);
VectorXd dq = VectorXd(dof);
VectorXd ddq = VectorXd(dof);
for (int k = 0; k < dof; ++k)
{
q[k] = math::random(qLB, qUB);
dq[k] = math::random(dqLB, dqUB);
ddq[k] = math::random(ddqLB, ddqUB);
}
VectorXd state = VectorXd::Zero(dof * 2);
state << q, dq;
skeleton->setState(state, true, true, true);
skeleton->setGenAccs(ddq, true);
skeleton->computeInverseDynamics(false, false);
// For each body node
for (int k = 0; k < skeleton->getNumBodyNodes(); ++k)
{
BodyNode* bn = skeleton->getBodyNode(k);
// Calculation of velocities using recursive method
Vector6d vBody = bn->getBodyVelocity();
Vector6d vWorld = bn->getWorldVelocity();
Vector6d aBody = bn->getBodyAcceleration();
Vector6d aWorld = bn->getWorldAcceleration();
// Calculation of velocities using Jacobian and dq
MatrixXd JBody = bn->getBodyJacobian();
MatrixXd JWorld = bn->getWorldJacobian();
MatrixXd dJBody = bn->getBodyJacobianTimeDeriv();
MatrixXd dJWorld = bn->getWorldJacobianTimeDeriv();
Vector6d vBody2 = Vector6d::Zero();
Vector6d vWorld2 = Vector6d::Zero();
Vector6d aBody2 = Vector6d::Zero();
Vector6d aWorld2 = Vector6d::Zero();
for (int l = 0; l < bn->getNumDependentGenCoords(); ++l)
{
int idx = bn->getDependentGenCoordIndex(l);
vBody2 += JBody.col(l) * dq[idx];
vWorld2 += JWorld.col(l) * dq[idx];
aBody2 += dJBody.col(l) * dq[idx] + JBody.col(l) * ddq[idx];
aWorld2 += dJWorld.col(l) * dq[idx] + JWorld.col(l) * ddq[idx];
}
// Comparing two velocities
EXPECT_TRUE(equals(vBody, vBody2, TOLERANCE));
EXPECT_TRUE(equals(vWorld, vWorld2, TOLERANCE));
EXPECT_TRUE(equals(aBody, aBody2, TOLERANCE));
EXPECT_TRUE(equals(aWorld, aWorld2, TOLERANCE));
// Debugging code
if (!equals(vBody, vBody2, TOLERANCE))
{
cout << "vBody : " << vBody.transpose() << endl;
cout << "vBody2: " << vBody2.transpose() << endl;
}
if (!equals(vWorld, vWorld2, TOLERANCE))
{
cout << "vWorld : " << vWorld.transpose() << endl;
//.........这里部分代码省略.........