# Using IMU data to detect ROV collisions

**URL:** <https://discuss.bluerobotics.com/t/using-imu-data-to-detect-rov-collisions/12155>\
**Category:** Blue Robotics Software\
**Tags:** ardusub, pymavlink\
**Created:** [May 20, 2022, 5:31am UTC](https://discuss.bluerobotics.com/t/using-imu-data-to-detect-rov-collisions/12155 "2022-05-20T05:31:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robotmark](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@robotmark](https://discuss.bluerobotics.com/u/robotmark)\
**Post date:** [May 20, 2022, 5:31am UTC](https://discuss.bluerobotics.com/t/using-imu-data-to-detect-rov-collisions/12155/1 "2022-05-20T05:31:14Z")

</div>

I want the ROV to move backward when it hits a fixed object, so I need to read the IMU data so THAT I can determine whether the ROV hit an object or not. I don’t know which IMU data I can use. I read the following two pieces of data about the IMU.

```auto
RAW_IMU {time_usec : 1032607166, xacc : 25, yacc : -18, zacc : -996, xgyro : 0, ygyro : -4, zgyro : -36, xmag : 119, ymag : 161, zmag : 334, id : 0, temperature : 0}
SCALED_IMU2 {time_boot_ms : 1032607, xacc : -20, yacc : -39, zacc : -976, xgyro : -2, ygyro : 7, zgyro : 9, xmag : 0, ymag : 0, zmag : 0, temperature : 0}

```

Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [May 20, 2022, 6:01am UTC](https://discuss.bluerobotics.com/t/using-imu-data-to-detect-rov-collisions/12155/2 "2022-05-20T06:01:21Z")

</div>

Hi @robotmark,

> [@robotmark](#):
>
> I don’t know which IMU data I can use.

Have you done any testing? The [MAVLink Inspector](https://www.ardusub.com/reference/qgroundcontrol/analyze-view.html#mavlink-inspector) in QGroundControl allows you to plot data live, and you can also [analyse and make plots from your telemetry data files](https://gist.github.com/ES-Alexander/1498c87ad6c07623f6776c552869c805?permalink_comment_id=3945340#gistcomment-3945340).

I expect any of [`RAW_IMU`](https://mavlink.io/en/messages/common.html#RAW_IMU), [`SCALED_IMU2`](https://mavlink.io/en/messages/common.html#SCALED_IMU2) and [`VIBRATION`](https://mavlink.io/en/messages/common.html#VIBRATION) should work fine, but you’ll need to choose one and determine reasonable thresholds based on testing with your vehicle and the kind of collisions you’re wanting to detect.

I recommend combining values from different directions to avoid the detection being orientation dependent. You can do that as a vector magnitude calculation, but for collision detection purposes it’s likely sufficient to just add together the values that you’re interested in (making sure to use calibrated sensors, of course).

---

<div class="post-metadata">

**Author:** ![robotmark](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@robotmark](https://discuss.bluerobotics.com/u/robotmark)\
**Post date:** [May 20, 2022, 10:44am UTC](https://discuss.bluerobotics.com/t/using-imu-data-to-detect-rov-collisions/12155/3 "2022-05-20T10:44:52Z")

</div>

I found the right acceleration using matplotlib, thank you very much.
