def getReward(self):
        # -1    reward for falling over
        #  0.01 reward for close to goal
        #  return reward inversely proportional to heading error otherwise
        psig = self.env.getPSIG()
                
        r_factor = 0.01
        rh_factor = 0.00001

        if np.abs(self.env.getTilt()) > self.max_tilt:
            return -1.0
        else:
            distance = self.calc_dist_to_goal()
            #heading = self.calc_angle_to_goal()
            if (distance > self.max_distance):
                print 'MAX DISTANCE REACHED'
                return -1.0
            if (distance < 1e-3):
                print 'DEBUG: GOAL REACHED'
                return 0.01
            else:
                # reward from Randlov's 1998 paper
                r1 = (4 - psig**2) * .00004
                #return (4 - psig**2) * 0.00004
                
                # reward from Randlov's C code
                #return (0.95 - heading**2) * r_factor
                
                # our own proportional reward function
                r2 =  -np.abs(self.env.getSensors()[0])
                #heading_reward = 0.1/(heading**2 + 0.1) * r_factor
                #dist_reward = -distance**2 * rh_factor
                #return 0.1/(heading**2 + 0.1) * r_factor
                #return heading_reward + dist_reward
                return r1
dataset/ETHPy150Open chrisdembia/agent-bicycle/randlov1998/tasks.py/LinearFATileCoding3476GoToTask.getReward/original