{
  "id": 332386,
  "title": "IMU -> Orientation",
  "url": "/competitions/smartphone-decimeter-2022/discussion/332386",
  "author_name": "",
  "post_date": "2022-06-21T13:06:53.591510400Z",
  "votes": 7,
  "comment_count": 8,
  "views": 0,
  "content": "<p>I am trying to calculate the yaw with reference to the following contribution<br>\n<a href=\"https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964\" target=\"_blank\">https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964</a></p>\n<p>Have you been able to calculate the orientation from the acc and mag as suggested by your host?<br>\nI tried to get the orientation from the following equation, but I am having trouble.</p>\n<p>$$ roll = \\arctan\\frac{acc_y}{acc_z} $$<br>\n$$ pitch = \\arctan\\frac{-acc_x}{sqrt(acc_y ^ 2 + acc_z^ 2)} $$</p>\n<p>$$ cr = cos(roll)\\qquad  sr = sin(roll)\\qquad cp = cos(pitch)\\qquad sp = sin(pitch) $$<br>\n$$ yaw = \\arctan\\frac{- cr * mag_y + sr * mag_z}{cp * mag_x + sp * sr * mag_y + sp * cr * mag_z} $$</p>\n<p>The yaw angle is not exact.<br>\nAny advice would be appreciated.</p>",
  "messages": [
    {
      "id": "1828044",
      "postDate": "06/21/2022 13:06:53",
      "content": "<p>I am trying to calculate the yaw with reference to the following contribution<br>\n<a href=\"https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964\" target=\"_blank\">https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964</a></p>\n<p>Have you been able to calculate the orientation from the acc and mag as suggested by your host?<br>\nI tried to get the orientation from the following equation, but I am having trouble.</p>\n<p>$$ roll = \\arctan\\frac{acc_y}{acc_z} $$<br>\n$$ pitch = \\arctan\\frac{-acc_x}{sqrt(acc_y ^ 2 + acc_z^ 2)} $$</p>\n<p>$$ cr = cos(roll)\\qquad  sr = sin(roll)\\qquad cp = cos(pitch)\\qquad sp = sin(pitch) $$<br>\n$$ yaw = \\arctan\\frac{- cr * mag_y + sr * mag_z}{cp * mag_x + sp * sr * mag_y + sp * cr * mag_z} $$</p>\n<p>The yaw angle is not exact.<br>\nAny advice would be appreciated.</p>",
      "rawMarkdown": "I am trying to calculate the yaw with reference to the following contribution\nhttps://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964\n\nHave you been able to calculate the orientation from the acc and mag as suggested by your host?\nI tried to get the orientation from the following equation, but I am having trouble.\n\n$$ roll = \\arctan\\\\frac{acc_y}{acc_z} $$\n$$ pitch = \\arctan\\\\frac{-acc_x}{sqrt(acc_y ^ 2 + acc_z^ 2)} $$\n\n$$ cr = cos(roll)\\qquad  sr = sin(roll)\\qquad cp = cos(pitch)\\qquad sp = sin(pitch) $$\n$$ yaw = \\arctan\\\\frac{- cr * mag_y + sr * mag_z}{cp * mag_x + sp * sr * mag_y + sp * cr * mag_z} $$\n\nThe yaw angle is not exact.\nAny advice would be appreciated.",
      "votes": null
    },
    {
      "id": "1829142",
      "postDate": "06/22/2022 11:00:00",
      "content": "<p>Magnetometer have very unprecise values. If you want to use it, you need first to calibrate source values. Even after that the values will be far from perfect (something like 20 degrees average error). You can easily get YAW orientation from Doppler speeds, so do not waste your time on magnetometer</p>",
      "rawMarkdown": "Magnetometer have very unprecise values. If you want to use it, you need first to calibrate source values. Even after that the values will be far from perfect (something like 20 degrees average error). You can easily get YAW orientation from Doppler speeds, so do not waste your time on magnetometer",
      "votes": null
    },
    {
      "id": "1830161",
      "postDate": "06/23/2022 08:15:59",
      "content": "<p>Thank you for your reply.</p>\n<p>Thank you for your very informative pointers.<br>\nI will try to calculate the yaw angle from the Doppler velocity!<br>\n(I don't understand much about Doppler velocity, so I will look into it.)</p>\n<p>This is not the main point, but where would be the effective use of imu? Can you remove outliers in angular velocity, etc.?</p>",
      "rawMarkdown": "Thank you for your reply.\n\nThank you for your very informative pointers.\nI will try to calculate the yaw angle from the Doppler velocity!\n(I don't understand much about Doppler velocity, so I will look into it.)\n\nThis is not the main point, but where would be the effective use of imu? Can you remove outliers in angular velocity, etc.?",
      "votes": null
    },
    {
      "id": "1830309",
      "postDate": "06/23/2022 10:42:11",
      "content": "<p>If you have current state - car orientation and velocity - you can predict next point with help of IMU (you will need accelerometer and gyroscope data)<br>\nAt least I hope so (I am still far from good solution of this task)<br>\nSo theoretically yes, if you have correct state you can detect outliers<br>\nFor correct state (orientation and velocity) you will need two consecutive measurements, so with help of IMU you can detect is 3 consecutive points correct or not</p>",
      "rawMarkdown": "If you have current state - car orientation and velocity - you can predict next point with help of IMU (you will need accelerometer and gyroscope data)\nAt least I hope so (I am still far from good solution of this task)\nSo theoretically yes, if you have correct state you can detect outliers\nFor correct state (orientation and velocity) you will need two consecutive measurements, so with help of IMU you can detect is 3 consecutive points correct or not",
      "votes": null
    },
    {
      "id": "1838332",
      "postDate": "06/30/2022 12:22:46",
      "content": "<p>Some thoughts about using \\( acc_x \\) , etc. :</p>\n<ul>\n<li><p>For the roll/pitch formulas to be useful, the IMU acceleration values must be in the absence of phone acceleration (i.e. at constant velocity or at rest).  You could try some averaging or other technique to determine what these values are.  Constant acceleration values can only give you orientation up to 1 degree of freedom, which is why you need something else (like magnetometer) to get the full orientation.</p></li>\n<li><p>You should be careful about the axis definitions.  For example, I think that the y-axis on the phone is out the top and your pitch definition would therefore imply that the side of the phone is pointing forward.  </p></li>\n<li><p>You might want to look at this notebook that uses the Mahony filter:<br>\n<a href=\"https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu\" target=\"_blank\">https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu</a></p></li>\n<li><p>You also need to worry about synchronization between IMU and GPS data, as discussed here.  I have been having trouble getting the two to be in alignment.<br>\n<a href=\"https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135\" target=\"_blank\">https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135</a></p></li>\n</ul>",
      "rawMarkdown": "Some thoughts about using \\\\( acc_x \\\\) , etc. :\n* For the roll/pitch formulas to be useful, the IMU acceleration values must be in the absence of phone acceleration (i.e. at constant velocity or at rest).  You could try some averaging or other technique to determine what these values are.  Constant acceleration values can only give you orientation up to 1 degree of freedom, which is why you need something else (like magnetometer) to get the full orientation.\n* You should be careful about the axis definitions.  For example, I think that the y-axis on the phone is out the top and your pitch definition would therefore imply that the side of the phone is pointing forward.  \n* You might want to look at this notebook that uses the Mahony filter:\n[https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu](https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu)\n\n* You also need to worry about synchronization between IMU and GPS data, as discussed here.  I have been having trouble getting the two to be in alignment.\n[https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135](https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135)",
      "votes": null
    },
    {
      "id": "1838906",
      "postDate": "07/01/2022 01:42:06",
      "content": "<p>Thank you for your reply.</p>\n<p>As you mentioned, I believe that the direction can be obtained by using a magnetic sensor.</p>\n<p>The coordinate axes are based on the following website<br>\n<a href=\"https://developer.android.com/guide/topics/sensors/sensors_overview\" target=\"_blank\">https://developer.android.com/guide/topics/sensors/sensors_overview</a></p>\n<p>I also tried to get direction by using Tilt module with reference to that notebook, but I am not able to get direction well due to the high noise of the magnetic sensor.<br>\n<a href=\"https://ahrs.readthedocs.io/en/latest/\" target=\"_blank\">https://ahrs.readthedocs.io/en/latest/</a></p>\n<p>So I have not been able to get to the point of taking the time stamp into account.</p>\n<p>However, as for the yaw angle, I believe it can be obtained from the Doppler shift. So I believe the advantage of imu is that we can get the data in high frequency, not in direction.</p>\n<p>I think it is significant to work on imu, because there are few examples of top-level solutions from last year that utilize imu.</p>",
      "rawMarkdown": "Thank you for your reply.\n\nAs you mentioned, I believe that the direction can be obtained by using a magnetic sensor.\n\nThe coordinate axes are based on the following website\nhttps://developer.android.com/guide/topics/sensors/sensors_overview\n\nI also tried to get direction by using Tilt module with reference to that notebook, but I am not able to get direction well due to the high noise of the magnetic sensor.\nhttps://ahrs.readthedocs.io/en/latest/\n\nSo I have not been able to get to the point of taking the time stamp into account.\n\nHowever, as for the yaw angle, I believe it can be obtained from the Doppler shift. So I believe the advantage of imu is that we can get the data in high frequency, not in direction.\n\nI think it is significant to work on imu, because there are few examples of top-level solutions from last year that utilize imu.",
      "votes": null
    },
    {
      "id": "1839474",
      "postDate": "07/01/2022 12:53:02",
      "content": "<p>How would you get yaw angle from Doppler velocity?  The Doppler velocity is the speed and direction of the phone in Earth Coordinates.  Could you clarify how you would any orientation information directly from that?</p>",
      "rawMarkdown": "How would you get yaw angle from Doppler velocity?  The Doppler velocity is the speed and direction of the phone in Earth Coordinates.  Could you clarify how you would any orientation information directly from that?",
      "votes": null
    },
    {
      "id": "1839778",
      "postDate": "07/01/2022 17:25:33",
      "content": "<p>I see from your other post that by yaw you mean direction of travel</p>",
      "rawMarkdown": "I see from your other post that by yaw you mean direction of travel",
      "votes": null
    },
    {
      "id": "1840391",
      "postDate": "07/02/2022 08:02:03",
      "content": "<p>The use of the word \"yaw\" may have been inaccurate.<br>\n(yaw = direction of travel)</p>\n<p>My notebook assumes that the y-axis of the mobile phone is aligned with the z-axis of the car (the direction of gravity of the car).</p>\n<p>As you commented in your notebook, there is much room for correction.</p>",
      "rawMarkdown": "The use of the word \"yaw\" may have been inaccurate.\n(yaw = direction of travel)\n\nMy notebook assumes that the y-axis of the mobile phone is aligned with the z-axis of the car (the direction of gravity of the car).\n\nAs you commented in your notebook, there is much room for correction.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1829142,
      "author_name": "ielenik",
      "author_url": "",
      "post_date": "06/22/2022 11:00:00",
      "content": "<p>Magnetometer have very unprecise values. If you want to use it, you need first to calibrate source values. Even after that the values will be far from perfect (something like 20 degrees average error). You can easily get YAW orientation from Doppler speeds, so do not waste your time on magnetometer</p>",
      "votes": null,
      "replies": [
        {
          "id": 1830161,
          "author_name": "tyonemoto",
          "author_url": "",
          "post_date": "06/23/2022 08:15:59",
          "content": "<p>Thank you for your reply.</p>\n<p>Thank you for your very informative pointers.<br>\nI will try to calculate the yaw angle from the Doppler velocity!<br>\n(I don't understand much about Doppler velocity, so I will look into it.)</p>\n<p>This is not the main point, but where would be the effective use of imu? Can you remove outliers in angular velocity, etc.?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1830309,
          "author_name": "ielenik",
          "author_url": "",
          "post_date": "06/23/2022 10:42:11",
          "content": "<p>If you have current state - car orientation and velocity - you can predict next point with help of IMU (you will need accelerometer and gyroscope data)<br>\nAt least I hope so (I am still far from good solution of this task)<br>\nSo theoretically yes, if you have correct state you can detect outliers<br>\nFor correct state (orientation and velocity) you will need two consecutive measurements, so with help of IMU you can detect is 3 consecutive points correct or not</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1838332,
      "author_name": "solverworld",
      "author_url": "",
      "post_date": "06/30/2022 12:22:46",
      "content": "<p>Some thoughts about using \\( acc_x \\) , etc. :</p>\n<ul>\n<li><p>For the roll/pitch formulas to be useful, the IMU acceleration values must be in the absence of phone acceleration (i.e. at constant velocity or at rest).  You could try some averaging or other technique to determine what these values are.  Constant acceleration values can only give you orientation up to 1 degree of freedom, which is why you need something else (like magnetometer) to get the full orientation.</p></li>\n<li><p>You should be careful about the axis definitions.  For example, I think that the y-axis on the phone is out the top and your pitch definition would therefore imply that the side of the phone is pointing forward.  </p></li>\n<li><p>You might want to look at this notebook that uses the Mahony filter:<br>\n<a href=\"https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu\" target=\"_blank\">https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu</a></p></li>\n<li><p>You also need to worry about synchronization between IMU and GPS data, as discussed here.  I have been having trouble getting the two to be in alignment.<br>\n<a href=\"https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135\" target=\"_blank\">https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135</a></p></li>\n</ul>",
      "votes": null,
      "replies": [
        {
          "id": 1838906,
          "author_name": "tyonemoto",
          "author_url": "",
          "post_date": "07/01/2022 01:42:06",
          "content": "<p>Thank you for your reply.</p>\n<p>As you mentioned, I believe that the direction can be obtained by using a magnetic sensor.</p>\n<p>The coordinate axes are based on the following website<br>\n<a href=\"https://developer.android.com/guide/topics/sensors/sensors_overview\" target=\"_blank\">https://developer.android.com/guide/topics/sensors/sensors_overview</a></p>\n<p>I also tried to get direction by using Tilt module with reference to that notebook, but I am not able to get direction well due to the high noise of the magnetic sensor.<br>\n<a href=\"https://ahrs.readthedocs.io/en/latest/\" target=\"_blank\">https://ahrs.readthedocs.io/en/latest/</a></p>\n<p>So I have not been able to get to the point of taking the time stamp into account.</p>\n<p>However, as for the yaw angle, I believe it can be obtained from the Doppler shift. So I believe the advantage of imu is that we can get the data in high frequency, not in direction.</p>\n<p>I think it is significant to work on imu, because there are few examples of top-level solutions from last year that utilize imu.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1839474,
          "author_name": "solverworld",
          "author_url": "",
          "post_date": "07/01/2022 12:53:02",
          "content": "<p>How would you get yaw angle from Doppler velocity?  The Doppler velocity is the speed and direction of the phone in Earth Coordinates.  Could you clarify how you would any orientation information directly from that?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1839778,
          "author_name": "solverworld",
          "author_url": "",
          "post_date": "07/01/2022 17:25:33",
          "content": "<p>I see from your other post that by yaw you mean direction of travel</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1840391,
          "author_name": "tyonemoto",
          "author_url": "",
          "post_date": "07/02/2022 08:02:03",
          "content": "<p>The use of the word \"yaw\" may have been inaccurate.<br>\n(yaw = direction of travel)</p>\n<p>My notebook assumes that the y-axis of the mobile phone is aligned with the z-axis of the car (the direction of gravity of the car).</p>\n<p>As you commented in your notebook, there is much room for correction.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1828044": "I am trying to calculate the yaw with reference to the following contribution\nhttps://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323964\n\nHave you been able to calculate the orientation from the acc and mag as suggested by your host?\nI tried to get the orientation from the following equation, but I am having trouble.\n\n$$ roll = \\arctan\\\\frac{acc_y}{acc_z} $$\n$$ pitch = \\arctan\\\\frac{-acc_x}{sqrt(acc_y ^ 2 + acc_z^ 2)} $$\n\n$$ cr = cos(roll)\\qquad  sr = sin(roll)\\qquad cp = cos(pitch)\\qquad sp = sin(pitch) $$\n$$ yaw = \\arctan\\\\frac{- cr * mag_y + sr * mag_z}{cp * mag_x + sp * sr * mag_y + sp * cr * mag_z} $$\n\nThe yaw angle is not exact.\nAny advice would be appreciated.",
    "1829142": "Magnetometer have very unprecise values. If you want to use it, you need first to calibrate source values. Even after that the values will be far from perfect (something like 20 degrees average error). You can easily get YAW orientation from Doppler speeds, so do not waste your time on magnetometer",
    "1830161": "Thank you for your reply.\n\nThank you for your very informative pointers.\nI will try to calculate the yaw angle from the Doppler velocity!\n(I don't understand much about Doppler velocity, so I will look into it.)\n\nThis is not the main point, but where would be the effective use of imu? Can you remove outliers in angular velocity, etc.?",
    "1830309": "If you have current state - car orientation and velocity - you can predict next point with help of IMU (you will need accelerometer and gyroscope data)\nAt least I hope so (I am still far from good solution of this task)\nSo theoretically yes, if you have correct state you can detect outliers\nFor correct state (orientation and velocity) you will need two consecutive measurements, so with help of IMU you can detect is 3 consecutive points correct or not",
    "1838332": "Some thoughts about using \\\\( acc_x \\\\) , etc. :\n* For the roll/pitch formulas to be useful, the IMU acceleration values must be in the absence of phone acceleration (i.e. at constant velocity or at rest).  You could try some averaging or other technique to determine what these values are.  Constant acceleration values can only give you orientation up to 1 degree of freedom, which is why you need something else (like magnetometer) to get the full orientation.\n* You should be careful about the axis definitions.  For example, I think that the y-axis on the phone is out the top and your pitch definition would therefore imply that the side of the phone is pointing forward.  \n* You might want to look at this notebook that uses the Mahony filter:\n[https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu](https://www.kaggle.com/code/queyrusi/orientation-filter-stop-prediction-with-imu)\n\n* You also need to worry about synchronization between IMU and GPS data, as discussed here.  I have been having trouble getting the two to be in alignment.\n[https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135](https://www.kaggle.com/competitions/smartphone-decimeter-2022/discussion/323135)",
    "1838906": "Thank you for your reply.\n\nAs you mentioned, I believe that the direction can be obtained by using a magnetic sensor.\n\nThe coordinate axes are based on the following website\nhttps://developer.android.com/guide/topics/sensors/sensors_overview\n\nI also tried to get direction by using Tilt module with reference to that notebook, but I am not able to get direction well due to the high noise of the magnetic sensor.\nhttps://ahrs.readthedocs.io/en/latest/\n\nSo I have not been able to get to the point of taking the time stamp into account.\n\nHowever, as for the yaw angle, I believe it can be obtained from the Doppler shift. So I believe the advantage of imu is that we can get the data in high frequency, not in direction.\n\nI think it is significant to work on imu, because there are few examples of top-level solutions from last year that utilize imu.",
    "1839474": "How would you get yaw angle from Doppler velocity?  The Doppler velocity is the speed and direction of the phone in Earth Coordinates.  Could you clarify how you would any orientation information directly from that?",
    "1839778": "I see from your other post that by yaw you mean direction of travel",
    "1840391": "The use of the word \"yaw\" may have been inaccurate.\n(yaw = direction of travel)\n\nMy notebook assumes that the y-axis of the mobile phone is aligned with the z-axis of the car (the direction of gravity of the car).\n\nAs you commented in your notebook, there is much room for correction."
  },
  "source": "meta"
}