Creating Custom Agent
In this tutorial, we are going to describe how to create an agent for Verse.
BaseAgent class explained
A nice example for all the necessary fields for a Verse agent is the BaseAgent class. The BaseAgent class holds the following members
idis astridentifier for the agent. It is used by interal algorithm of Verse to distinguish between different agents in the scenario.decision_logicis the parsed decision logic of the agent generated by Verse parser. It have to have typeControllerIR. Thedecision_logiccan be generated usingControllerIR.parsegiven a user defined decision logic, or can be be an trivial decision logic generated byControllerIR.empty()init_contis the set of initial continuous states for the agent. It will be used by Verse to initialize the scenario.init_discis the initial mode of the agent. It will be used by Verse to initialize the scenario.static_parametersis a set of parameters that will remain constant over the whole execution of the scenario.uncertain_parametersis the set of uncertain parameters in the agent dynamics. It is used by Verse’s algorithm for handling uncertainty in dynamics.
Besides the following functions, the BaseAgent also contains the following member functions
TC_simulateis the most import function in any agent class. As mentioned in Agent, it describe how the continuous state evolve for the agent. The only requirement forTC_simulatefunction its input and output should match the requirement described in Agent{agent}. This allows user to plug-in any simulator in to the TC_simulate function beyond Python simulation, including complicated simulators like CARLA.dynamicfunction decribe the continous dynamics of the agent. It is used by theTC_simulatefunction for theBaseAgent.set_initialsets theinit_cont,init_disc.static_parameters,uncertain_parametersof the agent.set_initial_statesets theinit_contof the agent.set_initial_modesets theinit_discof the agent.set_initial_parametersets thestatic_parametersof the agent.set_uncertain_parametersets theuncertain_parametersof the agent.
More detailed documentation for these functions can be found in the API doc below.
  | 
Agent Base class  | 
  | 
Creating custom agent
Due to the nature of Python, we allow duck typing fo the agent, i.e. an agent can be used in Verse as long as it have the proper members and member functions and the interface of the necessary functions match the requirements.
The necessary class members are
iddecision_logicinit_continit_discstatic_parametersuncertain_parameters
Their type (or behavior) should match what’s described in the previous section.
The necessary member functions are
TC_simulateset_initialset_initial_stateset_initial_modeset_static_parameterset_uncertain_parameter
Similarly, their input/output type should match what’s described in the previous section.
Any other class functions or members can be added freely to the agent class.