Steering Behaviors for Autonomous Agents - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Steering Behaviors for Autonomous Agents

Description:

http://www.red3d.com/cwr/steer/Obstacle.html. How it works (from Reynolds, Buckland) ... then transforms all the tagged obstacles into the vehicle's local ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 27
Provided by: bdug1
Category:

less

Transcript and Presenter's Notes

Title: Steering Behaviors for Autonomous Agents


1
Steering Behaviors for Autonomous Agents
  • Bryan Duggan

2
Spherical containment?
  • Create the feelers
  • Take the default look vector depth of the
    feeler
  • Rotate it to create left, right ( Y Axis - yaw),
    up and down (X Axis - pitch) feelers
  • Transform to world space ( the world transform)
  • Find out if each feeler penetrates the sphere
  • Calculate the distance from the centre to the
    feeler
  • If gt radius then
  • Calculate the normal
  • (feeler centre) and normalise
  • Calculate the force
  • n (radius distance)
  • Do this for each feeler and sum the forces

3
(No Transcript)
4
  • // Check if any of the feelers penetrate the
    world sphere
  • for (int i 0 i lt 3 i )
  • float dist D3DXVec3Length( (centre -
    feeleri))
  • if (dist gt radius)
  • D3DXVECTOR3 normal
  • D3DXVec3Normalize( normal , (feeleri -
    centre ))
  • D3DXVECTOR3 feelerForce normal (radius -
    dist)
  • force feelerForce

5
Obstacle avoidance
  • Steers a vehicle to avoid obstacles lying in its
    path.
  • Any object that can be approximated by a circle
    or sphere
  • This is achieved by steering the vehicle so as to
    keep a rectangular area a detection box,
    extending forward from the vehicle free of
    collisions.
  • The detection box's width is equal to the
    bounding radius of the vehicle, and its length is
    proportional to the vehicle's current speed the
    faster it goes, the longer the detection box.
  • http//www.red3d.com/cwr/steer/Obstacle.html

6
How it works (from Reynolds, Buckland)
  • The vehicle should only consider those obstacles
    within range of its detection box.
  • Initially, the obstacle avoidance algorithm
    iterates through all the obstacles in the game
    world and tags those that are within this range
    for further consideration.
  • The algorithm then transforms all the tagged
    obstacles into the vehicle's local space.
  • This makes life much easier as after
    transformation any objects with a negative local
    X-coordinate can be dismissed.

7
  • The algorithm now has to check to see if any
    obstacles overlap the detection box.
  • Local coordinates are useful here as all you need
    to do is expand the bounding radius of an
    obstacle by half the width of the detection
    cylinder (the vehicle's bounding radius) and then
    check to see if its local Y value is smaller than
    this value. Need a Z check also for 3D?
  • If it isn't, then it won't intersect the
    detection box and can subsequently be discarded
    from further consideration.

8
(No Transcript)
9
  • At this point there are only those obstacles
    remaining that intersect the detection box.
  • It's now necessary to find the intersection point
    closest to the vehicle.
  • A simple line/circle intersection test can be
    used to find where the expanded circle intersects
    the x-axis.
  • There will be two intersection points, as shown
    in Figure 3.8.
  • We don't have to worry about the case where there
    is one intersection tangent to the circle the
    vehicle will appear to just glance off the
    obstacle.
  • Note that it is possible to have an obstacle in
    front of the vehicle, but it will have an
    intersection point to the rear of the vehicle.
    This is shown in the figure by obstacle A.
  • The algorithm discards these cases and only
    considers intersection points laying on the
    positive x-axis.
  • The algorithm tests all the remaining obstacles
    to find the one with the closest (positive)
    intersection point.

10
(No Transcript)
11
  • //the detection box length is proportional to the
    agent's velocity
  • m_dDBoxLength Prm.MinDetectionBoxLength
    (m_pVehicle-gtSpeed()/m_pVehicle-gtMaxSpeed())
    Prm.MinDetectionBoxLength

12
  • //if the distance from the x axis to the object's
    position is less
  • //than its radius half the width of the
    detection box then there
  • //is a potential intersection.
  • double ExpandedRadius (curOb)-gtBRadius()
    m_pVehicle-gtBRadius()
  • if (fabs(LocalPos.y) lt ExpandedRadius)
  • //now to do a line/circle intersection test.

13
  • //calculate this obstacle's position in local
    space
  • Vector2D LocalPos PointToLocalSpace((curOb)-gtPo
    s(), m_pVehicle-gtHeading(), m_pVehicle-gtSide(),
    m_pVehicle-gtPos())
  • //if the local position has a negative x value
    then it must lay
  • //behind the agent. (in which case it can be
    ignored)
  • if (LocalPos.x gt 0)

14
Calculating the force
15
In 3D
  • The box becomes a cylinder
  • When implementing obstacle avoidance in three
    dimensions, use spheres to approximate the
    obstacles and a cylinder in place of the
    detection box. The math to check against a sphere
    is not that much different than that to check
    against a circle. Once the obstacles have been
    converted into local space, steps A and B are the
    same as you have already seen, and step C just
    involves checking against another axis.

16
More considerations
  • To do the distance calculation?
  • What is local space?
  • How do the axis change?
  • To translate to local space?
  • What happens to spheres?
  • What happens to the box?
  • Do we need a cylinder?

17
Cylinder Sphere intersection
  • The curve formed by the intersection of a
    cylinder and a sphere is known as Viviani's
    curve.

18
  • The easiest way to determine the solution is to
    solve the simultaneous equations

19
But...
  • Reynolds/Buckland solves this using a line and a
    circle!!
  • Can we solve it with a Ray Sphere?
  • I think so!!

20
A Ray/Sphere intersection
  • 3 possibilities
  • No intersection
  • 1 intersection
  • 2 intersections

21
Spheres
  • The equation of a sphere is
  • x2 y2 z2 r2
  • If p is a point on the sphere, you can write the
    vector form of a sphere equation
  • p.p r2
  • If we call the centre point c, then we can write
  • (p c).(p - c) r2
  • OR
  • (p c).(p - c) - r2 0

22
Recall
  • A ray is
  • p(t) p0 tu
  • We again want to find the value for t, so we can
    substitute into the ray equation
  • So the ray plane intersection is given by
  • (p0 tu c).(p0 tu - c) - r2 0
  • OR
  • (tu p0 c).(tu p0 - c) - r2 0
  • To solve this, we would like to get the equation
    into the form of a quadratic equation
  • At2 Bt c
  • If we do, we can use

23
Solution to a quadratic equation
If the Discriminant is- 0 there is exactly one
root - Positive there are 2 real roots -
Negative there are 2 imaginary roots
The Discriminant
24
So how do we do it??
  • (tu p0 c).(tu p0 - c) - r2 0
  • Dot product is distributive
  • a.(b c) a.b a.c
  • (a b).(a c) aa ac ba bc
  • So
  • (tu p0 c).(tu p0 - c) - r2 0
  • Becomes

25
  • (tu p0 c).(tu p0 - c) - r2 0
  • tu.tu tu.(p0 c) (p0 c).tu (p0 c).(p0
    c) - r2
  • Which becomes
  • u.ut2 2u(p0 pc)t (p0 c).(p0 c) - r2

26
So
  • a u.u
  • b 2u(p0 pc)
  • c (p0 c).(p0 c) - r2
  • Discriminant b2 4ac
  • If (Discriminant lt 0)
  • Return false
  • Else
  • Calculate 1 or 2 values for t
  • Calculate 2 or 1 point by substituting into ray
    equation
  • p(t) p0 tu
Write a Comment
User Comments (0)
About PowerShow.com