Thunderbots Project
Loading...
Searching...
No Matches
ErForceSimulator Class Reference

#include <er_force_simulator.h>

Public Member Functions

 ErForceSimulator (const TbotsProto::FieldType &field_type, const RobotConstants_t &robot_constants, std::unique_ptr< RealismConfigErForce > &realism_config, const bool ramping=false, double primitive_executor_time_step_s=DEFAULT_SIMULATOR_TICK_RATE_SECONDS_PER_TICK)
 
void setBallState (const BallState &ball_state)
 
void setYellowRobots (const std::vector< RobotStateWithId > &robots)
 
void setBlueRobots (const std::vector< RobotStateWithId > &robots)
 
void setRobots (const std::vector< RobotStateWithId > &robots, gameController::Team team)
 
void setRobots (const google::protobuf::Map< uint32_t, TbotsProto::RobotState > &robots, gameController::Team side)
 
void setWorldState (const TbotsProto::WorldState &world_state)
 
void setYellowRobotPrimitiveSet (const TbotsProto::PrimitiveSet &primitive_set_msg, std::unique_ptr< TbotsProto::World > world_msg)
 
void setBlueRobotPrimitiveSet (const TbotsProto::PrimitiveSet &primitive_set_msg, std::unique_ptr< TbotsProto::World > world_msg)
 
void stepSimulation (const Duration &time_step)
 
std::vector< TbotsProto::RobotStatus > getBlueRobotStatuses () const
 
std::vector< TbotsProto::RobotStatus > getYellowRobotStatuses () const
 
std::vector< SSLProto::SSL_WrapperPacket > getSSLWrapperPackets () const
 
world::SimulatorState getSimulatorState () const
 
Field getField () const
 
Timestamp getTimestamp () const
 
void resetCurrentTime ()
 

Static Public Member Functions

static std::unique_ptr< RealismConfigErForce > createDefaultRealismConfig ()
 
static std::unique_ptr< RealismConfigErForce > createRealisticRealismConfig ()
 

Detailed Description

The ErForceSimulator abstracts away the physics simulation of all objects in the world, as well as the firmware simulation for the robots. This provides a simple interface to setup, run, and query the current state of the simulation.

Constructor & Destructor Documentation

◆ ErForceSimulator()

ErForceSimulator ( const TbotsProto::FieldType &  field_type,
const RobotConstants_t robot_constants,
std::unique_ptr< RealismConfigErForce > &  realism_config,
const bool  ramping = false,
double  primitive_executor_time_step_s = DEFAULT_SIMULATOR_TICK_RATE_SECONDS_PER_TICK 
)
explicit

Creates a new Simulator. The starting state of the simulation will have the given field, with no robots or ball.

Parameters
field_typeThe field type
robot_constantsThe robot constants
realism_configrealism configuration

Member Function Documentation

◆ createDefaultRealismConfig()

std::unique_ptr< RealismConfigErForce > createDefaultRealismConfig ( )
static

Creates the default realism config using erforce simulator's default config

Returns
a pointer to default realism config

◆ createRealisticRealismConfig()

std::unique_ptr< RealismConfigErForce > createRealisticRealismConfig ( )
static

Creates the realistic realism config

Returns
a pointer to realistic realism config

◆ getBlueRobotStatuses()

std::vector< TbotsProto::RobotStatus > getBlueRobotStatuses ( ) const

Gets the blue and yellow robot statuses

Returns
a vector of robot statuses from either blue or yellow robots

◆ getField()

Field getField ( ) const

Returns the field in the simulation

Returns
the field in the simulation

◆ getSimulatorState()

world::SimulatorState getSimulatorState ( ) const

Returns the current Simulator State

◆ getSSLWrapperPackets()

std::vector< SSLProto::SSL_WrapperPacket > getSSLWrapperPackets ( ) const

Returns the most recent SSL Wrapper Packets

Returns
vector of SSLProto::SSL_WrapperPackets representing the most recent state of the simulation

◆ getTimestamp()

Timestamp getTimestamp ( ) const

Returns the current time in the simulation

Returns
the current time in the simulation

◆ resetCurrentTime()

void resetCurrentTime ( )

Resets the current time to 0

◆ setBallState()

void setBallState ( const BallState ball_state)

Sets the state of the ball in the simulation. No more than 1 ball may exist in the simulation at a time. If a ball does not already exist, a ball is added with the given state. If a ball already exists, it's state is set to the given state.

Parameters
ball_stateThe new ball state

◆ setWorldState()

void setWorldState ( const TbotsProto::WorldState &  world_state)

Set the world state from a WorldState proto in the simulation.

Parameters
world_stateThe new WorldState

◆ setYellowRobotPrimitiveSet()

void setYellowRobotPrimitiveSet ( const TbotsProto::PrimitiveSet &  primitive_set_msg,
std::unique_ptr< TbotsProto::World >  world_msg 
)

Sets the primitive being simulated by the robot on the corresponding team in simulation

Parameters
primitive_set_msgThe set of primitives to run on the robot
world_msgThe world message

◆ setYellowRobots()

void setYellowRobots ( const std::vector< RobotStateWithId > &  robots)

Adds robots to the specified team with the given initial states.

Precondition
The robot IDs must not be duplicated and must not match the ID of any robot already on the specified team.
Exceptions
runtime_errorif any of the given robot ids are duplicated, or a robot already exists on the specified team with one of the new IDs
Parameters
robotsthe robots to add

◆ stepSimulation()

void stepSimulation ( const Duration time_step)

Advances the simulation by the given time step.

Parameters
time_stephow much to advance the simulation by

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