Please explain following snippet

Hello,
I tried to figure out the way imu data relates to the motion of sphero bot in course project, but couldn’t reach a conclusion. So I checked the code provided by the instructor. Unfortunately had trouble understanding the following snippet too. The snippet is from Course Project, creating service server.
Thanks!

1 Like

Hi @shiruraditya,

That code snippet is trying to figure the axis in which the crash occurred.

It’s based on the theory that the linear acceleration in that axis will be higher than the acceleration in the other axes. Try to visualize an imaginary car crashing into a wall…if the wall is strong enough so that the car didn’t break through it, the car will likely bounce back with a high acceleration in the reverse direction.

Also, when the crash axis has been found, the code tried to determine the direction (positive or negative) of the crash within the axis.

1 Like