comparison Discovery/Src/motion.c @ 621:6826731ff2be

Use roll and pitch agles in 0-360 format: The roll and pitch values are provided as pos/neg angle values which causes problems in the vector calculation for the motion detection => changed the implementation to store the calibration data with a 180? offset. Also shift value by 180? before they are used for vector calculations.
author Ideenmodellierer
date Wed, 03 Feb 2021 21:44:22 +0100
parents 96af74455420
children 028d8f3a9410
comparison
equal deleted inserted replaced
620:bf574fb3efa0 621:6826731ff2be
272 272
273 } 273 }
274 274
275 void InitMotionDetection(void) 275 void InitMotionDetection(void)
276 { 276 {
277 float sensorPitch = settingsGetPointer()->viewPitch - 180.0; /* calib values are stored as 360° values. Sensor uses +/- 180° */
277 sectorDetection.target = 0; 278 sectorDetection.target = 0;
278 sectorDetection.current = 0; 279 sectorDetection.current = 0;
279 sectorDetection.size = 0; 280 sectorDetection.size = 0;
280 sectorDetection.count = 0; 281 sectorDetection.count = 0;
281 282
282 switch(settingsGetPointer()->MotionDetection) 283 switch(settingsGetPointer()->MotionDetection)
283 { 284 {
284 case MOTION_DETECT_SECTOR: DefinePitchSectors(settingsGetPointer()->viewPitch,CUSTOMER_DEFINED_VIEWS); 285 case MOTION_DETECT_SECTOR: DefinePitchSectors(sensorPitch,CUSTOMER_DEFINED_VIEWS);
285 MapCVToSector(); 286 MapCVToSector();
286 break; 287 break;
287 case MOTION_DETECT_MOVE: DefinePitchSectors(settingsGetPointer()->viewPitch,SECTOR_MAX); 288 case MOTION_DETECT_MOVE: DefinePitchSectors(sensorPitch,SECTOR_MAX);
288 break; 289 break;
289 case MOTION_DETECT_SCROLL: DefinePitchSectors(settingsGetPointer()->viewPitch,SECTOR_SCROLL); 290 case MOTION_DETECT_SCROLL: DefinePitchSectors(sensorPitch,SECTOR_SCROLL);
290 break; 291 break;
291 default: 292 default:
292 break; 293 break;
293 } 294 }
294 295
529 530
530 void calibrateViewport(float roll, float pitch, float yaw) 531 void calibrateViewport(float roll, float pitch, float yaw)
531 { 532 {
532 SSettings* pSettings = settingsGetPointer(); 533 SSettings* pSettings = settingsGetPointer();
533 534
534 pSettings->viewPitch = pitch; 535 pSettings->viewPitch = pitch + 180;
535 pSettings->viewRoll = roll; 536 pSettings->viewRoll = roll+ 180;
536 pSettings->viewYaw = yaw; 537 pSettings->viewYaw = yaw;
537 } 538 }
538 539
539 540
540 float checkViewport(float roll, float pitch, float yaw) 541 float checkViewport(float roll, float pitch, float yaw)
558 SCoord resultVec; 559 SCoord resultVec;
559 SDeltaHistory test; 560 SDeltaHistory test;
560 561
561 SSettings* pSettings = settingsGetPointer(); 562 SSettings* pSettings = settingsGetPointer();
562 563
564 roll += 180;
565 pitch += 180;
566
563 /* calculate base vector taking calibration delta into account yaw (heading) */ 567 /* calculate base vector taking calibration delta into account yaw (heading) */
564 float compYaw = yaw + pSettings->viewYaw; 568 float compYaw;
565 569
566 compYaw = 360.0 - yaw; /* turn to 0° */ 570 compYaw = 360.0 - yaw; /* turn to 0° */
567 compYaw += pSettings->viewYaw; /* consider calib yaw value */ 571 compYaw += pSettings->viewYaw; /* consider calib yaw value */
568 compYaw += yaw; 572 compYaw += yaw;
569 573