Usage Example
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"
)
)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()Last updated