ARTIFICIAL INTELLIGENCE
Lecturer: Silja Renooij
Motion
Utrecht University The Netherlands
These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
ARTIFICIAL INTELLIGENCE Motion Lecturer: Silja Renooij These slides - - PowerPoint PPT Presentation
Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Motion Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html Outline Move in 2D
These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
– 2D / 3D vector
– (=‘facing’) radians
– (= speed in direction) 2D / 3D vector
– (= change in orientation) radians
character #kinematic data character target #kinematic data target maxSpeed #maximum speed of character def getSteering(): steering = new KinematicSteeringOutput() steering.velocity = target.position – character.position # direction of target steering.velocity.normalize() steering.velocity *= maxSpeed # full speed in direction character.orientation = getNewOrientation(character.orientation,steering.velocity) # face in direct. of move steering.rotation = 0 return steering
character #kinematic data character target #kinematic data target input Seek maxSpeed #maximum speed of character radius #satisfaction radius (‘found’ target) timeToTarget = 0.25 #goal: get to target in 0.25s input Arrive def getSteering(): steering = new KinematicSteeringOutput() steering.velocity = target.position – character.position if steering.velocity.length() < radius: return None #arrived! steering.velocity /= timeToTarget #speed=distance/time if steering.velocity.length() > maxSpeed: #unless above max steering.velocity.normalize() steering.velocity *= maxSpeed character.orientation = getNewOrientation(character.orientation,steering.velocity) steering.rotation = 0 return steering
Character # kinematic data character target # kinematic data target input Seek maxAcceleration # maximum acceleration maxSpeed # maximum speed of character targetRadius # satisfaction radius input Arrive slowRadius # radius to slow down timeToTarget = 0.1 # 0.1s to achieve target velocity def getSteering(target): steering = new SteeringOutput() direction = target.position – character.position distance = direction.length() if distance < targetRadius: return None # arrived! if distance > slowRadius: targetSpeed = maxSpeed # move with maxspeed else targetSpeed = maxSpeed * distance / slowRadius # slow down if close targetVelocity = direction targetVelocity.normalize() targetVelocity *= targetSpeed steering.linear = target.position – character.position # only for Seek; remove for Arrive steering.linear = target.velocity – character.velocity # accelerate to target velocity steering.linear /=timeToTarget if steering.linear.length() > maxAcceleration: steering.linear.normalize() steering.linear *= maxAcceleration steering.angular = 0 return steering
direction, velocity rotation position orientation distance rotationSize steering.linear steering.angular
Character # kinematic data character target # kinematic data target maxAcceleration # maximum acceleration maxSpeed # maximum speed of character maxRotation # maximum rotation targetRadius # satisfaction radius slowRadius # radius to slow down timeToTarget = 0.1
# 0.1s to achieve target velocity
def getSteering(target): steering = new SteeringOutput() steering.linear = target.velocity – character.velocity steering.linear /=timeToTarget if steering.linear.length() > maxAcceleration: steeringlinear.normalize() steering.linear *= maxAcceleration steering.angular = 0 return steering
character targets threshold # threshold to take action decayCoefficient # constant for decay maxAcceleration def getSteering(): steering = new Steering for target in targets: direction = target.position – character.position distance = direction.length() target is too close if distance < threshold: strength = min(decayCoefficient / (distance ^2), maxAcceleration) #repulsion strength direction.normalize() steering.linear += strength * direction add acceleration return steering
Single ray Multiple rays Multiple rays
One ray Two whiskers
target Seek target avoid enemy 1 avoid enemy 2 enemy 2 enemy 1 Wall avoidance result pursue
trapped (do nothing) lost target