We follow the gym API for the environments. To accommodate for multi-agent setups we provide all outputs in a batched format. In the future, we plan to support direct integrations for RLLib and PyMARL APIs.
To get details about the configurable parameters for an environment we provide helper functions. We are working on more detailed documentation for the environments:
from sdriving.environments import REGISTRY, get_parameter_list
# To get the list of available environments run
print("\n".join(list(REGISTRY.keys())))
# To get help regarding a particular environment
# print(get_parameter_list(<environment name>))
print(
get_paramter_list(
"MultiAgentNuscenesIntersectionBicycleKinematicsDiscreteEnvironment"
)
)
To perform a rollout simply follow this pseudocode
env = REGISTRY[<env name>](<parameters>)
# Reset the environment.
# By default we don't reset the environment on instantiation.
# This must be done to add the vehicles to the environment.
obs = env.reset()
done_all = False
while not done_all:
action = <custom policy to get action>
# Batch the action for all agents into `actions`
# Note the difference from gym API. We return an id corresponding
# to which agents are in the environment
# For BiLevel environments, one needs to pass stage value which
# is either 0/1
(obs, agent_ids), reward, dones, info = env.step(action, <stage>)
# dones is a boolean tensor of length = # of agents
done_all = dones.all()