chrono::synchrono::SynEnvironmentAgent Class Reference


Agent that manages lanes and light changes for a traffic intersection.

Transmits messages to receiving vehicle agents about the current state of the intersection that is managed

#include <SynEnvironmentAgent.h>

Inheritance diagram for chrono::synchrono::SynEnvironmentAgent:
Collaboration diagram for chrono::synchrono::SynEnvironmentAgent:


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

Public Member Functions

 SynEnvironmentAgent (int rank, ChSystem *system=0)
 Construct a new Syn Environment Agent object, only need one for the simulation. More...
 ~SynEnvironmentAgent ()
virtual void Advance (double time_of_next_sync) override
 Advance the state of this vehicle agent until agent time syncs with passed time.
virtual void InitializeZombie (ChSystem *system=0) override
 Initialize this agents zombie representation. More...
virtual void SynchronizeZombie (SynMessage *message) override
 Synchronize this agents zombie with the rest of the simulation. More...
virtual void GenerateMessagesToSend (std::vector< SynMessage * > &messages) override
 Generate vector of SynMessages to send.
virtual std::shared_ptr< SynMessageStateGetState () override
 Environments have no state as such, they have state for SPAT + MAP.
virtual std::shared_ptr< SynAgentMessageGetMessage () override
 Get the this agent's message to be pass to other ranks. More...
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. More...
void SetColor (int intersection, int approach, int lane, LaneColor color)
- Public Member Functions inherited from chrono::synchrono::SynAgent
 SynAgent (unsigned int rank, SynAgentType type, ChSystem *system=nullptr)
 Construct a agent with the specified rank and type. More...
virtual ~SynAgent ()
virtual void ProcessMessage (SynMessage *msg)
 Process an incoming message. More...
void SetVisualizationManager (std::shared_ptr< SynVisualizationManager > vis_manager)
 Set the VisualizationManager for this agent.
std::shared_ptr< SynBrainGetBrain ()
 Get/Set this agent's brain.
void SetBrain (std::shared_ptr< SynBrain > brain)
unsigned int GetRank ()
 Get/Set this agent's rank.
void SetRank (unsigned int rank)
ChSystemGetSystem ()
 Get/Set the Chrono system associated with this agent.
void SetSystem (ChSystem *system)
double GetStepSize ()
 Get/Set this agent's step size.
void SetStepSize (double step_size)
SynAgentType GetType () const
 Get the type of this agent.

Additional Inherited Members

- Static Public Member Functions inherited from chrono::synchrono::SynAgent
static rapidjson::Document ParseAgentFileJSON (const std::string &filename)
 Parse an agent json specification file. More...
- Protected Attributes inherited from chrono::synchrono::SynAgent
unsigned int m_rank
 agent rank
SynAgentType m_type
 agent type
double m_step_size
 Step size of the underlying agent.
std::shared_ptr< SynBrainm_brain
 handle to this agent's brain
std::shared_ptr< SynVisualizationManagerm_vis_manager
 handle to this agent's visualization manager
 pointer to the Chrono system

Constructor & Destructor Documentation

◆ SynEnvironmentAgent()

chrono::synchrono::SynEnvironmentAgent::SynEnvironmentAgent ( int  rank,
ChSystem system = 0 

Construct a new Syn Environment Agent object, only need one for the simulation.

rankCurrent rank the agent is at
systemThe Chrono system the agent is in.

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.

lanelane information
colorcurrent color of the lane
behaviourIndicates 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.
The lane's position in that Approach

◆ GetMessage()

std::shared_ptr< SynAgentMessage > chrono::synchrono::SynEnvironmentAgent::GetMessage ( )

Get the this agent's message to be pass to other ranks.


Implements chrono::synchrono::SynAgent.

◆ InitializeZombie()

void chrono::synchrono::SynEnvironmentAgent::InitializeZombie ( ChSystem system = 0)

Initialize this agents zombie representation.

Will use the passed system if agent system is null.

Implements chrono::synchrono::SynAgent.

◆ SetColor()

void chrono::synchrono::SynEnvironmentAgent::SetColor ( int  intersection,
int  approach,
int  lane,
LaneColor  color 
laneThe lane's position in that approach, returned in AddLane

◆ SynchronizeZombie()

void chrono::synchrono::SynEnvironmentAgent::SynchronizeZombie ( SynMessage message)

Synchronize this agents zombie with the rest of the simulation.

Updates agent based on specified message.

Implements chrono::synchrono::SynAgent.

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_synchrono/agent/SynEnvironmentAgent.h
  • /builds/uwsbel/chrono/src/chrono_synchrono/agent/SynEnvironmentAgent.cpp