本文整理汇总了C++中yarp::sig::Matrix::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::toString方法的具体用法?C++ Matrix::toString怎么用?C++ Matrix::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yarp::sig::Matrix
的用法示例。
在下文中一共展示了Matrix::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeFTsensCalibrationToFile
/**
* Write the calibration matrix to a file suitable to be used by the IIT FTsens sensor.
* calibration_matrix should map the raw straing gauge values to SI (Newton,NewtonMeters)
* units.
*
* Full scale vector should contain the desired full scales in SI units.
*/
bool writeFTsensCalibrationToFile(std::string filename,
yarp::sig::Matrix & calibration_matrix,
yarp::sig::Vector & full_scale)
{
if( calibration_matrix.rows() != 6 ||
calibration_matrix.cols() != 6 ||
full_scale.size() != 6 )
{
return false;
}
std::ofstream myfile;
myfile.open (filename.c_str());
if( !myfile.is_open() )
{
std::cerr << "[ERROR] Error in writing calibration matrix to " << filename << std::endl;
return false;
}
std::cout << "insituFTSensorCalibration module: writing to file calibration matrix: " << std::endl;
std::cout << calibration_matrix.toString() << std::endl;
std::cout << "insituFTSensorCalibration module: with full scale: " << std::endl;
std::cout << full_scale.toString() << std::endl;
//It seems that full_scale is required to be an integer, TODO check
std::vector<int> full_scale_int;
full_scale_int.resize(6);
for(int i=0; i < 6; i++ )
{
full_scale_int[i] = round(full_scale[i]);
}
for(int i=0; i < 6; i++ )
{
for(int j=0; j < 6; j++ )
{
//The matrix that is passed to the actual sensor use
//coefficients gains that are encoded with respect to
//the full scale
double firmware_coeff = calibration_matrix(i,j)/((double)full_scale_int[i]);
//Then this firmware coefficient is expressed in 1.15 two complement fixed point way
//that we encode in the file in hex format TODO CHECK endianess problems
std::string hex;
if( !convert_onedotfifteen(firmware_coeff,hex) )
{
std::cerr << "[ERROR] Error in writing calibration matrix to file, for the given choice"
<< " of fullscale the " << i << " " << j << " coefficient is not in [-1.0,1.0]" << std::endl;
myfile.close();
return false;
}
myfile << hex << "\r\n";
}
}
myfile << 1 << "\r\n";
for(int i=0; i < 6; i++ )
{
myfile << full_scale_int[i] << "\r\n";
}
myfile.close();
return true;
}