/*1* Agent2d.h2* RVO2 Library3*4* Copyright 2008 University of North Carolina at Chapel Hill5*6* Licensed under the Apache License, Version 2.0 (the "License");7* you may not use this file except in compliance with the License.8* You may obtain a copy of the License at9*10* http://www.apache.org/licenses/LICENSE-2.011*12* Unless required by applicable law or agreed to in writing, software13* distributed under the License is distributed on an "AS IS" BASIS,14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15* See the License for the specific language governing permissions and16* limitations under the License.17*18* Please send all bug reports to <[email protected]>.19*20* The authors may be contacted via:21*22* Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha23* Dept. of Computer Science24* 201 S. Columbia St.25* Frederick P. Brooks, Jr. Computer Science Bldg.26* Chapel Hill, N.C. 27599-317527* United States of America28*29* <http://gamma.cs.unc.edu/RVO2/>30*/3132#ifndef RVO2D_AGENT_H_33#define RVO2D_AGENT_H_3435/**36* \file Agent2d.h37* \brief Contains the Agent class.38*/3940#include "Definitions.h"41#include "RVOSimulator2d.h"4243namespace RVO2D {44/**45* \brief Defines an agent in the simulation.46*/47class Agent2D {48public:49/**50* \brief Constructs an agent instance.51* \param sim The simulator instance.52*/53explicit Agent2D();5455/**56* \brief Computes the neighbors of this agent.57*/58void computeNeighbors(RVOSimulator2D *sim_);5960/**61* \brief Computes the new velocity of this agent.62*/63void computeNewVelocity(RVOSimulator2D *sim_);6465/**66* \brief Inserts an agent neighbor into the set of neighbors of67* this agent.68* \param agent A pointer to the agent to be inserted.69* \param rangeSq The squared range around this agent.70*/71void insertAgentNeighbor(const Agent2D *agent, float &rangeSq);7273/**74* \brief Inserts a static obstacle neighbor into the set of neighbors75* of this agent.76* \param obstacle The number of the static obstacle to be77* inserted.78* \param rangeSq The squared range around this agent.79*/80void insertObstacleNeighbor(const Obstacle2D *obstacle, float rangeSq);8182/**83* \brief Updates the two-dimensional position and two-dimensional84* velocity of this agent.85*/86void update(RVOSimulator2D *sim_);8788std::vector<std::pair<float, const Agent2D *> > agentNeighbors_;89size_t maxNeighbors_;90float maxSpeed_;91float neighborDist_;92Vector2 newVelocity_;93std::vector<std::pair<float, const Obstacle2D *> > obstacleNeighbors_;94std::vector<Line> orcaLines_;95Vector2 position_;96Vector2 prefVelocity_;97float radius_;98float timeHorizon_;99float timeHorizonObst_;100Vector2 velocity_;101float height_ = 0.0;102float elevation_ = 0.0;103uint32_t avoidance_layers_ = 1;104uint32_t avoidance_mask_ = 1;105float avoidance_priority_ = 1.0;106107size_t id_;108109friend class KdTree2D;110friend class RVOSimulator2D;111};112113/**114* \relates Agent115* \brief Solves a one-dimensional linear program on a specified line116* subject to linear constraints defined by lines and a circular117* constraint.118* \param lines Lines defining the linear constraints.119* \param lineNo The specified line constraint.120* \param radius The radius of the circular constraint.121* \param optVelocity The optimization velocity.122* \param directionOpt True if the direction should be optimized.123* \param result A reference to the result of the linear program.124* \return True if successful.125*/126bool linearProgram1(const std::vector<Line> &lines, size_t lineNo,127float radius, const Vector2 &optVelocity,128bool directionOpt, Vector2 &result);129130/**131* \relates Agent132* \brief Solves a two-dimensional linear program subject to linear133* constraints defined by lines and a circular constraint.134* \param lines Lines defining the linear constraints.135* \param radius The radius of the circular constraint.136* \param optVelocity The optimization velocity.137* \param directionOpt True if the direction should be optimized.138* \param result A reference to the result of the linear program.139* \return The number of the line it fails on, and the number of lines if successful.140*/141size_t linearProgram2(const std::vector<Line> &lines, float radius,142const Vector2 &optVelocity, bool directionOpt,143Vector2 &result);144145/**146* \relates Agent147* \brief Solves a two-dimensional linear program subject to linear148* constraints defined by lines and a circular constraint.149* \param lines Lines defining the linear constraints.150* \param numObstLines Count of obstacle lines.151* \param beginLine The line on which the 2-d linear program failed.152* \param radius The radius of the circular constraint.153* \param result A reference to the result of the linear program.154*/155void linearProgram3(const std::vector<Line> &lines, size_t numObstLines, size_t beginLine,156float radius, Vector2 &result);157}158159#endif /* RVO2D_AGENT_H_ */160161162