本文整理汇总了C++中yarp::sig::Matrix类的典型用法代码示例。如果您正苦于以下问题:C++ Matrix类的具体用法?C++ Matrix怎么用?C++ Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: appendMatrixRow
void iCubShoulderConstr::appendMatrixRow(yarp::sig::Matrix &dest,
const yarp::sig::Vector &row)
{
yarp::sig::Matrix tmp;
// if dest is already filled with something
if (dest.rows())
{
// exit if lengths do not match
if (row.length()!=dest.cols())
return;
tmp.resize(dest.rows()+1,dest.cols());
// copy the content of dest in temp
for (int i=0; i<dest.rows(); i++)
for (int j=0; j<dest.cols(); j++)
tmp(i,j)=dest(i,j);
// reassign dest
dest=tmp;
}
else
dest.resize(1,row.length());
// append the last row
for (int i=0; i<dest.cols(); i++)
dest(dest.rows()-1,i)=row[i];
}
开发者ID:apostroph,项目名称:icub-main,代码行数:29,代码来源:iKinIpOpt.cpp
示例2: idynInertia2kdlRotationalInertia
bool idynInertia2kdlRotationalInertia(const yarp::sig::Matrix & idynInertia,KDL::RotationalInertia & kdlRotationalInertia)
{
if(idynInertia.cols() != 3 || idynInertia.rows() != 3 ) return false;
//if(idynInertia(0,1) != idynInertia(1,0) || idynInertia(0,2) != idynInertia(2,0) || idynInertia(1,2) != idynInertia(2,1)) return false;
kdlRotationalInertia = KDL::RotationalInertia(idynInertia(0,0),idynInertia(1,1),idynInertia(2,2),idynInertia(0,1),idynInertia(0,2),idynInertia(1,2));
return true;
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例3: Matrix_write
bool Matrix_write(const std::string file_name, const yarp::sig::Matrix & mat)
{
FILE * fp;
uint32_t rows,cols;
double elem;
rows = mat.rows();
cols = mat.cols();
fp = fopen(file_name.c_str(),"wb");
if( fp == NULL ) return false;
//writing dimensions informations
fwrite(&rows,sizeof(uint32_t),1,fp);
fwrite(&cols,sizeof(uint32_t),1,fp);
for(size_t i=0;i<rows;i++) {
for(size_t j=0;j<cols;j++ ) {
elem = mat(i,j);
fwrite(&elem,sizeof(double),1,fp);
}
}
/*
if( gsl_matrix_fwrite(fp,(gsl_matrix*)mat.getGslMatrix()) == GSL_EFAILED ) {
fclose(fp);
return false;
}*/
fclose(fp);
return true;
}
开发者ID:helloxss,项目名称:online-inertial-parameter-estimation,代码行数:30,代码来源:MatVetIO.cpp
示例4: localSE3inv
yarp::sig::Matrix localSE3inv(const yarp::sig::Matrix &H, unsigned int verbose)
{
if ((H.rows()<4) || (H.cols()<4))
{
if (verbose)
fprintf(stderr,"localSE3inv() failed\n");
return yarp::sig::Matrix(0,0);
}
yarp::sig::Matrix invH(4,4);
yarp::sig::Vector p(3);
yarp::sig::Matrix Rt=H.submatrix(0,2,0,2).transposed();
p[0]=H(0,3);
p[1]=H(1,3);
p[2]=H(2,3);
p=Rt*p;
for (unsigned int i=0; i<3; i++)
for (unsigned int j=0; j<3; j++)
invH(i,j)=Rt(i,j);
invH(0,3)=-p[0];
invH(1,3)=-p[1];
invH(2,3)=-p[2];
invH(3,3)=1.0;
return invH;
}
开发者ID:,项目名称:,代码行数:31,代码来源:
示例5: computeFoR
//creates a full transform as given by a DCM matrix at the pos and norm w.r.t. the original frame, from the pos and norm (one axis set arbitrarily)
bool AvoidanceHandlerAbstract::computeFoR(const yarp::sig::Vector &pos, const yarp::sig::Vector &norm, yarp::sig::Matrix &FoR)
{
if (norm == zeros(3))
{
FoR=eye(4);
return false;
}
yarp::sig::Vector x(3,0.0), z(3,0.0), y(3,0.0);
z = norm;
if (z[0] == 0.0)
{
z[0] = 0.00000001; // Avoid the division by 0
}
y[0] = -z[2]/z[0]; //y is in normal plane
y[2] = 1; //this setting is arbitrary
x = -1*(cross(z,y));
// Let's make them unitary vectors:
x = x / yarp::math::norm(x);
y = y / yarp::math::norm(y);
z = z / yarp::math::norm(z);
FoR=eye(4);
FoR.setSubcol(x,0,0);
FoR.setSubcol(y,0,1);
FoR.setSubcol(z,0,2);
FoR.setSubcol(pos,0,3);
return true;
}
开发者ID:robotology,项目名称:react-control,代码行数:33,代码来源:avoidanceHandler.cpp
示例6: v
Vector yarp::math::dcm2ypr(const yarp::sig::Matrix &R)
{
yAssert((R.rows() >= 3) && (R.cols() >= 3));
Vector v(3); // yaw pitch roll
if (R(0, 2)<1.0)
{
if (R(0, 2)>-1.0)
{
v[0] = atan2(-R(0, 1), R(0, 0));
v[1] = asin(R(0, 2));
v[2] = atan2(-R(1, 2), R(2, 2));
}
else // == -1
{
// Not a unique solution: psi-phi=atan2(-R12,R11)
v[0] = 0.0;
v[1] = -M_PI / 2.0;
v[2] = -atan2(R(1, 0), R(1, 1));
}
}
else // == +1
{
// Not a unique solution: psi+phi=atan2(-R12,R11)
v[0] = 0.0;
v[1] = M_PI / 2.0;
v[2] = atan2(R(1, 0), R(1, 1));
}
return v;
}
开发者ID:jgvictores,项目名称:yarp,代码行数:32,代码来源:math.cpp
示例7: KDLtoYarp
bool KDLtoYarp(const KDL::Rotation & kdlRotation, yarp::sig::Matrix & yarpMatrix3_3)
{
if( yarpMatrix3_3.rows() != 3 || yarpMatrix3_3.cols() != 3 ) { yarpMatrix3_3.resize(3,3); }
//Both kdl and yarp store the rotation matrix in row major order
memcpy(yarpMatrix3_3.data(),kdlRotation.data,3*3*sizeof(double));
return true;
}
开发者ID:robotology,项目名称:idyntree,代码行数:7,代码来源:check_iKin_export_random_chain.cpp
示例8:
bool yarpWholeBodyModelV1::convertBasePose(const Frame &xBase, yarp::sig::Matrix & H_world_base)
{
if( H_world_base.cols() != 4 || H_world_base.rows() != 4 )
H_world_base.resize(4,4);
xBase.get4x4Matrix(H_world_base.data());
return true;
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例9: getVelocityState
void RobotInterface::getVelocityState(yarp::sig::Matrix& outputVelocity)
{
outputVelocity.resize(velocityState.rows(), velocityState.cols());
for(int i = 0; i < outputVelocity.rows(); i++)
{
for(int d = 0; d < outputVelocity.cols(); d++) outputVelocity(i, d) = velocityState(i, d);
}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:8,代码来源:robotInterface.cpp
示例10: getPressureState
void RobotInterface::getPressureState(yarp::sig::Matrix& outputPressure)
{
outputPressure.resize(pressureState.rows(), pressureState.cols());
for(int i = 0; i < outputPressure.rows(); i++)
{
for(int d = 0; d < outputPressure.cols(); d++) outputPressure(i, d) = pressureState(i, d);
}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:8,代码来源:robotInterface.cpp
示例11: idynMatrix2kdlRotation
bool idynMatrix2kdlRotation(const yarp::sig::Matrix & idynMatrix, KDL::Rotation & kdlRotation)
{
if(idynMatrix.cols() != 3 || idynMatrix.rows() != 3) return false;
kdlRotation = KDL::Rotation(idynMatrix(0,0),idynMatrix(0,1),idynMatrix(0,2),
idynMatrix(1,0),idynMatrix(1,1),idynMatrix(1,2),
idynMatrix(2,0),idynMatrix(2,1),idynMatrix(2,2));
return true;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例12: getPositionState
void RobotInterface::getPositionState(yarp::sig::Matrix& outputPosition)
{
outputPosition.resize(positionState.rows(), positionState.cols());
for(int i = 0; i < outputPosition.rows(); i++)
{
for(int d = 0; d < outputPosition.cols(); d++) outputPosition(i, d) = positionState(i, d);
}
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:8,代码来源:robotInterface.cpp
示例13: printMatrixYarp
void DictionaryLearning::printMatrixYarp(const yarp::sig::Matrix &A)
{
cout << endl;
for (int i=0; i<A.rows(); i++)
for (int j=0; j<A.cols(); j++)
cout<<A(i,j)<<" ";
cout<<endl;
cout << endl;
}
开发者ID:robotology,项目名称:gesture-recognition,代码行数:9,代码来源:DictionaryLearning.cpp
示例14: fromRotationMatrix
void Quaternion::fromRotationMatrix(const yarp::sig::Matrix &R)
{
if ((R.rows()<3) || (R.cols()<3))
{
yError("fromRotationMatrix() failed, matrix should be >= 3x3");
yAssert(R.rows() >= 3 && R.cols() >= 3);
}
double tr = R(0, 0) + R(1, 1) + R(2, 2);
if (tr>0.0)
{
double sqtrp1 = sqrt(tr + 1.0);
double sqtrp12 = 2.0*sqtrp1;
internal_data[0] = 0.5*sqtrp1;
internal_data[1] = (R(2, 1) - R(1, 2)) / sqtrp12;
internal_data[2] = (R(0, 2) - R(2, 0)) / sqtrp12;
internal_data[3] = (R(1, 0) - R(0, 1)) / sqtrp12;
}
else if ((R(1, 1)>R(0, 0)) && (R(1, 1)>R(2, 2)))
{
double sqdip1 = sqrt(R(1, 1) - R(0, 0) - R(2, 2) + 1.0);
internal_data[2] = 0.5*sqdip1;
if (sqdip1>0.0)
sqdip1 = 0.5 / sqdip1;
internal_data[0] = (R(0, 2) - R(2, 0))*sqdip1;
internal_data[1] = (R(1, 0) + R(0, 1))*sqdip1;
internal_data[3] = (R(2, 1) + R(1, 2))*sqdip1;
}
else if (R(2, 2)>R(0, 0))
{
double sqdip1 = sqrt(R(2, 2) - R(0, 0) - R(1, 1) + 1.0);
internal_data[3] = 0.5*sqdip1;
if (sqdip1>0.0)
sqdip1 = 0.5 / sqdip1;
internal_data[0] = (R(1, 0) - R(0, 1))*sqdip1;
internal_data[1] = (R(0, 2) + R(2, 0))*sqdip1;
internal_data[2] = (R(2, 1) + R(1, 2))*sqdip1;
}
else
{
double sqdip1 = sqrt(R(0, 0) - R(1, 1) - R(2, 2) + 1.0);
internal_data[1] = 0.5*sqdip1;
if (sqdip1>0.0)
sqdip1 = 0.5 / sqdip1;
internal_data[0] = (R(2, 1) - R(1, 2))*sqdip1;
internal_data[2] = (R(1, 0) + R(0, 1))*sqdip1;
internal_data[3] = (R(0, 2) + R(2, 0))*sqdip1;
}
}
开发者ID:jgvictores,项目名称:yarp,代码行数:56,代码来源:Quaternion.cpp
示例15: set_R
bool Kalman::set_R(const yarp::sig::Matrix &_R)
{
if ((_R.cols()==R.cols()) && (_R.rows()==R.rows()))
{
R=_R;
return true;
}
else
return false;
}
开发者ID:elen4,项目名称:icub-main,代码行数:10,代码来源:kalman.cpp
示例16: idynMatrix2kdlFrame
bool idynMatrix2kdlFrame(const yarp::sig::Matrix & idynMatrix, KDL::Frame & kdlFrame)
{
if( idynMatrix.cols() != 4 || idynMatrix.rows() != 4 ) return false;
KDL::Rotation kdlRotation;
KDL::Vector kdlVector;
idynMatrix2kdlRotation(idynMatrix.submatrix(0,2,0,2),kdlRotation);
idynVector2kdlVector(idynMatrix.subcol(0,3,3),kdlVector);
kdlFrame = KDL::Frame(kdlRotation,kdlVector);
return true;
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例17: set_Q
bool Kalman::set_Q(const yarp::sig::Matrix &_Q)
{
if ((_Q.cols()==Q.cols()) && (_Q.rows()==Q.rows()))
{
Q=_Q;
return true;
}
else
return false;
}
开发者ID:elen4,项目名称:icub-main,代码行数:10,代码来源:kalman.cpp
示例18: set_B
bool Kalman::set_B(const yarp::sig::Matrix &_B)
{
if ((_B.cols()==B.cols()) && (_B.rows()==B.rows()))
{
B=_B;
return true;
}
else
return false;
}
开发者ID:elen4,项目名称:icub-main,代码行数:10,代码来源:kalman.cpp
示例19: setSubmatrix
bool Matrix::setSubmatrix(const yarp::sig::Matrix &m, int r, int c)
{
if((c<0) || (c+m.cols()>ncols) || (r<0) || (r+m.rows()>nrows))
return false;
for(int i=0;i<m.rows();i++)
for(int j=0;j<m.cols();j++)
(*this)[r+i][c+j] = m(i,j);
return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:10,代码来源:Matrix.cpp
示例20: res
yarp::sig::Vector iCub::skinDynLib::toVector(yarp::sig::Matrix m)
{
Vector res(m.rows()*m.cols(),0.0);
for (int r = 0; r < m.rows(); r++)
{
res.setSubvector(r*m.cols(),m.getRow(r));
}
return res;
}
开发者ID:AbuMussabRaja,项目名称:icub-main,代码行数:11,代码来源:common.cpp
注:本文中的yarp::sig::Matrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论