def __init__(self,
                TARGETS = ['SM_Plant_7','SM_Plant_8'],# you can change it for other targets
                DOCKER = True,
                ENV_NAME='RealisticRendering',
                cam_id = 0,
                MAX_STEPS = 100):
     self.cam_id = cam_id
     self.target_list = TARGETS

     if DOCKER:
         self.docker = run_docker.RunDocker()
         env_ip, env_dir = self.docker.start(ENV_NAME = ENV_NAME)
         self.unrealcv = UnrealCv(self.cam_id, ip=env_ip, targets=self.target_list, env=env_dir)
     else:
         self.docker = False
         #you need run the environment previously
         env_ip = '127.0.0.1'
         self.unrealcv = UnrealCv(self.cam_id, ip=env_ip, targets=self.target_list)

     print env_ip


     self.reward_th = 0.2
     self.trigger_th = 0.9

     self.origin = [
         (-106.195,  437.424,   40),
         (  27.897, -162.437,   40),
         ( -66.601,   -4.503,   40),
         (  10.832,  135.126,   40),
         (  67.903,   26.995,   40),
         ( -23.558, -187.354,   40),
         ( -80.312,  254.579,   40),
     ]

     self.count_steps = 0
     self.max_steps = MAX_STEPS
     self.action = (0,0,0) #(velocity,angle,trigger)

     self.targets_pos = self.unrealcv.get_objects_pos(self.target_list)
     self.trajectory = []

     state = self.unrealcv.read_image(self.cam_id, 'lit')

     #self.action_space = spaces.Discrete(len(self.ACTION_LIST))
     self.action_space = spaces.Box(low = 0,high = 100, shape = self.action)
     self.observation_space = spaces.Box(low=0, high=255, shape=state.shape)

     self.trigger_count  = 0
Beispiel #2
0
 def __init__(
     self,
     ENV_NAME='RealisticRendering'  # if use your own environment,please change it
 ):
     self.cam_id = 0
     # run virtual enrionment in docker container
     self.docker = run_docker.RunDocker()
     env_ip, env_dir = self.docker.start(ENV_NAME=ENV_NAME)
     # connect unrealcv client to server
     self.unrealcv = UnrealCv(self.cam_id, ip=env_ip, env=env_dir)
     self.startpose = self.unrealcv.get_pose()
     # ACTION: (linear velocity ,angle velocity)
     self.ACTION_LIST = [
         (20, 0),
         (20, 15),
         (20, -15),
         (20, 30),
         (20, -30),
     ]
     self.count_steps = 0
     self.max_steps = 100
     self.target_pos = (-60, 0, 50)
     self.action_space = gym.spaces.Discrete(len(self.ACTION_LIST))
     state = self.unrealcv.read_image(self.cam_id, 'lit')
     self.observation_space = gym.spaces.Box(low=0,
                                             high=255,
                                             shape=state.shape)
Beispiel #3
0
    def __init__(
        self,
        setting_file,
        test,  # if True will use the test_xy as start point
        timeDependent,
        action_type,  # 'discrete', 'continuous'
        observation_type,  # 'color', 'depth', 'rgbd'
        reward_type  # distance, bbox, bbox_distance,
    ):

        self.show = False
        self.collision = False
        self.timeDependent = timeDependent
        self.target = None
        # self.dis2target_now= 100
        # self.isTargetChanged = False

        print("Reading setting file: ", setting_file)
        self.test = test
        self.action_type = action_type
        self.observation_type = observation_type
        self.reward_type = reward_type
        assert self.action_type == 'discrete' or self.action_type == 'continuous'
        assert self.observation_type == 'depth'
        setting = self.load_env_setting(setting_file)

        # connect UnrealCV
        self.unrealcv = UnrealCv(9000, self.cam_id, self.env_ip,
                                 self.message_handler)

        print("Camera_id: ", self.cam_id)
        print("Environment ip: ", self.env_ip)
        print("Observation type: ", observation_type)
        print("action_type: ", action_type)
        print("Reward type: ", reward_type)
        print("timeDependent: ", str(self.timeDependent))

        self.unrealcv.notify_connection()

        self.count_steps = 0

        # action
        if self.action_type == 'discrete':
            self.action_space = spaces.Discrete(len(self.discrete_angular))
        elif self.action_type == 'continuous':
            self.action_space = spaces.Box(
                low=np.array(self.continous_actions['low']),
                high=np.array(self.continous_actions['high']))

        # get start position
        self.startPoint = self.unrealcv.get_pose()
        self.unrealcv.get_target_point()

        while (self.target == None):
            time.sleep(0.5)

        # for reset point generation
        self.trajectory = []
        self.start_id = 0
Beispiel #4
0
    def __init__(
        self,
        setting_file,
        test,  # if True will use the test_xy as start point
        action_type,  # 'discrete', 'continuous'
        observation_type,  # 'color', 'depth', 'rgbd'
        reward_type  # distance, bbox, bbox_distance,
    ):

        self.show = True

        print("Reading setting file: ", setting_file)
        self.test = test
        self.action_type = action_type
        self.observation_type = observation_type
        self.reward_type = reward_type
        assert self.action_type == 'discrete' or self.action_type == 'continuous'
        assert self.observation_type == 'depth'
        setting = self.load_env_setting(setting_file)

        # connect UnrealCV
        self.unrealcv = UnrealCv(9000, self.cam_id, self.env_ip)

        print("Camera_id: ", self.cam_id)
        print("Environment ip: ", self.env_ip)
        print("Observation type: ", observation_type)
        print("action_type: ", action_type)
        print("Reward type: ", reward_type)

        self.unrealcv.notify_connection()
        self.unrealcv.declare_step_by_step()

        self.count_steps = 0

        #  self.targets_pos = self.target_points[0]
        #  print ("Target points: ",self.target_points)
        #  print ("The target pose: ",self.targets_pos)

        # action
        if self.action_type == 'discrete':
            self.action_space = spaces.Discrete(len(self.discrete_actions))
        elif self.action_type == 'continuous':
            self.action_space = spaces.Box(
                low=np.array(self.continous_actions['low']),
                high=np.array(self.continous_actions['high']))

        # get start position
        current_pose = self.unrealcv.get_pose()

        #  self.dis2target_now = self.get_distance(current_pose, self.targets_pos)

        # for reset point generation
        self.trajectory = []
        self.start_id = 0