本文整理汇总了C++中SharedMemory::read方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemory::read方法的具体用法?C++ SharedMemory::read怎么用?C++ SharedMemory::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedMemory
的用法示例。
在下文中一共展示了SharedMemory::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
SharedMemory shared;
shared.read();
return a.exec();
}
示例2: main
int main(int argc, char **argv)
{
SharedMemory *shm = new SharedMemory("ViconShared",61234,sizeof(X));
ros::init(argc, argv, "quad");
std::cout << "Vicon Socket Initialized\n";
std::cout << omegamax;
ros::NodeHandle ViconNode;
ros::Rate loop_rate(100);
float omegas[4] = {0,0,0,0};
//Opening zigbee comm port
FILE *fp;
fp = fopen("/dev/ttyUSB0","rw+");
if (!fp)
{
printf("Could not open Zigbee port!\n");
exit(-1);
}
setvbuf(fp, NULL, _IONBF,0); // No buffering
// ************** //
// **** LOOP **** //
// ************** //
int count = 0;
while (ros::ok())
{
//READ STATE FROM SHARED MEMORY
shm->read((void *)X);
//MY CURRENT POSITION
std::cout << robots[quadID] << std::endl
<< std::setprecision(8)
<< " pos:\t"
<< X[quadID][0] << "\t"
<< X[quadID][1] << "\t"
<< X[quadID][2] << "\n ang:\t"
<< X[quadID][3] << "\t"
<< X[quadID][4] << "\t"
<< X[quadID][5]
<< std::endl;
//get current state
x=X[quadID][0];
y=X[quadID][1];
z=X[quadID][2];
ox=X[quadID][3]; //check if minangle() is needed
oy=X[quadID][4];
oz=X[quadID][5];
//get estimate of derivatives using
//The Al-Alaoui differentiator
dx=-(1.0/7.0)*pdx+(8.0/(7.0*Ts))*(x-px);
dy=-(1.0/7.0)*pdy+(8.0/(7.0*Ts))*(y-py);
dz=-(1.0/7.0)*pdz+(8.0/(7.0*Ts))*(z-pz);
dox=-(1.0/7.0)*pdox+(8.0/(7.0*Ts))*(ox-pox);
doy=-(1.0/7.0)*pdoy+(8.0/(7.0*Ts))*(oy-poy);
doz=-(1.0/7.0)*pdoz+(8.0/(7.0*Ts))*(oz-poz);
std::cout
<< std::setprecision(4)
<< "dx: " << dx << "\t"
<< "dy: " << dy << "\t"
<< "dz: " << dz << "\n"
<< "dox: " << dox << "\t"
<< "doy: " << doy << "\t"
<< "doz: " << doz << "\n"
<< std::endl;
//update values for the next update
px=x;
py=y;
pz=z;
pox=ox;
poy=oy;
poz=oz;
pdx=dx;
pdy=dy;
pdz=dz;
pdox=dox;
pdoy=doy;
pdoz=doz;
//CONTROL LAW
//updates all omegas (w)
uqFromXqref();
x_error_abs = abs(x_error);
y_error_abs = abs(y_error);
z_error_abs = abs(z_error);
\
//.........这里部分代码省略.........