Skip to main content
. 2024 Feb 21;9(3):126. doi: 10.3390/biomimetics9030126
Algorithm 1 Obstacle collision model

Input: xoreci,yoreci, lenoreci, widoreci, α, xociri,yociri, rociri

Output: The distances measured by the three distance sensors to the nearest obstacles ds, dl, dr.

  • 1:

    Obtain the line-segment model of the range sensors and the line-segment model of each obstacle PoPs, PoPl, PoPr.

  • 2:

    For rectangular obstacles i, the set of boundary models is AiBi,AiDi,CiBi,CiDi, whose slope and intercept are kji and cji, j=AB,AD,CB,CD.

  • 3:

    Determine whether PoPs and AiBi,AiDi,CiBi,CiDi are parallel.

  • 4:

    if parallel then

  • 5:

        It indicates no intersection points.

  • 6:

    else

  • 7:

        Calculate the intersection point xc,yc=cjiclklkji,klcjiclklkji+cl, and obtain the distance dl.

  • 8:

    end if

  • 9:

    Sequentially verify whether the intersection point lies on the two intersecting line segments simultaneously.

  • 10:

    if True then

  • 11:

        Output dl.

  • 12:

    else

  • 13:

        It indicates safety.

  • 14:

    end if

  • 15:

    For circular obstacle i,

  • 16:

    if  PlOcir>rociri then

  • 17:

        It indicates safety.

  • 18:

    else

  • 19:

        Compute the intersection points between the line and the circle and determine the one closer to the robot as the obstacle intersection point. Next, obtain the distance dl.

  • 20:

    end if

  • 21:

    Verify whether the intersection point lies on the line segment.

  • 22:

    if True then

  • 23:

        Output dl.

  • 24:

    else

  • 25:

        It indicates safety.

  • 26:

    end if

  • 27:

    For the forward and right sensors, use the same steps as the left sensor.