Package populus :: Module SteerLibrary :: Class SteerLibraryMixIn
[frames] | no frames]

Class SteerLibraryMixIn


This is a mixin that contains steering functions. It is meant to extended a base motion model to create a new base class for a steering agent. Do not instantiate this class, it can't stand by its own.

Instance Methods
 
__init__(self)
 
convertForceIntoCosts(self, force)
This function is meant for converting the most common result of a steering function into the correspondent result of an inverse steering function.
 
initSetOfCosts(self, c=0.0, m=1.0)
Create and initialize a set of costs for later user.
 
spanDirections(self, spanning)
This function return a subset of isb directions indexes spanned by a fan centered along the forward axis with angular extension spannig.
 
steerForArrival(self, target, slowing_distance)
This steering function compute a desired velocity toward the target.
 
steerForAvoidObstacle(self, obstaclePos, obstacleRadius, minTimeToCollision=5.0, radius=None)
This steering function compute a desired direction to motivate an agent in avoiding a potential collision with an obstacle.
 
steerForAvoidObstacles(self, obstacleGroup, numObstacles, minTimeToCollision=5.0, radius=None)
This steering function compute a desired direction to motivate an agent in avoiding a potential collision with a group of obstacles.
 
steerForAvoidObstaclesNEW(self, obstacleGroup, numObstacles, minTimeToCollision=5.0, radius=None, spanning=210.0)
Steer for Avoid Obstacles with Inverse Steering Behaviors.
 
steerForCohesion(self, neighborhood, numNeighbors, point=None, distance_offset=0)
This steering function compute a cohesion force that motivate and agent in moving toward its neighborhood to avoid being isolated.
 
steerForFacing(self, neighborhood, numNeighbors)
This steering function compute a desired direction to rotate an agent in order to make it face the neighborhood.
 
steerForFlee(self, target)
This steering function compute a desired velocity away from a given target.
 
steerForKeepGroupSpace(self, neighborhood, numNeighbors, minDistance, maxDistance)
This steering function compute a group space force that motivates an agent in keeping a mean equal distance from the neighborhood central point.
 
steerForMinDistance(self, neighborhood, numNeighbors, maxDistance)
This steering function compute a repulsion force away from a group of given neighbors.
 
steerForSeek(self, target)
This steering function compute a desired velocity toward a given target.
Static Methods
 
addCost(set, cost, magnitude=1.0)
Add a new entry with cost and magnitude to a set of costs.
 
getCost(set, index)
Get the cost of an entry at index in the set of costs.
 
getMagnitude(set, index)
Get the magnitude of an entry at index in the set of costs.
 
setCost(set, index, cost)
Set the cost of the entry at index in the set of costs.
 
setMagnitude(set, index, magnitude)
Set the magnitude of the entry at index in the set of costs.
Method Details

convertForceIntoCosts(self, force)

 

This function is meant for converting the most common result of a steering function into the correspondent result of an inverse steering function. Given a motivational force towad a goal, this function assigns costs to isb directions based on the angular distance between them and the optimistic optimal (normalized force). Use this function to convert the result of a steering function or as building block for inverse steering functions.

initSetOfCosts(self, c=0.0, m=1.0)

 

Create and initialize a set of costs for later user. Set c and m if you want to initialize the set with a particular cost and magnitude.

spanDirections(self, spanning)

 

This function return a subset of isb directions indexes spanned by a fan centered along the forward axis with angular extension spannig. Notice that this function return a list of indexes and not directions.

steerForArrival(self, target, slowing_distance)

 

This steering function compute a desired velocity toward the target. The velocity starts to diminish as soon as the slowing_distance is reached producing a smooth arrival to the target point.

steerForAvoidObstacle(self, obstaclePos, obstacleRadius, minTimeToCollision=5.0, radius=None)

 

This steering function compute a desired direction to motivate an agent in avoiding a potential collision with an obstacle. The obstacle must be enclosed in a bounding sphere. In order to detect a potential threat, a collision rectangular probe is defined in front of the agent. Avoidance force tries to keep that rectangular area free from the obstacle.

steerForAvoidObstacles(self, obstacleGroup, numObstacles, minTimeToCollision=5.0, radius=None)

 

This steering function compute a desired direction to motivate an agent in avoiding a potential collision with a group of obstacles. The avoidence force is computed only for the nearest obstacle. Each obstacle must be enclosed in a bounding sphere. In order to detect a potential threat, a collision rectangular probe is defined in front of the agent. Avoidance force tries to keep that rectangular area free from obstacles.

NOTE1: obstacles in this implementation are intended as *fixed* (speed == 0) and *sparse* (dist between two of them > minDist)

NOTE2: extension to different obstacle shapes is mandatory. For fixed obstacles such as walls and stairs we could have a representation of them on grid map as in Terzoupolus (Autonoumus Pedestrian)

VERY IMPORTANT NOTE: this IS NOT the best way of performing collision avoidance. The main reason is that avoidance force depends only from the position of the nearest obstacle. What if this force will drive the agent toward another obstacle? Possible solutions are Inverse Steering Behaviors or flow dynamic.

steerForCohesion(self, neighborhood, numNeighbors, point=None, distance_offset=0)

 

This steering function compute a cohesion force that motivate and agent in moving toward its neighborhood to avoid being isolated. Differently from Reynolds version, here is possible to specify a particular attraction point if necessary. An attraction point will turn useful when the agent is member of a static group instead of a moving one, eg. conversations, queues, etc. Setup a distance offset to set an attraction area instead of an attraction point. Basically, the agent will try to reach the edge of the circle of center point (or neighborhood's center) and radius distance_offset.

steerForFacing(self, neighborhood, numNeighbors)

 

This steering function compute a desired direction to rotate an agent in order to make it face the neighborhood. That is, to have the best orientation for facing as much as possible the group of neighbors.

steerForKeepGroupSpace(self, neighborhood, numNeighbors, minDistance, maxDistance)

 

This steering function compute a group space force that motivates an agent in keeping a mean equal distance from the neighborhood central point. The mean distance is the mean of neighbors' distances from the group's center. Therefore, the group space force could be an attractive or repulsive force depending from the agent's position. Min and max distances are used to specify the min and max allowed distances from the group's center.

steerForMinDistance(self, neighborhood, numNeighbors, maxDistance)

 

This steering function compute a repulsion force away from a group of given neighbors. The given maxDistance is the radius of the neighborhood. The magnitude of the resulting force depends from the maxDistance and the distance of the closest neighbor.