Commit cfe4aa87 authored by Nicola Gatto's avatar Nicola Gatto
Browse files

Convert received types and reduce sleep time

parent be267fbf
......@@ -151,7 +151,6 @@ class RosEnvironment(Environment):
def reset(self):
self.__in_reset = True
time.sleep(0.5)
reset_message = Bool()
reset_message.data = True
self.__waiting_for_state_update = True
......@@ -187,7 +186,8 @@ class RosEnvironment(Environment):
next_state = self.__last_received_state
terminal = self.__last_received_terminal
reward = <#if config.hasRosRewardTopic()>self.__last_received_reward<#else>self.__calc_reward(next_state, terminal)</#if>
rospy.logdebug('Calculated reward: {}'.format(reward))
logger.debug('Transition: ({}, {}, {}, {})'.format(action, reward, next_state, terminal))
return next_state, reward, terminal, 0
......@@ -206,25 +206,24 @@ class RosEnvironment(Environment):
else:
rospy.logerr("Timeout 3 times in a row: Terminate application")
exit()
time.sleep(100/1000)
time.sleep(1/500)
def close(self):
rospy.signal_shutdown('Program ended!')
def __state_callback(self, data):
self.__last_received_state = np.array(data.data, dtype='float32').reshape((<#list config.stateDim as d>${d},</#list>))
rospy.logdebug('Received state: {}'.format(self.__last_received_state))
logger.debug('Received state: {}'.format(self.__last_received_state))
self.__waiting_for_state_update = False
def __terminal_state_callback(self, data):
self.__last_received_terminal = data.data
rospy.logdebug('Received terminal flag: {}'.format(self.__last_received_terminal))
logger.debug('Received terminal: {}'.format(self.__last_received_terminal))
self.__last_received_terminal = np.bool(data.data)
logger.debug('Received terminal flag: {}'.format(self.__last_received_terminal))
self.__waiting_for_terminal_update = False
<#if config.hasRosRewardTopic()>
def __reward_callback(self, data):
self.__last_received_reward = float(data.data)
self.__last_received_reward = np.float32(data.data)
logger.debug('Received reward: {}'.format(self.__last_received_reward))
self.__waiting_for_reward_update = False
<#else>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment