ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 28 Aug 2019 04:44:29 -0500IMU covariance matrix setting for robot_localizationhttps://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/Hi guys :)
I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here (http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html) this is an error:
-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) **should not be 0**. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.
Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.
So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here https://www.st.com/resource/en/datasheet/lsm6dso.pdf . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching."
The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?
Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives?
Thanks
EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md
I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:
- Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): https://github.com/GAVLab/allan_variance
- https://github.com/csvance/lsm9ds0Wed, 13 Mar 2019 06:31:07 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/Comment by ricber for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=331834#post-id-331834No one of the reasons to close a question applies to my case.Wed, 28 Aug 2019 04:44:29 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=331834#post-id-331834Comment by Tom Moore for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=331352#post-id-331352If you *do* end up solving this, please update this question and accept the answer, or just close it.Thu, 22 Aug 2019 06:26:41 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=331352#post-id-331352Comment by Tom Moore for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=324807#post-id-324807@ricber you could also normalize by the number of seconds elapsed for your N rotations, which gives you the error/sec, which is really what you wanted anyway.
If the gyro is not actively rotating, I'm not sure that you can characterize the error in it. But I'm not an expert in such things.Thu, 06 Jun 2019 02:31:52 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=324807#post-id-324807Comment by bmgatten for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=322853#post-id-322853I understand that at the end of "n" rotations, we'll end up with some error. Are you saying there's a way to back out a variance for the rotational rate from this? If so, can you explain a little more how to go about doing this?Thu, 09 May 2019 13:01:16 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=322853#post-id-322853Comment by Tom Moore for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=318820#post-id-318820My experience is that, if the sensor vendor doesn't provide the information, computing it can be black magic. Your approach seems reasonable to me. You could rotate the IMU through N full rotations in a given axis, manually integrate the velocities, and see what the final error is, and then back out the values from that.Tue, 19 Mar 2019 06:54:42 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=318820#post-id-318820Comment by ricber for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=324032#post-id-324032I was proposing to calculate the data variance just placing the IMU in a static position. With your approach, @Tom Moore, aren't you introducing an error that depends on the numerical integration, thus, depending on the frequency of measurement?Sun, 26 May 2019 09:17:16 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=324032#post-id-324032Comment by Tom Moore for <p>Hi guys :)</p>
<p> I'm trying to fuse an odometry source with the data coming from an IMU. To do this, I'm using robot_localization. I'm having difficulties in understanding how to set the covariance matrix for the IMU. At the moment, I have a covariance matrix filled with zeros. As you can read from here ( <a rel="nofollow" href="http://docs.ros.org/kinetic/api/robot_localization/html/preparing_sensor_data.html">http://docs.ros.org/kinetic/api/robot...</a> ) this is an error: </p>
<p>-> Missing covariances. If you have configured a given sensor to fuse a given variable into the state estimation node, then the variance for that value (i.e., the covariance matrix value at position (i,i), where i is the index of that variable) <strong>should not be 0</strong>. If a 0 variance value is encountered for a variable that is being fused, the state estimation nodes will add a small epsilon value (1e−6) to that value. A better solution is for users to set covariances appropriately.</p>
<p>Ok, so let's set the covariances appropriately.
I think I only have two options: calculate it or get the values from the datasheet.</p>
<p> So, let's look at the datasheet. I'm using the X-NUCLEO-IKS01A1 board with LSM6DS0 IMU. The datasheet is here <a rel="nofollow" href="https://www.st.com/resource/en/datasheet/lsm6dso.pdf">https://www.st.com/resource/en/datash...</a> . As you can see there's a table on page 9 that talks about noise, like 'Gyroscope RMS noise in normal/low-power mode', etc. But how can I relate these values to variances? I didn't find anything on the web apart from this answer here <a rel="nofollow" href="https://robotics.stackexchange.com/questions/1449/how-are-units-of-noise-measurement-related-to-units-of-a-sensors-data-measureme">https://robotics.stackexchange.com/qu...</a> where they say: "If you haven't got a background in random processes and signal analysis then you're going to have a rough time relating this back to real-world numbers, particularly if you're doing any kind of sensor fusion. Even the "big boys" in the sensor fusion game can't easily map sensor noise to system behavior without lots of simulation and head-scratching." </p>
<p>The other option is to calculate it. Again, I didn't find any standard approach to do it. I came up with the idea to just collect data for a while placing the IMU in a very firm way, then calculating the variance (so assuming the covariance matrix diagonal). Does it make sense an approach like this?</p>
<p>Moreover, do you know if there's a standard approach to set the covariance matrix? What's the complete spectrum of the alternatives? </p>
<p>Thanks</p>
<p> EDIT 26/05/19:
I have temporarily postponed solving the problem with a sound approach in a favor to a trial and error one as proposed here: <a rel="nofollow" href="https://github.com/methylDragon/ros-sensor-fusion-tutorial/blob/master/01%20-%20ROS%20and%20Sensor%20Fusion%20Tutorial.md">https://github.com/methylDragon/ros-s...</a></p>
<p>I have also found some interesting material that I still didn't have time to look at, but I would like to share with the readers hoping to be helpful:</p>
<ul>
<li><p> Allan variance method (Allan DW (1966) Statistics of atomic frequency standards.
Proceedings of the IEEE 54(2): 221–230): <a rel="nofollow" href="https://github.com/GAVLab/allan_variance">https://github.com/GAVLab/allan_variance</a></p></li>
<li><p><a rel="nofollow" href="https://github.com/csvance/lsm9ds0">https://github.com/csvance/lsm9ds0</a></p></li>
</ul>
https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=323210#post-id-323210Off the top of my head, rotating `N` times means you have an expected rotation of `2pi * N` radians (ground truth, expected value). Your integrated IMU velocity data measures `M` radians. So your error per measurement in `(M - 2pi * N) / C`, where `C` is the number measurements. So maybe try `[(M - 2pi * N) / C]^2`?Wed, 15 May 2019 03:35:32 -0500https://answers.ros.org/question/318445/imu-covariance-matrix-setting-for-robot_localization/?comment=323210#post-id-323210