Environment/LASEnv.py
def step(self, action):
        """
        Take one step of interaction.
        
        Parameters
        ----------
        action: ndarray
            action[0: smas_num] are action corresponding to sma
            action[smas_num: end] are action corresponding to light color
        
        Returns
        -------
        observation: ndarray
            obervation of environment after taking an action
        reward: float
            reward after taking an action
        done: bool
            whether simulation is done or not.
        info:
            some information for debugging
        """
        # To imporove system's robustness, we need to just ignore this action
        # rather than throw an exception.
        if np.sum(np.isnan(action)) != 0:
            Tracer()()
            raise ValueError("Find nan value in action!")
        # Clip action to avoid improer action command
        action = np.clip(action, self.act_min, self.act_max)
        action = (action + 1) / 2.0
        # Split action for light and sma
        action_smas = action[:self.smas_num]
        action_lights_color = action[self.smas_num:]
        # Taking action

        #vrep.simxPauseCommunication(self.clientID,True)     #temporarily halting the communication thread 
        self._set_all_joint_position(action_smas)
        # Actually only set light color
        self._set_all_light_state_and_color(action_lights_color)
        #vrep.simxPauseCommunication(self.clientID,False)    #and evaluated at the same time

        # Set a small sleep time to avoid getting nan sensor data
        time.sleep(0.01)

        #vrep.simxPauseCommunication(self.clientID,True)     #temporarily halting the communication thread 
        self._set_all_joint_position(action_smas)
        # Actually only set light color
        self._set_all_light_state_and_color(action_lights_color)
        #vrep.simxPauseCommunication(self.clientID,False)    #and evaluated at the same time
        #self.action_history.append(action_lights_color)  # Only consider light actions for now

        # Observe current state
        try:
            self.observation = self._self_observe()
        except ValueError:
            self._nanObervationFlag = 1
            print("Observation has NAN value.")
#        # Caculate reward
#        self.reward = self._reward(self.observation)
        
        # This reward is non-interactive reward i.e. it's not affected by visitor.
        # Therefore, it's only used for tunning hyper-parameters of LASAgent
        if self.reward_function_type == 'red_light_sparse':
            self.reward = self._reward_red_light_sparse(self.observation)
        elif self.reward_function_type == 'red_light_dense':
            self.reward = self._reward_red_light_dense(self.observation)
        else:
            raise ValueError('No reward function: {}'.format(self.reward_function_type))
        
        
        done = False
        info = []
        return self.observation, self.reward, done, info

        Take one step of interaction.
        
        Parameters
        ----------
        action: ndarray
            action[0: smas_num] are action corresponding to sma
            action[smas_num: end] are action corresponding to light color
        
        Returns
        -------
        observation: ndarray
            obervation of environment after taking an action
        reward: float
            reward after taking an action
        done: bool
            whether simulation is done or not.
        info:
            some information for debugging
        
Take one step of interaction.
Parameters

ndarray
action[0: smas_num] are action corresponding to sma
action[smas_num: end] are action corresponding to light color

Returns

ndarray
obervation of environment after taking an action
reward: float
reward after taking an action
done: bool
whether simulation is done or not.
info:
some information for debugging
Take one step of interaction . Parameters ndarray action [ 0 : smas_num ] are action corresponding to sma action [ smas_num : end ] are action corresponding to light color Returns ndarray obervation of environment after taking an action reward : float reward after taking an action done : bool whether simulation is done or not . info : some information for debugging
def step(self, action):
        if np.sum(np.isnan(action)) != 0:
            Tracer()()
            raise ValueError("Find nan value in action!")
        action = np.clip(action, self.act_min, self.act_max)
        action = (action + 1) / 2.0
        action_smas = action[:self.smas_num]
        action_lights_color = action[self.smas_num:]
        self._set_all_joint_position(action_smas)
        self._set_all_light_state_and_color(action_lights_color)
        time.sleep(0.01)
        self._set_all_joint_position(action_smas)
        self._set_all_light_state_and_color(action_lights_color)
        try:
            self.observation = self._self_observe()
        except ValueError:
            self._nanObervationFlag = 1
            print("Observation has NAN value.")
        if self.reward_function_type == 'red_light_sparse':
            self.reward = self._reward_red_light_sparse(self.observation)
        elif self.reward_function_type == 'red_light_dense':
            self.reward = self._reward_red_light_dense(self.observation)
        else:
            raise ValueError('No reward function: {}'.format(self.reward_function_type))
        done = False
        info = []
        return self.observation, self.reward, done, info
def step ( self , action ) : if np . sum ( np . isnan ( action ) ) != 0 : Tracer ( ) ( ) raise ValueError ( "Find nan value in action!" ) action = np . clip ( action , self . act_min , self . act_max ) action = ( action + 1 ) / 2.0 action_smas = action [ : self . smas_num ] action_lights_color = action [ self . smas_num : ] self . _set_all_joint_position ( action_smas ) self . _set_all_light_state_and_color ( action_lights_color ) time . sleep ( 0.01 ) self . _set_all_joint_position ( action_smas ) self . _set_all_light_state_and_color ( action_lights_color ) try : self . observation = self . _self_observe ( ) except ValueError : self . _nanObervationFlag = 1 print ( "Observation has NAN value." ) if self . reward_function_type == 'red_light_sparse' : self . reward = self . _reward_red_light_sparse ( self . observation ) elif self . reward_function_type == 'red_light_dense' : self . reward = self . _reward_red_light_dense ( self . observation ) else : raise ValueError ( 'No reward function: {}' . format ( self . reward_function_type ) ) done = False info = [ ] return self . observation , self . reward , done , info
Take one step of interaction.
Take one step of interaction .
"""
        Take one step of interaction.
        
        Parameters
        ----------
        action: ndarray
            action[0: smas_num] are action corresponding to sma
            action[smas_num: end] are action corresponding to light color
        
        Returns
        -------
        observation: ndarray
            obervation of environment after taking an action
        reward: float
            reward after taking an action
        done: bool
            whether simulation is done or not.
        info:
            some information for debugging
        """ # To imporove system's robustness, we need to just ignore this action # rather than throw an exception. # Clip action to avoid improer action command # Split action for light and sma # Taking action #vrep.simxPauseCommunication(self.clientID,True)     #temporarily halting the communication thread  # Actually only set light color #vrep.simxPauseCommunication(self.clientID,False)    #and evaluated at the same time # Set a small sleep time to avoid getting nan sensor data #vrep.simxPauseCommunication(self.clientID,True)     #temporarily halting the communication thread  # Actually only set light color #vrep.simxPauseCommunication(self.clientID,False)    #and evaluated at the same time #self.action_history.append(action_lights_color)  # Only consider light actions for now # Observe current state #        # Caculate reward #        self.reward = self._reward(self.observation) # This reward is non-interactive reward i.e. it's not affected by visitor. # Therefore, it's only used for tunning hyper-parameters of LASAgent
self
action