Example #1
0
    def worldKiller(self, id):

        req = InstructionCommandRequest()
        req.instruction = "die"

        response = serverClient(req, "/magna/Worlds/die", InstructionCommand)

        self.world_spawner_launch.shutdown()
Example #2
0
    def worldGetFSPset(self, fspset_path):

        req = WorldGetFSPsetRequest()
        req.fspset_path = json.dumps(fspset_path)

        response = serverClient(req, "/magna/Worlds/get_fspset",
                                WorldGetFSPset)

        return response.fspset
Example #3
0
    def sendsendNewFlightplanToGS(self, ids, poses_list):

        req = UTMnotificationRequest()
        req.instruction = json.dumps({"action": "new flightplan", "ids": ids})
        req.goal_path_poses_list = poses_list

        response = serverClient(req, "/magna/utm/notification",
                                UTMnotification)

        return response
Example #4
0
    def GazeboModelsKiller(self):
        for n_agent in np.arange(self.N_agents):
            model_name = "{0}_{1}".format(self.agent_models[n_agent],
                                          n_agent + 1)

            response = serverClient(model_name, 'gazebo/delete_model',
                                    DeleteModel)
            time.sleep(0.1)

        return
Example #5
0
    def worldAdd(self, world_part_definition):

        if world_part_definition == "from_hyperparameters":
            world_part_definition = [{
                "name": "JSON",
                "world": self.world_name,
                "subworld": self.subworld_name
            }]

        req = InstructionCommandRequest()
        req.instruction = json.dumps(world_part_definition)

        response = serverClient(req, "/magna/Worlds/add", InstructionCommand)

        return response
Example #6
0
    def sendNotificationsToAgents(self, agents_list, message):
        if type(agents_list) == int:
            agents_list = [agents_list]

        msg = InstructionCommandRequest()

        for agent in agents_list:

            msg.instruction = message
            print(agent, msg)

            response = serverClient(
                msg, '/magna/GS_Agent_{}/notification'.format(agent),
                InstructionCommand)

        return "completed"
Example #7
0
    def AlgorithmControlCommand(self, agents_list, name, action, params,
                                values):

        if type(agents_list) == int:
            agents_list = [agents_list]

        for agent in agents_list:

            request = AlgorithmControlRequest()
            request.name = name
            request.params = params
            request.action = action
            request.values = values

            response = serverClient(
                request, '/magna/GS_Agent_{}/algorithm_control'.format(agent),
                AlgorithmControl)

        return "completed"
Example #8
0
    def SimulationTerminationCommand(self):

        response = serverClient(True, '/magna/GS/simulation_termination',
                                DieCommand)

        return