Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question CameraSensors. ObservationToTexture

Discussion in 'ML-Agents' started by GodSevenTeen, Aug 9, 2023.

  1. GodSevenTeen

    GodSevenTeen

    Joined:
    Jan 8, 2023
    Posts:
    4
    I added camerasor to the robot model imported through the URDF importer and encountered an error while running, 'NullReferenceException: Object reference not set to an instance of an object'
    Unity. MLAgents. Sensors. CameraSensors. ObservationToTexture (UnityEngine. Camera obsCamera, UnityEngine. Texture2D texture2D, System. Int32 width, System. Int32 height). I have previously stated that I have added a regular camera and other properties remain default
     
  2. GodSevenTeen

    GodSevenTeen

    Joined:
    Jan 8, 2023
    Posts:
    4
    and these is the full report

    NullReferenceException: Object reference not set to an instance of an object
    Unity.MLAgents.Sensors.CameraSensor.ObservationToTexture (UnityEngine.Camera obsCamera, UnityEngine.Texture2D texture2D, System.Int32 width, System.Int32 height) (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Sensors/CameraSensor.cs:158)
    Unity.MLAgents.Sensors.CameraSensor.GetCompressedObservation () (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Sensors/CameraSensor.cs:92)
    Unity.MLAgents.Policies.HeuristicPolicy.StepSensors (System.Collections.Generic.List`1[T] sensors) (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Policies/HeuristicPolicy.cs:137)
    Unity.MLAgents.Policies.HeuristicPolicy.RequestDecision (Unity.MLAgents.AgentInfo info, System.Collections.Generic.List`1[T] sensors) (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Policies/HeuristicPolicy.cs:38)
    Unity.MLAgents.Agent.SendInfoToBrain () (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Agent.cs:1099)
    Unity.MLAgents.Agent.SendInfo () (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Agent.cs:1326)
    Unity.MLAgents.Academy.EnvironmentStep () (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Academy.cs:573)
    Unity.MLAgents.AcademyFixedUpdateStepper.FixedUpdate () (at ./Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Academy.cs:43)
     
  3. GodSevenTeen

    GodSevenTeen

    Joined:
    Jan 8, 2023
    Posts:
    4
    But I can mount a camera sensor on a very simple cube, and Python can also receive information, just like this.

    My Behavior?team=0: [array([[[[0.6431373 ],
    ...,
    [0.38300654],
    [0.38300654],
    [0.38300654]]]], dtype=float32), array([[0.]], dtype=float32)]
    This is a decision_step
     
  4. piikashowapk

    piikashowapk

    Joined:
    Aug 9, 2023
    Posts:
    1
    After integrating a CameraSensor to the robot model via the URDF importer, I faced an error during runtime: 'NullReferenceException: Object reference not set to an instance of an object' within Unity. The issue originates from Unity.MLAgents.Sensors.CameraSensors.ObservationToTexture(UnityEngine.Camera obsCamera, UnityEngine.Texture2D texture2D, System.Int32 width, System.Int32 height). It's important to note that I have already added a standard camera, apk and all other properties remain at their default settings.
     
  5. GodSevenTeen

    GodSevenTeen

    Joined:
    Jan 8, 2023
    Posts:
    4
    Your summary is very good. Can you solve this problem