code: def _update_state(self):
      # get measurements and observations
      measurements = []
      while type(measurements) == list:
          measurements, sensor_data = self.game.read_data()
      self.state = {}
  
      for camera in self.scene.sensors:
          self.state[camera.name] = sensor_data[camera.name].data
  
      self.location = [
          measurements.player_measurements.transform.location.x,
          measurements.player_measurements.transform.location.y,
          measurements.player_measurements.transform.location.z,
      ]
  
      self.distance_from_goal = np.linalg.norm(
          np.array(self.location[:2])
          - [self.current_goal.location.x, self.current_goal.location.y]
      )
  
      is_collision = (
          measurements.player_measurements.collision_vehicles != 0
          or measurements.player_measurements.collision_pedestrians != 0
          or measurements.player_measurements.collision_other != 0
      )
  
      speed_reward = measurements.player_measurements.forward_speed - 1
      if speed_reward > 30.0:
          speed_reward = 30.0
      self.reward = (
          speed_reward
          - (
              measurements.player_measurements.intersection_otherlane
              * 5
          )
          - (measurements.player_measurements.intersection_offroad * 5)
          - is_collision * 100
          - np.abs(self.control.steer) * 10
      )
  
      # update measurements
      self.measurements = [
          measurements.player_measurements.forward_speed
      ] + self.location
      self.autopilot = (
          measurements.player_measurements.autopilot_control
      )
  
      # The directions to reach the goal (0 Follow lane, 1 Left, 2 Right, 3 Straight)
      directions = int(
          self._get_directions(
              measurements.player_measurements.transform,
              self.current_goal,
          )
          - 2
      )
      self.state["high_level_command"] = directions
  
      if (
          measurements.game_timestamp >= self.episode_max_time
      ) or is_collision:
          self.done = True
  
      self.state["measurements"] = np.array(self.measurements)
  
imports: import random
  import sys
  from os import path, environ
  from rl_coach.logger import screen
  from rl_coach.filters.action.partial_discrete_action_space_map import PartialDiscreteActionSpaceMap
  from rl_coach.filters.observation.observation_rgb_to_y_filter import ObservationRGBToYFilter
  from rl_coach.filters.observation.observation_to_uint8_filter import ObservationToUInt8Filter
  import os
  import signal
  import logging
  import subprocess
  import numpy
  from rl_coach.environments.environment import Environment, EnvironmentParameters, LevelSelection
  from rl_coach.spaces import BoxActionSpace, ImageObservationSpace, StateSpace, VectorObservationSpace
  from rl_coach.utils import get_open_port, force_list
  from enum import Enum
  from typing import List, Union
  from rl_coach.base_parameters import VisualizationParameters
  from rl_coach.filters.filter import InputFilter, NoOutputFilter
  from rl_coach.filters.observation.observation_rescale_to_size_filter import ObservationRescaleToSizeFilter
  from rl_coach.filters.observation.observation_stacking_filter import ObservationStackingFilter
label_desc: Use image node_id 6 for calling the CarlaEnvironment obj's underlying member method code with example usage: obj._update_state() without return types