Project Chrono: chrono::synchrono::SynEnvironmentAgent Class Reference

Classes | Public Member Functions | List of all members
chrono::synchrono::SynEnvironmentAgent Class Reference
SYNCHRONO module » Agents

## Description

Derived agent class. Acts as a traffic light and distributes MAP and/or SPAT data.

`#include <SynEnvironmentAgent.h>`

Inheritance diagram for chrono::synchrono::SynEnvironmentAgent:
[legend]
Collaboration diagram for chrono::synchrono::SynEnvironmentAgent:
[legend]

## Classes
struct | LaneData
| It defines the traffic light color and schedule for one lane. More...

## Public Member Functions
| SynEnvironmentAgent (ChSystem *system)
| Default Constructor.
virtual | ~SynEnvironmentAgent ()
| Destructor.
virtual void | InitializeZombie (ChSystem *system) override
| Initialize this agents zombie representation Bodies are added and represented in the lead agent's world.
virtual void | SynchronizeZombie (std::shared_ptr< SynMessage > message) override
| Synchronize this agents zombie with the rest of the simulation.
virtual void | Update () override
| Update this agent Typically used to update the state representation of the agent to be distributed to other agents.
virtual void | GatherMessages (SynMessageList &messages) override
| Generates messages to be sent to other nodes Will create or get messages and pass them into the referenced message vector.
virtual void | GatherDescriptionMessages (SynMessageList &messages) override
| Get the description messages for this agent A single agent may have multiple description messages.
int | AddLane (int intersection, int approach, ApproachLane lane, LaneColor color, std::vector< double > behaviour)
| Add a lane to the environment, need to specify which intersection and which approach.
void | SetColor (int intersection, int approach, int lane, LaneColor color)
| Change the current color of a light at an intersection.
virtual void | SetKey (AgentKey agent_key) override
| Set the Agent ID.
Public Member Functions inherited from chrono::synchrono::SynAgent
| SynAgent (AgentKey agent_key={0, 0})
| Construct a agent with the specified node_id.
virtual | ~SynAgent ()
| Destructor.
virtual void | ProcessMessage (std::shared_ptr< SynMessage > msg)
| Process an incoming message.
virtual void | RegisterZombie (std::shared_ptr< SynAgent > zombie)
| Register a new zombie.
void | SetProcessMessageCallback (std::function< void(std::shared_ptr< SynMessage >)> callback)
int | GetID ()
AgentKey | GetKey ()

## Additional Inherited Members
Protected Attributes inherited from chrono::synchrono::SynAgent
AgentKey | m_agent_key
std::function< void(std::shared_ptr< SynMessage >)> | m_process_message_callback

## Constructor & Destructor Documentation

## ◆ SynEnvironmentAgent()

chrono::synchrono::SynEnvironmentAgent::SynEnvironmentAgent | ( | ChSystem * | system | ) |

Default Constructor.

Parameters

  system | the ChSystem used for grabbing the current sim time

## Member Function Documentation

## ◆ AddLane()

int chrono::synchrono::SynEnvironmentAgent::AddLane | ( | int | intersection,
|  | int | approach,
|  | ApproachLane | lane,
|  | LaneColor | color,
|  | std::vector< double > | behaviour )

Add a lane to the environment, need to specify which intersection and which approach.

Parameters

  intersection | particular intersection to add to
  approach | particular approach to add to
  lane | particular lane to add to
  color | current color of the lane
  behaviour | Indicates when the traffic light's color will change. If currently is RED and behaviour is {a,b,c}, it will stay RED for a seconds, switch to GREEN for b seconds, and Yellow for c seconds. Then it will switch back to RED and do the cycle again.

Returns
  The lane's position in that Approach

## ◆ GatherDescriptionMessages()

virtual void chrono::synchrono::SynEnvironmentAgent::GatherDescriptionMessages | ( | SynMessageList & | messages | ) |
| inlineoverridevirtual

Get the description messages for this agent A single agent may have multiple description messages.

Parameters

  messages | a referenced vector containing messages to be distributed from this rank

Implements chrono::synchrono::SynAgent.

## ◆ GatherMessages()

virtual void chrono::synchrono::SynEnvironmentAgent::GatherMessages | ( | SynMessageList & | messages | ) |
| inlineoverridevirtual

Generates messages to be sent to other nodes Will create or get messages and pass them into the referenced message vector.

Parameters

  messages | a referenced vector containing messages to be distributed from this rank

Implements chrono::synchrono::SynAgent.

## ◆ InitializeZombie()

void chrono::synchrono::SynEnvironmentAgent::InitializeZombie | ( | ChSystem * | system | ) |
| overridevirtual

Initialize this agents zombie representation Bodies are added and represented in the lead agent's world.

Parameters

  system | the ChSystem used to initialize the zombie

Implements chrono::synchrono::SynAgent.

## ◆ SetColor()

void chrono::synchrono::SynEnvironmentAgent::SetColor | ( | int | intersection,
|  | int | approach,
|  | int | lane,
|  | LaneColor | color )

Change the current color of a light at an intersection.

Does not alter cycles

Parameters

  intersection | which intersection has the light we want to chane the color of
  approach | which approach has the light we want to change the color of
  lane | the lane's position in that approach, returned in AddLane
  color | which color to change to

## ◆ SetKey()

void chrono::synchrono::SynEnvironmentAgent::SetKey | ( | AgentKey | agent_key | ) |
| overridevirtual

Set the Agent ID.

Reimplemented from chrono::synchrono::SynAgent.

## ◆ SynchronizeZombie()

void chrono::synchrono::SynEnvironmentAgent::SynchronizeZombie | ( | std::shared_ptr< SynMessage > | message | ) |
| overridevirtual

Synchronize this agents zombie with the rest of the simulation.

Updates agent based on the passed message. Any message can be passed, so a check should be done to ensure this message was intended for this agent.

Parameters

  message | the message to process and is used to update the position of the zombie

Implements chrono::synchrono::SynAgent.

## ◆ Update()

void chrono::synchrono::SynEnvironmentAgent::Update | ( |  | ) |
| overridevirtual

Update this agent Typically used to update the state representation of the agent to be distributed to other agents.

Implements chrono::synchrono::SynAgent.

The documentation for this class was generated from the following files:

- D:/W/B/src/chrono-9.0.1/src/chrono_synchrono/agent/SynEnvironmentAgent.h
- D:/W/B/src/chrono-9.0.1/src/chrono_synchrono/agent/SynEnvironmentAgent.cpp