delphyne
AgentSimulationBase< T > Class Template Reference

Detailed Description

template<typename T>
class delphyne::AgentSimulationBase< T >

A runnable agent-based simulation, using Drake's system framework as its backbone.

Template Parameters
Tmust be a valid Eigen ScalarType.

Instantiated templates for the following ScalarTypes are provided:

  • double

These are already available to link against in the containing library.

#include <include/delphyne/mi6/agent_simulation.h>

Public Member Functions

 AgentSimulationBase (std::unique_ptr< drake::systems::Simulator< T >> simulator, std::unique_ptr< drake::systems::Diagram< T >> diagram, std::map< std::string, std::unique_ptr< AgentBase< T >>> agents, std::unique_ptr< const maliput::api::RoadGeometry > road_geometry, drake::geometry::SceneGraph< T > *scene_graph, SceneSystem *scene_system)
 Constructs a simulation. More...
 
 AgentSimulationBase (std::unique_ptr< drake::systems::Simulator< T >> simulator, std::unique_ptr< drake::systems::Diagram< T >> diagram, std::map< std::string, std::unique_ptr< AgentBase< T >>> agents, std::unique_ptr< const maliput::api::RoadNetwork > road_network, drake::geometry::SceneGraph< T > *scene_graph, SceneSystem *scene_system)
 Constructs a simulation. More...
 
template<class AgentType >
const AgentType & GetAgentByName (const std::string &name)
 Returns a reference to the named agent of the given type. More...
 
template<template< typename U > class AgentBaseType>
const AgentBaseType< T > & GetAgentByName (const std::string &name)
 Returns a mutable reference to the named agent of the given type. More...
 
const AgentBase< T > & GetAgentByName (const std::string &name) const
 Returns a reference to the named agent. More...
 
template<class AgentType >
AgentType * GetMutableAgentByName (const std::string &name)
 Returns a mutable reference to the named agent of the given type. More...
 
template<template< typename U > class AgentBaseType>
AgentBaseType< T > * GetMutableAgentByName (const std::string &name)
 Returns a mutable reference to the named agent of the given type. More...
 
AgentBase< T > * GetMutableAgentByName (const std::string &name)
 Returns a mutable reference to the named agent. More...
 
std::unique_ptr< ignition::msgs::Scene > GetVisualScene ()
 Returns the simulation scene, full of visuals. More...
 
drake::systems::rendering::PoseBundle< T > GetCurrentPoses () const
 Returns the current poses of all agents in the simulation. More...
 
std::vector< AgentBaseCollision< T > > GetCollisions () const
 Returns all agent pairs that are currently in collision. More...
 
void SetRealTimeRate (double realtime_rate)
 Sets the real-time rate for this simulation. More...
 
double GetRealTimeRate () const
 Gets the real-time rate for this simulation. More...
 
void StepBy (const T &time_step)
 Advances simulated time by the given time_step in seconds. More...
 
const T & GetCurrentTime () const
 Returns the current simulation time in seconds. More...
 
const drake::systems::Diagram< T > & GetDiagram () const
 Gets a reference to the simulation diagram representation. More...
 
const drake::systems::Context< T > & GetContext () const
 Gets a reference to the simulation context. More...
 
drake::systems::Context< T > * GetMutableContext ()
 Gets a mutable reference to the simulation context. More...
 

Constructor & Destructor Documentation

◆ AgentSimulationBase() [1/2]

AgentSimulationBase ( std::unique_ptr< drake::systems::Simulator< T >>  simulator,
std::unique_ptr< drake::systems::Diagram< T >>  diagram,
std::map< std::string, std::unique_ptr< AgentBase< T >>>  agents,
std::unique_ptr< const maliput::api::RoadGeometry road_geometry,
drake::geometry::SceneGraph< T > *  scene_graph,
SceneSystem scene_system 
)
explicit

Constructs a simulation.

Parameters
simulatorthe Simulator instance to advance this simulation.
diagramthe Diagram representation of this simulation.
agentsall the Agents associated with this simulation.
road_geometrythe RoadGeometry associated with this simulation.
scene_grapha reference to the SceneGraph in this simulation, for all sorts of geometrical queries.
scene_systema reference to the scene composing system in this simulation

◆ AgentSimulationBase() [2/2]

AgentSimulationBase ( std::unique_ptr< drake::systems::Simulator< T >>  simulator,
std::unique_ptr< drake::systems::Diagram< T >>  diagram,
std::map< std::string, std::unique_ptr< AgentBase< T >>>  agents,
std::unique_ptr< const maliput::api::RoadNetwork road_network,
drake::geometry::SceneGraph< T > *  scene_graph,
SceneSystem scene_system 
)
explicit

Constructs a simulation.

Parameters
simulatorthe Simulator instance to advance this simulation.
diagramthe Diagram representation of this simulation.
agentsall the Agents associated with this simulation.
road_networkthe RoadNetwork associated with this simulation.
scene_grapha reference to the SceneGraph in this simulation, for all sorts of geometrical queries.
scene_systema reference to the scene composing system in this simulation

Member Function Documentation

◆ GetAgentByName() [1/3]

const AgentType& GetAgentByName ( const std::string &  name)

Returns a reference to the named agent of the given type.

Parameters
[in]nameThe name of the agent.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.
std::bad_castif the agent was found but it is not of the expected type.
Template Parameters
AgentTypeAn AgentBase<T> subclass.

◆ GetAgentByName() [2/3]

const AgentBaseType<T>& GetAgentByName ( const std::string &  name)

Returns a mutable reference to the named agent of the given type.

Parameters
[in]nameThe name of the agent.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.
std::bad_castif the agent was found but it is not of the expected type.
Template Parameters
AgentBaseTypeAn AgentBase subclass, to be specialized for T.

◆ GetAgentByName() [3/3]

const delphyne::AgentBase< T > & GetAgentByName ( const std::string &  name) const

Returns a reference to the named agent.

Parameters
[in]nameThe name of the agent.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.

◆ GetCollisions()

std::vector< AgentBaseCollision< T > > GetCollisions

Returns all agent pairs that are currently in collision.

Remarks
The order in which collision pairs are returned may vary with the collision detection backend used and thus no order is enforced. DO NOT expect nor rely on any given order.

◆ GetContext()

const drake::systems::Context<T>& GetContext ( ) const

Gets a reference to the simulation context.

◆ GetCurrentPoses()

drake::systems::rendering::PoseBundle< T > GetCurrentPoses

Returns the current poses of all agents in the simulation.

◆ GetCurrentTime()

const T& GetCurrentTime ( ) const

Returns the current simulation time in seconds.

See also
Simulator::Context::get_time.

◆ GetDiagram()

const drake::systems::Diagram<T>& GetDiagram ( ) const

Gets a reference to the simulation diagram representation.

◆ GetMutableAgentByName() [1/3]

AgentType* GetMutableAgentByName ( const std::string &  name)

Returns a mutable reference to the named agent of the given type.

Parameters
[in]nameThe name of the agent.
Returns
a pointer to the agent or nullptr if it is not of the expected type.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.
Template Parameters
AgentTypeAn AgentBase<T> subclass.

◆ GetMutableAgentByName() [2/3]

AgentBaseType<T>* GetMutableAgentByName ( const std::string &  name)

Returns a mutable reference to the named agent of the given type.

Parameters
[in]nameThe name of the agent.
Returns
a pointer to the agent or nullptr if it is not of the expected type.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.
Template Parameters
AgentBaseTypeAn AgentBase subclass, to be specialized for T.

◆ GetMutableAgentByName() [3/3]

delphyne::AgentBase< T > * GetMutableAgentByName ( const std::string &  name)

Returns a mutable reference to the named agent.

Parameters
[in]nameThe name of the agent.
Exceptions
std::runtime_errorif no agent with the given name is known by the simulator.

◆ GetMutableContext()

drake::systems::Context<T>* GetMutableContext ( )

Gets a mutable reference to the simulation context.

◆ GetRealTimeRate()

double GetRealTimeRate ( ) const

Gets the real-time rate for this simulation.

See also
systems::Simulator::get_target_realtime_rate

◆ GetVisualScene()

std::unique_ptr< ignition::msgs::Scene > GetVisualScene

Returns the simulation scene, full of visuals.

◆ SetRealTimeRate()

void SetRealTimeRate ( double  realtime_rate)

Sets the real-time rate for this simulation.

See also
systems::Simulator::set_target_realtime_rate

◆ StepBy()

void StepBy ( const T &  time_step)

Advances simulated time by the given time_step in seconds.


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