Skip to main content
. 2017 Mar 21;17(3):649. doi: 10.3390/s17030649
Algorithm 3. Five-step turn detection algorithm.
Input: Angle value sequence θ = [θ1,θ2,θn]
Output: Direction change list U.
1: θmaxFindpeaks(θ)/* Find the local maximum sequence
2: for θi in θmax do
3: if (θi>15 or θi<15) and (i>2) then
4:   θsum = sum[θi2:θi+2]
5: if (θsum>30 and θsum60) then
6:   U.add(Go left)
7: else if (θsum>60 and θsum120) then
8:   U.add(Turn left)
9: else if (θsum>60 and θsum30) then
10:   U.add(Go right)
11: else if (θsum>120 and θsum60) then
12:   U.add(Turn right)
13: else if (θsum>120 or θsum120) then
14   U.add(Turn around)
15: end for
16: return U