simulation_ws/src/rl-agent/markov/environments/mars_env.py [558:619]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # Calculate the distance to checkpoint
        new_distance_to_checkpoint = Float64
        new_distance_to_checkpoint.data = abs(math.sqrt(((new_position.x - CHECKPOINT_X) ** 2) +
                                                        (new_position.y - CHECKPOINT_Y) ** 2))

        if new_distance_to_checkpoint.data < self.current_distance_to_checkpoint:
            self.closer_to_checkpoint = True
        else:
            self.closer_to_checkpoint = False

        # Update the distance to checkpoint
        self.current_distance_to_checkpoint = new_distance_to_checkpoint.data

        # update the current position
        self.x = new_position.x
        self.y = new_position.y

    
    '''
    DO NOT EDIT - Function to receive Collision data from a ROSTopic
    '''
    def callback_collision(self, data):
        # Listen for a collision with anything in the environment
        collsion_states = data.states
        if len(collsion_states) > 0:
            self.collide = True

    
    '''
    DO NOT EDIT - Function to wrote episodic rewards to CloudWatch
    '''
    def send_reward_to_cloudwatch(self, reward):
        try:
            session = boto3.session.Session()
            cloudwatch_client = session.client('cloudwatch', region_name=self.aws_region)
            cloudwatch_client.put_metric_data(
                MetricData=[
                    {
                        'MetricName': 'Episode_Reward',
                        'Unit': 'None',
                        'Value': reward
                    },
                    {
                        'MetricName': 'Episode_Steps',
                        'Unit': 'None',
                        'Value': self.steps,
                    },
                    {
                        'MetricName': 'DistanceToCheckpoint',
                        'Unit': 'None',
                        'Value': self.current_distance_to_checkpoint
                    }
                ],
                Namespace='AWS_NASA_JPL_OSR_Challenge'
            )
        except Exception as err:
            print("Error in the send_reward_to_cloudwatch function: {}".format(err))


'''
DO NOT EDIT - Inheritance class to convert discrete actions to continuous actions
'''
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



simulation_ws/src/rl-agent/markov/environments/training_env.py [480:538]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # Calculate the distance to checkpoint
        new_distance_to_checkpoint = Float64
        new_distance_to_checkpoint.data = abs(math.sqrt(((new_position.x - CHECKPOINT_X) ** 2) +
                                                        (new_position.y - CHECKPOINT_Y) ** 2))

        if new_distance_to_checkpoint.data < self.current_distance_to_checkpoint:
            self.closer_to_checkpoint = True
        else:
            self.closer_to_checkpoint = False

        # Update the distance to checkpoint
        self.current_distance_to_checkpoint = new_distance_to_checkpoint.data

        # update the current position
        self.x = new_position.x
        self.y = new_position.y

    '''
    DO NOT EDIT - Function to receive Collision data from a ROSTopic
    '''
    def callback_collision(self, data):
        # Listen for a collision with anything in the environment
        collsion_states = data.states
        if len(collsion_states) > 0:
            self.collide = True

    '''
    DO NOT EDIT - Function to wrote episodic rewards to CloudWatch
    '''
    def send_reward_to_cloudwatch(self, reward):
        try:
            session = boto3.session.Session()
            cloudwatch_client = session.client('cloudwatch', region_name=self.aws_region)
            cloudwatch_client.put_metric_data(
                MetricData=[
                    {
                        'MetricName': 'Episode_Reward',
                        'Unit': 'None',
                        'Value': reward
                    },
                    {
                        'MetricName': 'Episode_Steps',
                        'Unit': 'None',
                        'Value': self.steps,
                    },
                    {
                        'MetricName': 'DistanceToCheckpoint',
                        'Unit': 'None',
                        'Value': self.current_distance_to_checkpoint
                    }
                ],
                Namespace='AWS_NASA_JPL_OSR_Challenge'
            )
        except Exception as err:
            print("Error in the send_reward_to_cloudwatch function: {}".format(err))

'''
DO NOT EDIT - Inheritance class to convert discrete actions to continuous actions
'''
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



