# HG changeset patch # User Ideenmodellierer # Date 1612385062 -3600 # Node ID 6826731ff2be786ba3f00ac1008c2bb1f9d320c9 # Parent bf574fb3efa0d6e8648acdbd4d102f6cea40b22e 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. diff -r bf574fb3efa0 -r 6826731ff2be Discovery/Src/base.c --- a/Discovery/Src/base.c Wed Jan 27 22:12:44 2021 +0100 +++ b/Discovery/Src/base.c Wed Feb 03 21:44:22 2021 +0100 @@ -751,7 +751,7 @@ pSettings->design = 7; if(pSettings->MotionDetection == MOTION_DETECT_SECTOR) { - DefinePitchSectors(pSettings->viewPitch,CUSTOMER_DEFINED_VIEWS); + DefinePitchSectors((float)(pSettings->viewPitch - 180.0),CUSTOMER_DEFINED_VIEWS); MapCVToSector(); } } @@ -767,7 +767,7 @@ pSettings->design = 3; if(pSettings->MotionDetection == MOTION_DETECT_SECTOR) { - DefinePitchSectors(pSettings->viewPitch,CUSTOMER_DEFINED_VIEWS); + DefinePitchSectors((float)(pSettings->viewPitch - 180.0),CUSTOMER_DEFINED_VIEWS); MapCVToSector(); } } diff -r bf574fb3efa0 -r 6826731ff2be Discovery/Src/motion.c --- a/Discovery/Src/motion.c Wed Jan 27 22:12:44 2021 +0100 +++ b/Discovery/Src/motion.c Wed Feb 03 21:44:22 2021 +0100 @@ -274,6 +274,7 @@ void InitMotionDetection(void) { + float sensorPitch = settingsGetPointer()->viewPitch - 180.0; /* calib values are stored as 360° values. Sensor uses +/- 180° */ sectorDetection.target = 0; sectorDetection.current = 0; sectorDetection.size = 0; @@ -281,12 +282,12 @@ switch(settingsGetPointer()->MotionDetection) { - case MOTION_DETECT_SECTOR: DefinePitchSectors(settingsGetPointer()->viewPitch,CUSTOMER_DEFINED_VIEWS); + case MOTION_DETECT_SECTOR: DefinePitchSectors(sensorPitch,CUSTOMER_DEFINED_VIEWS); MapCVToSector(); break; - case MOTION_DETECT_MOVE: DefinePitchSectors(settingsGetPointer()->viewPitch,SECTOR_MAX); + case MOTION_DETECT_MOVE: DefinePitchSectors(sensorPitch,SECTOR_MAX); break; - case MOTION_DETECT_SCROLL: DefinePitchSectors(settingsGetPointer()->viewPitch,SECTOR_SCROLL); + case MOTION_DETECT_SCROLL: DefinePitchSectors(sensorPitch,SECTOR_SCROLL); break; default: break; @@ -531,8 +532,8 @@ { SSettings* pSettings = settingsGetPointer(); - pSettings->viewPitch = pitch; - pSettings->viewRoll = roll; + pSettings->viewPitch = pitch + 180; + pSettings->viewRoll = roll+ 180; pSettings->viewYaw = yaw; } @@ -560,8 +561,11 @@ SSettings* pSettings = settingsGetPointer(); + roll += 180; + pitch += 180; + /* calculate base vector taking calibration delta into account yaw (heading) */ - float compYaw = yaw + pSettings->viewYaw; + float compYaw; compYaw = 360.0 - yaw; /* turn to 0° */ compYaw += pSettings->viewYaw; /* consider calib yaw value */