<jupyter_start><jupyter_text>RobotManager Tests<jupyter_code>service_client_get_map = rospy.ServiceProxy('/static_map', GetMap)
map_response = service_client_get_map()
models_folder_path = rospkg.RosPack().get_path('simulator_setup')
robot_yaml = os.path.join(models_folder_path, 'robot', "myrobot.model.yaml")
from task_generator.robot_manager import RobotManager
from rl_agent.utils.observation_collector import ObservationCollector

# namespace convention: *simulation ns*/*robot name*/*data topic*
# robot1 namespace: '/sim_1/test1/...' e.g. '/sim_1/test1/goal', '/sim_1/test1/odom' etc.

# robot1 = RobotManager(ns='sim_1', map_=map_response.map, robot_yaml_path=robot_yaml, robot_name='test1')
# robot2 = RobotManager(ns='sim_1', map_=map_response.map, robot_yaml_path=robot_yaml, robot_name='test2')
robot_list = [RobotManager(ns='eval_sim', map_=map_response.map, robot_yaml_path=robot_yaml, robot_name=f'robot{i+1}') for i in range(12)]
from task_generator.marl_tasks import get_MARL_task

# number of static and dynamic obstacles still hardcoded for this task mode
task_manager = get_MARL_task(
    "eval_sim", "random", robot_names=[f'robot{i+1}' for i in range(12)], PATHS={}
)
for robot in robot_list:
    robot.set_start_pos_goal_pos()
# sets random start and goal position and returns the poses
start_pos_1, goal_pos_1 = robot1.set_start_pos_goal_pos()
start_pos_2, goal_pos_2 = robot2.set_start_pos_goal_pos()
print(f"{goal_pos_1}\n{goal_pos_2:}")<jupyter_output>x: 8.391000373288989
y: -1.9499998949468136
theta: 1.1753860034784536
x: 3.6660002507269382
y: 2.7750002276152372
theta: 0.7659632563102519<jupyter_text>TASK MANAGER TESTS<jupyter_code>from task_generator.marl_tasks import get_MARL_task

# number of static and dynamic obstacles still hardcoded for this task mode
task_manager = get_MARL_task(
    "sim_1", "random", robot_names=["test1", "test2"]
)
# generates random dynamic and static obstacle configurations as well as
# random start and goal pose
task_manager.reset()<jupyter_output><empty_output><jupyter_text>DRL AGENT CLASS TESTS<jupyter_code>DEFAULT_HYPERPARAMETER = os.path.join(
    rospkg.RosPack().get_path("arena_local_planner_drl"),
    "configs",
    "hyperparameters",
    "default.json",
)
from rl_agent.training_agent_wrapper import TrainingDRLAgent

agent1 = TrainingDRLAgent(
    ns="sim_1", 
    robot_name="test1",
    hyperparameter_path=DEFAULT_HYPERPARAMETER,
)
agent2 =TrainingDRLAgent(
    ns="sim_1", 
    robot_name="test2",
    hyperparameter_path=DEFAULT_HYPERPARAMETER,
)
# in order to retrieve the first observation, manually call the StepWorld service
# as follows: rosservice call /sim_1/step_world "0.1"  
agent1.get_observations()
agent_list = [agent1, agent2]

from rl_agent.envs.pettingzoo_env import FlatlandPettingZooEnv

env = FlatlandPettingZooEnv(ns="sim_1", agent_list=agent_list)
import numpy as np
env.reset()
merged_obs, rewards, dones, infos = env.step({"test1": np.array([0.3, 2.0]), "test2": np.array([0.3, 2.0])})<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup