本文整理汇总了C++中AHRS::getEuler方法的典型用法代码示例。如果您正苦于以下问题:C++ AHRS::getEuler方法的具体用法?C++ AHRS::getEuler怎么用?C++ AHRS::getEuler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AHRS
的用法示例。
在下文中一共展示了AHRS::getEuler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
//-------------------- IMU setup and main loop ----------------------------
imuSetup();
ros::init(argc, argv, "ros_erle_imu_euler");
ros::NodeHandle n;
ros::Publisher imu_euler_pub = n.advertise<ros_erle_imu_euler::euler>("euler", 1000);
ros::Rate loop_rate(50);
while (ros::ok()){
//----------------------- Calculate delta time ----------------------------
gettimeofday(&tv,NULL);
previoustime = currenttime;
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
if(dt < 1/1300.0)
usleep((1/1300.0-dt)*1000000);
gettimeofday(&tv,NULL);
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
//-------- Read raw measurements from the MPU and update AHRS --------------
// Accel + gyro.
imu.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
ahrs.updateIMU(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, dt);
//------------------------ Read Euler angles ------------------------------
ahrs.getEuler(&roll, &pitch, &yaw);
ros_erle_imu_euler::euler msg;
msg.roll = roll;
msg.pitch = pitch;
msg.yaw = yaw;
imu_euler_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
示例2: imuLoop
void imuLoop()
{
float dtsum = 0.0f; //sum of delta t's
while(dtsum < 1.0f/freq) //run this loop at 1300 Hz (Max frequency gives best results for Mahony filter)
{
//----------------------- Calculate delta time ----------------------------
gettimeofday(&tv,NULL);
previoustime = currenttime;
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
if(dt < 1/1300.0) usleep((1/1300.0-dt)*1000000);
gettimeofday(&tv,NULL);
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
//-------- Read raw measurements from the MPU and update AHRS --------------
// Accel + gyro.
imu->update();
imu->read_accelerometer(&ax, &ay, &az);
imu->read_gyroscope(&gx, &gy, &gz);
ax /= G_SI;
ay /= G_SI;
az /= G_SI;
gx *= 180 / PI;
gy *= 180 / PI;
gz *= 180 / PI;
ahrs.updateIMU(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, dt);
// Accel + gyro + mag.
// Soft and hard iron calibration required for proper function.
/*
imu->update();
imu->read_accelerometer(&ay, &ax, &az);
az *= -1;
imu->read_gyroscope(&gy, &gx, &gz);
gz *= -1;
imu->read_magnetometer(&mx, &my, &mz);
ax /= G_SI;
ay /= G_SI;
az /= G_SI;
gx *= 180 / PI;
gy *= 180 / PI;
gz *= 180 / PI;
ahrs.update(-ax, -ay, -az, gx*0.0175, gy*0.0175, gz*0.0175, mx, my, mz, dt);
*/
//------------------------ Read Euler angles ------------------------------
ahrs.getEuler(&pitch, &roll, &yaw);
//------------------- Discard the time of the first cycle -----------------
if (!isFirst)
{
if (dt > maxdt) maxdt = dt;
if (dt < mindt) mindt = dt;
}
isFirst = 0;
dtsum += dt;
}
}
示例3: imuLoop
void imuLoop ( void ) {
//Calculate delta time
gettimeofday( &tv , NULL );
previoustime = currenttime;
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = ( currenttime - previoustime ) / 1000000.0;
if( dt < 1/1300.0 ) usleep( ( 1/1300.0 - dt ) * 1000000);
gettimeofday( &tv , NULL) ;
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = ( currenttime - previoustime ) / 1000000.0;
//Read raw measurements from the MPU and update AHRS
// Accel + gyro + mag.
// Soft and hard iron calibration required for proper function.
imu -> update();
imu -> read_accelerometer( &ay , &ax , &az );
imu -> read_gyroscope( &gy , &gx , &gz );
imu -> read_magnetometer( &mx , &my , &mz );
ax /= G_SI;
ay /= G_SI;
az /= G_SI;
my = - my;
ahrs.update( ax , ay , az , gx , gy , gz , mx , my , mz , dt );
//Read Euler angles
ahrs.getEuler( &pitch , &roll , &yaw );
//Discard the time of the first cycle
if ( !isFirst ) {
if ( dt > maxdt ) maxdt = dt;
if ( dt < mindt ) mindt = dt;
}
isFirst = 0;
//Console and network output with a lowered rate
dtsumm += dt;
if( dtsumm > 0.05 ) {
//Console output
//printf("ROLL: %+05.2f PITCH: %+05.2f YAW: %+05.2f PERIOD %.4fs RATE %dHz \n", roll, pitch, gz/*yaw * -1*/, dt, int(1/dt));
// Network output
//sprintf( sendline , "%10f %10f %10f %10f %dHz\n" ,ahrs.getW() ,ahrs.getX() ,ahrs.getY() ,ahrs.getZ() ,int( 1/dt ) );
//sendto( sockfd , sendline , strlen( sendline ) , 0 , ( struct sockaddr * )&servaddr , sizeof( servaddr ) );
dtsumm = 0;
}
}
示例4: imuLoop
void imuLoop()
{
//----------------------- Calculate delta time ----------------------------
gettimeofday(&tv,NULL);
previoustime = currenttime;
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
if(dt < 1/1300.0) usleep((1/1300.0-dt)*1000000);
gettimeofday(&tv,NULL);
currenttime = 1000000 * tv.tv_sec + tv.tv_usec;
dt = (currenttime - previoustime) / 1000000.0;
//-------- Read raw measurements from the MPU and update AHRS --------------
// Accel + gyro.
/*
imu->update();
imu->read_accelerometer(&ax, &ay, &az);
imu->read_gyroscope(&gx, &gy, &gz);
ax /= G_SI;
ay /= G_SI;
az /= G_SI;
gx *= 180 / PI;
gy *= 180 / PI;
gz *= 180 / PI;
ahrs.updateIMU(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, dt);
*/
// Accel + gyro + mag.
// Soft and hard iron calibration required for proper function.
imu->update();
imu->read_accelerometer(&ay, &ax, &az);
imu->read_gyroscope(&gy, &gx, &gz);
imu->read_magnetometer(&my, &mx, &mz);
ax /= -G_SI;
ay /= -G_SI;
az /= G_SI;
gx *= 180 / PI;
gy *= 180 / PI;
gz *= -180 / PI;
ahrs.update(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, my, mx, -mz, dt);
//------------------------ Read Euler angles ------------------------------
//ahrs.getEuler(&pitch, &roll, &yaw);//roll and pitch inverted
ahrs.getEuler(&roll, &pitch, &yaw);
//------------------- Discard the time of the first cycle -----------------
if (!isFirst)
{
if (dt > maxdt) maxdt = dt;
if (dt < mindt) mindt = dt;
}
isFirst = 0;
}