isl-org / spear

SPEAR: A Simulator for Photorealistic Embodied AI Research
MIT License
221 stars 15 forks source link

Failed when running the python file. #245

Closed StarsTesla closed 1 year ago

StarsTesla commented 1 year ago

Hi, there, I follow the markdown to run the python file, and whatever I run, always fail, here is the one of the error log when running generate_image.py:

[SPEAR | env.py] Launching Unreal instance...
[SPEAR | env.py] Writing temp config file: /home/michael/git/spear/examples/generate_image_dataset/tmp/config.yaml
[SPEAR | env.py] File or directory or symlink exists, removing: /home/michael/git/spear/SpearSim/SpearSim/Content/Paks/SpearPaks
[SPEAR | env.py] Creating symlink: /home/michael/git/spear/SpearSim/SpearSim/Content/Paks/SpearPaks -> /home/michael/git/spear/pak
[SPEAR | env.py] Launching executable with the following command-line arguments:
/home/michael/git/spear/SpearSim/SpearSim.sh -windowed -resx=1024 -resy=1024 -graphicsadapter=0 -nosound -fileopenlog -stdout -fullstdoutlogoutput -nologtimes -config_file=/home/michael/git/spear/examples/generate_image_dataset/tmp/config.yaml
[SPEAR | env.py] Launching executable with the following config values:
CORE_UTILS:
  WAIT_FOR_KEYBOARD_INPUT_DURING_INITIALIZATION: False
SIMULATION_CONTROLLER:
  AGENT: CameraAgent
  CAMERA_AGENT:
    ACTION_COMPONENTS: ['set_location', 'set_rotation']
    CAMERA:
      FOV: 90.0
      IMAGE_HEIGHT: 1024
      IMAGE_WIDTH: 1024
      RENDER_PASSES: ['final_color, depth']
    CAMERA_ACTOR_NAME: camera_actor
    OBSERVATION_COMPONENTS: ['camera']
    SPAWN_ACTOR_NAME: PlayerStart_0
    SPAWN_LOCATION_X: 0.0
    SPAWN_LOCATION_Y: 0.0
    SPAWN_LOCATION_Z: 0.0
    SPAWN_MODE: specify_existing_actor
    SPAWN_ROTATION_PITCH: 0.0
    SPAWN_ROTATION_ROLL: 0.0
    SPAWN_ROTATION_YAW: 0.0
    STEP_INFO_COMPONENTS: []
  CAMERA_SENSOR:
    READ_SURFACE_DATA: True
    USE_SHARED_MEMORY: True
  CUSTOM_UNREAL_CONSOLE_COMMANDS: []
  IMITATION_LEARNING_TASK:
    AGENT_ACTOR_NAME: 
    AGENT_SPAWN_OFFSET_LOCATION_X: 0.0
    AGENT_SPAWN_OFFSET_LOCATION_Y: 0.0
    AGENT_SPAWN_OFFSET_LOCATION_Z: 0.0
    EPISODES_FILE: 
    GOAL_ACTOR_NAME: 
    OBSTACLE_IGNORE_ACTOR_NAMES: []
  IMU_SENSOR:
    DEBUG_RENDER: False
  INTERACTION_MODE: programmatic
  IP: 127.0.0.1
  MAP_ID: 
  NAVMESH:
    AGENT_HEIGHT: 200.0
    AGENT_MAX_SLOPE: 1.0
    AGENT_MAX_STEP_HEIGHT: 1.0
    AGENT_RADIUS: 50.0
    CELL_HEIGHT: 1.0
    CELL_SIZE: 1.0
    DEBUG_NAVIGATION_DATA_FILE: 
    MAX_SIMPLIFICATION_ERROR: 1.3
    MERGE_REGION_SIZE: 400.0
    MIN_REGION_AREA: 0.0
    TILE_POOL_SIZE: 1024
    TILE_SIZE_UU: 1000.0
    TRAJECTORY_SAMPLING_DEBUG_RENDER: False
    TRAJECTORY_SAMPLING_SEARCH_RADIUS: 0.0
  PHYSICS:
    ENABLE_ENHANCED_DETERMINISM: True
    ENABLE_SUBSTEPPING: True
    MAX_SUBSTEPS: 100
    MAX_SUBSTEP_DELTA_TIME: 0.01
    SIMULATION_STEP_TIME: 0.05
  POINT_GOAL_NAV_TASK:
    AGENT_ACTOR_NAME: 
    EPISODE_BEGIN:
      AGENT_LOCATION_X_MAX: nan
      AGENT_LOCATION_X_MIN: nan
      AGENT_LOCATION_Y_MAX: nan
      AGENT_LOCATION_Y_MIN: nan
      AGENT_LOCATION_Z: nan
      GOAL_LOCATION_X_MAX: nan
      GOAL_LOCATION_X_MIN: nan
      GOAL_LOCATION_Y_MAX: nan
      GOAL_LOCATION_Y_MIN: nan
      GOAL_LOCATION_Z: nan
      SPAWN_DISTANCE_THRESHOLD: 1.0
    GOAL_ACTOR_NAME: 
    GOAL_MATERIAL: /Engine/BasicShapes/BasicShapeMaterial.BasicShapeMaterial
    GOAL_MESH: /Engine/BasicShapes/Cylinder.Cylinder
    OBSTACLE_IGNORE_ACTOR_NAMES: []
    RANDOM_SEED: 0
    REWARD:
      HIT_GOAL: 1.0
      HIT_OBSTACLE: -1.0
  PORT: 30000
  SCENE_ID: apartment_0000
  SPHERE_AGENT:
    ACTION_COMPONENTS: ['add_force', 'add_rotation']
    CAMERA:
      FOV: 90.0
      IMAGE_HEIGHT: 512
      IMAGE_WIDTH: 512
      RENDER_PASSES: ['final_color']
    CAMERA_ACTOR_NAME: 
    OBSERVATION_COMPONENTS: ['camera', 'location', 'rotation']
    SPAWN_ACTOR_NAME: 
    SPAWN_LOCATION_X: 0.0
    SPAWN_LOCATION_Y: 0.0
    SPAWN_LOCATION_Z: 0.0
    SPAWN_MODE: specify_pose
    SPAWN_ROTATION_PITCH: 0.0
    SPAWN_ROTATION_ROLL: 0.0
    SPAWN_ROTATION_YAW: 0.0
    SPHERE:
      ANGULAR_DAMPING: 0.0
      LINEAR_DAMPING: 0.0
      MATERIAL: /Engine/BasicShapes/BasicShapeMaterial.BasicShapeMaterial
      MAX_ANGULAR_VELOCITY: 1.0
      MESH_SCALE_X: 0.5
      MESH_SCALE_Y: 0.5
      MESH_SCALE_Z: 0.5
      STATIC_MESH: /Engine/BasicShapes/Sphere.Sphere
    SPHERE_ACTOR_NAME: 
    STEP_INFO_COMPONENTS: ['debug']
  TASK: NullTask
  URDFBOT_AGENT:
    ACTION_COMPONENTS: ['control_joints']
    CAMERA:
      FOV: 90.0
      IMAGE_HEIGHT: 512
      IMAGE_WIDTH: 512
      POSITION_OFFSET_X: 0.0
      POSITION_OFFSET_Y: 0.0
      POSITION_OFFSET_Z: 0.0
      RENDER_PASSES: ['final_color']
    IS_READY_VELOCITY_THRESHOLD: 0.001
    OBSERVATION_COMPONENTS: ['link_state', 'camera']
    SPAWN_ACTOR_NAME: 
    SPAWN_MODE: specify_pose
    SPAWN_PITCH: 0.0
    SPAWN_POSITION_X: 0.0
    SPAWN_POSITION_Y: 0.0
    SPAWN_POSITION_Z: 0.0
    SPAWN_ROLL: 0.0
    SPAWN_YAW: 0.0
    STEP_INFO_COMPONENTS: []
    URDFBOT_ACTOR_NAME: 
  VEHICLE_AGENT:
    ACTION_COMPONENTS: ['set_brake_torques', 'set_drive_torques']
    CAMERA:
      FOV: 90.0
      IMAGE_HEIGHT: 512
      IMAGE_WIDTH: 512
      RENDER_PASSES: ['final_color']
    IS_READY_VELOCITY_THRESHOLD: 0.001
    OBSERVATION_COMPONENTS: ['camera', 'location', 'rotation', 'wheel_rotation_speeds']
    SPAWN_ACTOR_NAME: 
    SPAWN_LOCATION_X: 0.0
    SPAWN_LOCATION_Y: 0.0
    SPAWN_LOCATION_Z: 0.0
    SPAWN_MODE: specify_pose
    SPAWN_ROTATION_PITCH: 0.0
    SPAWN_ROTATION_ROLL: 0.0
    SPAWN_ROTATION_YAW: 0.0
    STEP_INFO_COMPONENTS: ['']
    VEHICLE_ACTOR_NAME: 
  VISUALIZER:
    ACTOR_NAME: camera_actor
    SPAWN_CAMERA: False
    SPAWN_LOCATION_X: 0.0
    SPAWN_LOCATION_Y: 0.0
    SPAWN_LOCATION_Z: 0.0
    SPAWN_ROTATION_PITCH: 0.0
    SPAWN_ROTATION_ROLL: 0.0
    SPAWN_ROTATION_YAW: 0.0
SPEAR:
  CUSTOM_COMMAND_LINE_ARGUMENTS: []
  GPU_ID: 0
  LAUNCH_MODE: standalone_executable
  MAX_NUM_TICKS_AFTER_RESET: 10
  NUM_EXTRA_WARMUP_TICKS: 20
  PAKS_DIR: /home/michael/git/spear/pak
  RENDER_OFFSCREEN: False
  RPC_CLIENT_INITIALIZE_CONNECTION_MAX_TIME_SECONDS: 120.0
  RPC_CLIENT_INITIALIZE_CONNECTION_SLEEP_TIME_SECONDS: 1.0
  RPC_CLIENT_INTERNAL_RECONNECT_LIMIT: 1
  RPC_CLIENT_INTERNAL_TIMEOUT_SECONDS: 5.0
  STANDALONE_EXECUTABLE: /home/michael/git/spear/SpearSim/SpearSim.sh
  TEMP_DIR: tmp
  UNREAL_EDITOR_EXECUTABLE: 
  UNREAL_INTERNAL_LOG_FILE: 
  UPROJECT: 
  VK_ICD_FILENAMES: 
  WINDOW_RESOLUTION_X: 1024
  WINDOW_RESOLUTION_Y: 1024
URDFBOT:
  URDFBOT_PAWN:
    CAMERA_COMPONENT:
      FOV: 90.0
      PITCH: 0.0
      POSITION_X: 0.0
      POSITION_Y: 0.0
      POSITION_Z: 50.0
      ROLL: 0.0
      YAW: 0.0
    KEYBOARD_ACTIONS:

    URDF_DIR: /home/michael/git/spear/python/spear/urdf
    URDF_FILE: 
  URDF_LINK_COMPONENT:
    POSITION_SOLVER_ITERATION_COUNT: 16
    VELOCITY_SOLVER_ITERATION_COUNT: 16
VEHICLE:
  VEHICLE_COMPONENT:
    CHASSIS_HEIGHT: 15.0
    CHASSIS_WIDTH: 15.0
    DRAG_COEFFICIENT: 1.0
    LEGACY_WHEEL_FRICTION_POSITION_ENABLED: False
    MASS: 11.2
    SUSPENSION_ENABLED: True
    WHEEL_FRICTION_ENABLED: True
  VEHICLE_PAWN:
    ANIM_INSTANCE: /Vehicle/OpenBot/Meshes/ABP_OpenBot.ABP_OpenBot_C
    CAMERA_COMPONENT:
      ASPECT_RATIO: 1.333333
      FOV: 70.0
      LOCATION_X: 9.0
      LOCATION_Y: 5.0
      LOCATION_Z: 10.0
      ROTATION_PITCH: 0.0
      ROTATION_ROLL: 0.0
      ROTATION_YAW: 0.0
    IMU_COMPONENT:
      LOCATION_X: 8.0
      LOCATION_Y: 0.0
      LOCATION_Z: 10.0
      ROTATION_PITCH: 0.0
      ROTATION_ROLL: 0.0
      ROTATION_YAW: 0.0
    SKELETAL_MESH: /Vehicle/OpenBot/Meshes/SK_OpenBot.SK_OpenBot
  VEHICLE_WHEEL:
    FRICTION_FORCE_MULTIPLIER: 3.0
    SPRING_PRELOAD: 0.033
    SPRING_RATE: 0.167
    SUSPENSION_DAMPING_RATIO: 0.5
    SUSPENSION_MAX_DROP: 0.001
    SUSPENSION_MAX_RAISE: 0.001
    WHEEL_MASS: 0.033
    WHEEL_RADIUS: 3.3
    WHEEL_WIDTH: 2.5
[SPEAR | env.py] Initializing RPC client...
WARNING:tornado.general:Connect error on fd 6: ECONNREFUSED
chmod: changing permissions of '/home/michael/git/spear/SpearSim/SpearSim/Binaries/Linux/SpearSim-Linux-Shipping': Operation not permitted
5.2.1-0+UE5 1009 0
Disabling core dumps.
[SPEAR | CoreUtils.cpp] CoreUtils::StartupModule
[SPEAR | ActorHitEventComponent.h] UActorHitEventComponent::UActorHitEventComponent
[SPEAR | TickEventComponent.h] UTickEventComponent::UTickEventComponent
[SPEAR | VehicleMovementComponent.cpp] UVehicleMovementComponent::UVehicleMovementComponent
[SPEAR | VehicleMovementComponent.cpp] UVehicleMovementComponent::UVehicleMovementComponent
[SPEAR | VehiclePawn.cpp] AVehiclePawn::AVehiclePawn
[SPEAR | VehicleWheel.cpp] UVehicleWheel::UVehicleWheel
[SPEAR | SpearSimSpectatorPawn.cpp] ASpearSimSpectatorPawn::ASpearSimSpectatorPawn
[SPEAR | SpearSimGameEngine.cpp] USpearSimGameEngine::USpearSimGameEngine
[SPEAR | SpearSimGameMode.cpp] ASpearSimGameMode::ASpearSimGameMode
WARNING:tornado.general:Connect error on fd 6: ECONNREFUSED
[SPEAR | Vehicle.cpp] Vehicle::StartupModule
[SPEAR | SimulationController.cpp] SimulationController::StartupModule
[SPEAR | SpearSimGameEngine.cpp] USpearSimGameEngine::USpearSimGameEngine
[SPEAR | SimulationController.cpp] SimulationController::postWorldInitializationEventHandler
[SPEAR | SimulationController.cpp] SimulationController::worldCleanupEventHandler
[SPEAR | SimulationController.cpp] SimulationController::postWorldInitializationEventHandler
[SPEAR | SimulationController.cpp] scene_id:                apartment_0000
[SPEAR | SimulationController.cpp] map_id:                  apartment_0000
[SPEAR | SimulationController.cpp] desired_world_path_name: /Game/Scenes/apartment_0000/Maps/apartment_0000.apartment_0000
[SPEAR | SimulationController.cpp] desired_level_name:      /Game/Scenes/apartment_0000/Maps/apartment_0000
[SPEAR | SimulationController.cpp] world->GetPathName():    /Game/Scenes/apartment_0000/Maps/apartment_0000.apartment_0000
[SPEAR | SimulationController.cpp] open_level:              0
[SPEAR | SpearSimGameMode.cpp] ASpearSimGameMode::ASpearSimGameMode
[SPEAR | SpearSimSpectatorPawn.cpp] ASpearSimSpectatorPawn::ASpearSimSpectatorPawn
[SPEAR | SimulationController.cpp] SimulationController::worldBeginPlayEventHandler
libc++abi: terminating due to uncaught exception of type std::out_of_range: map::at:  key not found
Signal 6 caught.
Malloc Size=262146 LargeMemoryPoolOffset=262162 
CommonUnixCrashHandler: Signal=6
Malloc Size=131160 LargeMemoryPoolOffset=393352 
Malloc Size=131160 LargeMemoryPoolOffset=524536 
Engine crash handling finished; re-raising signal 6 for the default handler. Good bye.
WARNING:tornado.general:Connect error on fd 6: ECONNREFUSED
Aborted (core dumped)
[SPEAR | env.py] ERROR: Unrecognized process status: zombie
[SPEAR | env.py] ERROR: Killing process 3148595...
Traceback (most recent call last):
  File "generate_images.py", line 98, in <module>
    env = CustomEnv(config, num_internal_steps=args.num_internal_steps)
  File "generate_images.py", line 26, in __init__
    super(CustomEnv, self).__init__(config)
  File "/home/michael/git/spear/python/spear/env.py", line 27, in __init__
    self._initialize_rpc_client()
  File "/home/michael/git/spear/python/spear/env.py", line 290, in _initialize_rpc_client
    self._close_rpc_client()
  File "/home/michael/git/spear/python/spear/env.py", line 353, in _close_rpc_client
    self._rpc_client._loop._ioloop.close()
  File "/home/michael/anaconda3/envs/spear-env/lib/python3.8/site-packages/tornado/ioloop.py", line 716, in close
    self.remove_handler(self._waker.fileno())
  File "/home/michael/anaconda3/envs/spear-env/lib/python3.8/site-packages/tornado/platform/posix.py", line 48, in fileno
    return self.reader.fileno()
ValueError: I/O operation on closed file
StarsTesla commented 1 year ago

My running env is under Ubuntu with display, GPU 3090,and no root mode(cause the UE disallow root mode)

mikeroberts3000 commented 1 year ago

The example seems to be proceeding as expected until this line.

libc++abi: terminating due to uncaught exception of type std::out_of_range: map::at:  key not found

This is encouraging because we don't actually call the std::map::at() function in very many places. The most frequently executed place where we use std::map::at() is in our Config system, but we explicitly check if a requested key isn't found, and we print out our own error message in this case. I don't see that error message in your log, so that narrows the problem down even further.

StarsTesla commented 1 year ago

@mikeroberts3000 Yes, I use precompiled binary. I can run the pre-compiled binary follow the markdown, and control it with my keyboard and mouse. Yes or no? after I started it , it shows one window with seems not continue images flash, and then the second windows shows final color. Here below is my user_config.

#
# Copyright(c) 2022 Intel. Licensed under the MIT License <http://opensource.org/licenses/MIT>.
#

SPEAR:
  LAUNCH_MODE: "standalone_executable"

  STANDALONE_EXECUTABLE: "/home/michael/git/spear/SpearSim/SpearSim.sh"

  PAKS_DIR: "/home/michael/git/spear/pak"

  CUSTOM_COMMAND_LINE_ARGUMENTS: []
  RENDER_OFFSCREEN: False
  WINDOW_RESOLUTION_X: 1024
  WINDOW_RESOLUTION_Y: 1024

SIMULATION_CONTROLLER:
  AGENT: "CameraAgent"
  TASK: "NullTask"
  CUSTOM_UNREAL_CONSOLE_COMMANDS: []

  NAVMESH:
    MIN_REGION_AREA: 0.0

  CAMERA_AGENT:
    CAMERA_ACTOR_NAME: "camera_actor"
    SPAWN_MODE: "specify_existing_actor"
    SPAWN_ACTOR_NAME: "PlayerStart_0"
    ACTION_COMPONENTS: ["set_location", "set_rotation"] # "set_location", "set_rotation"
    OBSERVATION_COMPONENTS: ["camera"] # "camera"
    STEP_INFO_COMPONENTS: []
    CAMERA:
      RENDER_PASSES: ["final_color, depth"] # "depth", "final_color", "normal", "segmentation"
      IMAGE_HEIGHT: 1024
      IMAGE_WIDTH: 1024
      FOV: 90.0

  VISUALIZER:
    ACTOR_NAME: "camera_actor"
    SPAWN_CAMERA: False
StarsTesla commented 1 year ago

The pak dir contains only one pak, kujiale_0000.pak

mikeroberts3000 commented 1 year ago

Please use `` to format blocks of code instead of (I corrected this issue in both of your posts already, but for future reference, this is a better way to format multi-line code blocks.)

mikeroberts3000 commented 1 year ago

Ah, your RENDER_PASSES is defined as an array with a one string entry "final_color, depth". This is incorrect. You want it to be an array with two string entries "final_color" and "depth". So you want to do the following.

RENDER_PASSES: ["final_color", "depth"]

We provide an example definition for RENDER_PASSES in the README for generate_image_dataset. I hope that helps.

StarsTesla commented 1 year ago

@mikeroberts3000 Thanks for that, now the generation is done(After I press Igore the warning). But the depth shows some wired, it gives a kinda textural depth? Maybe something is wrong?

0001

mikeroberts3000 commented 1 year ago

I think you're now experiencing a bug/limitation in the Unreal Engine that we make a note of in our backlog here: https://github.com/isl-org/spear/issues/198

We render depth images in a full-precision floating-point texture format, but this format doesn't seem to work correctly on macOS or Linux in UE 5.2. The easiest workaround is to use Windows.

Another workaround (that would require modifying our code) would be to change the texture format used for depth rendering:

https://github.com/isl-org/spear/blob/8afa15b30cc667b55729e1c10bac141c36c76953/cpp/unreal_plugins/SimulationController/Source/SimulationController/CameraSensor.cpp#L51

The goal would be to: (1) change the texture format to a format that is better-behaved on macOS and Linux; (2) implement an encoding function in the depth post-processing material (PPM_Depth.uasset) that encodes floating-point depth into the desired format in a way that doesn't lose much precision; (3) implement a decoding function in CameraSensor.cpp that recovers floating-point depth from the encoded representation; and (4) invoke the decoding function in CameraSensor::getObservation(), once the data has been copied from the GPU to the CPU. If you're up for it, I can help to guide you through the process and we could submit a PR together.