本文整理汇总了C++中IPC::getAttitude方法的典型用法代码示例。如果您正苦于以下问题:C++ IPC::getAttitude方法的具体用法?C++ IPC::getAttitude怎么用?C++ IPC::getAttitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPC
的用法示例。
在下文中一共展示了IPC::getAttitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
// Initialize shared memory
if (ipc.init(false))
exit(1);
// Initialize nominal beaconContainer
parseWaypoints();
// Create camera semaphore/ mutex
sem_init(&semCam, 0, 0);
if (pthread_mutex_init(&mutexImageData, NULL) != 0) {
printf("\n Camera mutex init failed\n");
exit(1);
}
// Start camera thread
pthread_t tid;
int err = pthread_create(&tid, NULL, &camThread, NULL);
if (err != 0) {
printf("\nCan't create camera thread :[%s]", strerror(err));
exit(1);
}
lastPhotogramMicros = getMicroSec();
// Main loop
for(;;photogram++) {
TRACE(DEBUG, "\nPHOTOGRAM %d, milliseconds: %ld\n", photogram, getMillisSinceStart());
// Update time variables
photogramMicros = getMicroSec();
lastPhotogramSpentTime = getSpent(photogramMicros - lastPhotogramMicros);
microsSinceStart += lastPhotogramSpentTime;
lastPhotogramMicros = photogramMicros;
// Get drone roll, pitch and yaw
attitudeT attitude, delayedAttitude;
ipc.getAttitude(attitude);
attitudeSignal.push(attitude, lastPhotogramSpentTime);
delayedAttitude = attitudeSignal.getSignal();
droneRoll = delayedAttitude.roll * 0.01;
dronePitch = delayedAttitude.pitch * 0.01;
droneYaw = delayedAttitude.yaw * 0.01;
// Update estimated servo values
rollStatusServo.update(lastPhotogramSpentTime);
pitchStatusServo.update(lastPhotogramSpentTime);
if (rollStatusServo.inBigStep() || pitchStatusServo.inBigStep()) {
sem_wait(&semCam);
continue;
}
// Update estimated camera roll and pitch
roll = droneRoll + rollStatusServo.getEstimatedAngle();
pitch = dronePitch + pitchStatusServo.getEstimatedAngle();
// Switch beacon containers to preserve one history record
if (beaconContainer == &beaconContainerA) {
beaconContainer = &beaconContainerB;
oldBeaconContainer = &beaconContainerA;
}
else {
beaconContainer = &beaconContainerA;
oldBeaconContainer = &beaconContainerB;
}
beaconContainer->clean();
// Wait until new frame is received
sem_wait(&semCam);
// Where the magic happens
findBeacons();
groupBeacons();
findWaypoints();
computePosition();
}
StopCamera();
printf("Finished.\n");
return 0;
}