From 14de5a626e9b2d8aac92adfd2bcb96d9d69fa13a Mon Sep 17 00:00:00 2001 From: Hans Haupt Date: Tue, 11 Jun 2024 17:05:22 +0200 Subject: [PATCH] updated documentation of getTilt --- src/motionDetection/MotionDetection.cpp | 4 ++-- src/motionDetection/MotionDetection.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/motionDetection/MotionDetection.cpp b/src/motionDetection/MotionDetection.cpp index fd6be8a..60b17d7 100644 --- a/src/motionDetection/MotionDetection.cpp +++ b/src/motionDetection/MotionDetection.cpp @@ -89,8 +89,8 @@ Orientation MotionDetection::getTilt(){ yAngle = atan(float(reading.x)/reading.z)*180/3.1415+0.5; xAngle = atan(float(reading.y)/reading.z)*180/3.1415+0.5; } else { - yAngle = 90; - xAngle = 90; + yAngle = 90*(reading.x > 0) - (reading.x < 0); + xAngle = 90*(reading.y > 0) - (reading.y < 0); } //shift quadrants depending on signum diff --git a/src/motionDetection/MotionDetection.h b/src/motionDetection/MotionDetection.h index 8824c7c..3e84458 100644 --- a/src/motionDetection/MotionDetection.h +++ b/src/motionDetection/MotionDetection.h @@ -144,10 +144,11 @@ public: /** * @brief calculates how the robot is tilted. It is set, that when the robot is placed normally on a flat table, the result will be (0,0) - * Tilting the robot, so that the front leg is deeper than the other to results in an increasing value, tilting the front leg up will let the value jump to 359 and then decreasing - * Tilting the robot to the right (..) will increase the value, tilting it left will jump to 359 and then decreased. + * Tilting the robot, so that the front leg is deeper than the other to results in an increasing degrees, tilting the front leg up will increase negativ degrees + * Tilting the robot to the right will increase the degrees until 180° (upside down), tilting it left will result in increasing negativ degrees (-1,-2,...,-180). + * On the top there is a jump of the values from 180->-180 and vice versa. * - * Precision is rounded to 1deg steps + * Precision is rounded to 1 deg steps * * @attention The results are only valid, if the robot is not moved in any way during the measurment, as the calculation is made by using the accelration values. * If it's detected, that the robot is accelerated while measuring, the method will return max(uint).