Struct Agent

Struct Documentation

struct Agent

Class representing an agent in the simulation.

This class defines the properties and behaviors of an agent, such as its position, velocity, and shape. Agents can interact with each other and navigate through the environment based on a driving force.

Public Functions

Agent(unsigned ID, std::vector<unsigned> Ids_shapes, unsigned nb_shapes, const std::vector<double2> &delta_gtos, const std::vector<double> &radius_shapes, double theta_body_init, double mass, double moi)

Constructor for the Agent class.

Parameters:
  • ID -- The ID of the agent.

  • Ids_shapes -- The Ids of the shapes

  • nb_shapes -- The number of shapes.

  • delta_gtos -- Vector the shapes' positions relative to the agent's center of mass.

  • radius_shapes -- Vector of shape radii.

  • theta_body_init -- The initial orientation of the agent's body.

  • mass -- The mass of the agent.

  • moi -- The moment of inertia of the agent.

~Agent()

Destructor for the Agent class.

This destructor is responsible for cleaning up any resources allocated by an Agent object. It is automatically called when an Agent object goes out of scope or is explicitly deleted.

void move()

Moves the agent based on its velocity and angular velocity.

This function updates the position and orientation of the agent based on its current velocity (_vx, _vy) and angular velocity (_w). The movement is performed over a small time interval (dt).

inline double2 get_r()

The method gets the current position of the agent.

Returns:

The position in cartesian coordinates as a double2

inline double2 get_v()

The method gets the current velocity of the agent.

Returns:

The velocity in cartesian coordinates as a double2

std::vector<double2> get_delta_gtos()

Calculates the current relative positions of the shapes.

Based on the current orientation of the agent wrt the x-axis, this function gives the relative positions of the agent's shapes.

Returns:

The updated relative positions of the shapes

Public Members

const unsigned _id

Agent id.

const double _mass

Mass.

const double _moi

Moment of inertia.

const std::vector<unsigned> _ids_shapes

List of ids of the shapes of the agent.

const double _radius

Equivalent radius for repulsive force.

const unsigned _nb_shapes

Number of shapes of the agent.

std::vector<double2> _delta_gtos

List of vector from the center of mass G to the center of each physical shape (disc)

const std::vector<double> _radius_shapes

The radii of the agent's shapes

const double _theta_init

The initial value of the agent's orientation, derived from the relative positions of its shapes in the Agents XML file.

double _x

x-component of the center of mass

double _y

y-component of the center of mass

double _theta

Orientation of the agent.

double _vx

x-component of the velocity of the center of mass

double _vy

y-component of the velocity of the center of mass

double _w

Angular velocity of the agent.

double2 _Fp

Driving force on the agent, with the dimension of an acceleration.

double _vx_des

x-component of the desired velocity of the agent

double _vy_des

y-component of the desired velocity of the agent

double _w_des

Desired angular velocity of the agent.

double _theta_des

Desired orientation of the agent (orientation of the desired velocity)

std::list<unsigned> _neighbours

List of neighbours.

std::list<std::pair<unsigned, unsigned>> _neighbours_walls

List of neighbouring walls.