Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPULiDAR negative FOV start bug #33

Closed
reza-shahriari opened this issue Sep 28, 2024 · 8 comments
Closed

GPULiDAR negative FOV start bug #33

reza-shahriari opened this issue Sep 28, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@reza-shahriari
Copy link

Hi,
this is my settings.json file:

{
  "SettingsVersion": 2.0,
  "SimMode": "ComputerVision",
  "Vehicles": {
      "CVSensor": {
          "VehicleType": "ComputerVision",
          "AutoCreate": true,
          "Sensors": {
            "gpulidar1": {
              "SensorType": 8,
              "Enabled" : true
          }
          }
      }
  }
}

when I run the game I see this error:
2024-09-28_15-03-47
changing settings and adding more details to GPU lidar (as mentioned here) not change the problem!
even using Car simulation leads to the same problem. when I Disable(Enabled: false) the GPU lidar sensor everything works perfectly

@WouterJansen
Copy link
Contributor

Can you share you settings.json file please? It seems to be tring to load a material CSV file for the intensity generation of GPU LiDAR and something is going wrong there.

@WouterJansen WouterJansen self-assigned this Sep 30, 2024
@WouterJansen WouterJansen added the question Further information is requested label Sep 30, 2024
@WouterJansen WouterJansen removed their assignment Sep 30, 2024
@reza-shahriari
Copy link
Author

Can you share you settings.json file please?

this is my setting.json file:
{
"SettingsVersion": 2.0,
"SimMode": "ComputerVision",
"Vehicles": {
"CVSensor": {
"VehicleType": "ComputerVision",
"AutoCreate": true,
"Sensors": {
"gpulidar1": {
"SensorType": 8,
"Enabled" : true
}
}
}
}
}

for material.csv I have an empty csv file in the Documents/airsim folder

@WouterJansen
Copy link
Contributor

remove the material.csv file or make sure it is not empty (or contains an empty line) and this will be no longer crashing. I will make a catch for this for next release.

@WouterJansen WouterJansen self-assigned this Sep 30, 2024
@reza-shahriari
Copy link
Author

Thanks.
deleting the material.csv solved my problem

@reza-shahriari
Copy link
Author

2024-10-01_18-48-47
The crash problem solved and its not crashing now but lidar GPU results is almost always just a point!

    def parse_gpulidarData(self):
        points = np.array(self.data.point_cloud, dtype=np.dtype('f4'))
        points = np.reshape(points, (int(points.shape[0] / 5), 5))
        xyz = points[:, 0:3]
        self.points = xyz

def visualize(self):
        print("visualizing data ...")
        
       # Convert NED (AirSim) to ENU coordinate system
        x = self.points[:, 0]
        y = -self.points[:, 1]  # Flip Y axis
        z = -self.points[:, 2]  # Flip Z axis

        # Verify the number of points
        print(f"Total points: {x.shape[0]}")  

        # RGB extraction (assuming the rgb array is already defined)
        # Normalize RGB values to the [0, 1] range for matplotlib
        rgb_normalized = self.rgb / 255.0

        # Plotting the Lidar data with colors
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')

        # Scatter plot with colors
        scatter = ax.scatter(x, y, z, c=rgb_normalized, marker='o')

        # Set labels
        ax.set_xlabel('X')
        ax.set_ylabel('Y')
        ax.set_zlabel('Z')

        # # Adjust the aspect ratio for better visualization
        # max_range = np.array([x.max() - x.min(), y.max() - y.min(), z.max() - z.min()]).max() / 2.0
        # mid_x = (x.max() + x.min()) * 0.5
        # mid_y = (y.max() + y.min()) * 0.5
        # mid_z = (z.max() + z.min()) * 0.5

        # ax.set_xlim(mid_x - max_range, mid_x + max_range)
        # ax.set_ylim(mid_y - max_range, mid_y + max_range)
        # ax.set_zlim(mid_z - max_range, mid_z + max_range)

        # Display the plot
        plt.show()

visualizing data ...
Total points: 32768

@reza-shahriari
Copy link
Author

settings file:

{
  "SettingsVersion": 2.0,
  "SimMode": "ComputerVision",
  "Vehicles": {
      "Drone1": {
          "VehicleType": "ComputerVision",
          "AutoCreate": true,
          "Sensors": {
            "gpulidar1": {
            "SensorType": 8,
            "Enabled" : true,
            "Range":150,
            "NumberOfChannels": 16,
            "RotationsPerSecond": 10,
            "PointsPerSecond": 100000,
            "X": 0, "Y": 0, "Z": -1,
            "Roll": 0, "Pitch": 0, "Yaw" : 0,
            "VerticalFOVUpper": -15,
            "VerticalFOVLower": -25,
            "HorizontalFOVStart": -20,
            "HorizontalFOVEnd": 20,
            "DrawDebugPoints": true
          }
          }
      }
  }
}

WouterJansen added a commit that referenced this issue Oct 4, 2024
…p the creation. Fixed #33

(cherry picked from commit 52e3989)
WouterJansen added a commit that referenced this issue Oct 4, 2024
…p the creation. Fixed #33

(cherry picked from commit 52e3989)
@WouterJansen WouterJansen reopened this Oct 4, 2024
@WouterJansen
Copy link
Contributor

Hi, I get the same results. One thing, RotationsPerSecond is not an argument for the LiDARs in Cosys-AirSim. We use MeasurementsPerCycle to define the horizontal sample density. See the documentation on the LiDAR and GPULiDAR for all the arguments that can be used.

It seems you are running into an edge case that is causing a bug when to reset the pointcloud data. This is due to you using a negative HorizontalFOVStart argument. I will fix this in a future release. For now you can either switch to the normal LiDAR sensor which does not have this bug or do a little change to your settings to prevent having to use a negative HorizontalFOVStart. For example in your case you want to have a 40 degrees FOV from -20 degrees to 20 degrees, you have to set it to Yaw : -20, HorizontalFOVStart: 0 and_HorizontalFOVEnd_: 40.

@WouterJansen WouterJansen added bug Something isn't working and removed question Further information is requested labels Oct 4, 2024
@WouterJansen WouterJansen changed the title gpu lidar crash GPULiDAR negative FOV start bug Oct 4, 2024
@reza-shahriari
Copy link
Author

Thanks for the answer.
changing setting to this worked nice for me:

{
  "SettingsVersion": 2.0,
  "SimMode": "ComputerVision",
  "Vehicles": {
    "Drone1": {
      "VehicleType": "ComputerVision",
      "AutoCreate": true,
      "Sensors": {
        "gpulidar1": {
          "SensorType": 8,
          "Enabled": true,
          "External": false,
          "NumberOfChannels": 50,
          "Range": 100,
          "MeasurementsPerCycle": 2048,
          "RotationsPerSecond": 10,
          "Resolution": 2048,
          "X": 0,
          "Y": 0,
          "Z": -0.5,
          "Roll": 0,
          "Pitch": 0,
          "Yaw": 0,
          "VerticalFOVUpper": 30,
          "VerticalFOVLower": -30,
          "HorizontalFOVStart": 0,
          "HorizontalFOVEnd": 360,
          "DrawDebugPoints": false,
          "DrawMode": 0,
          "IgnoreMarked": true,
          "GroundTruth": true,
          "InstanceSegmentation": true,
          "Annotation": "",
          "GenerateIntensity": false,
          "rangeMaxLambertianPercentage": 80,
          "rainMaxIntensity": 70,
          "rainConstantA": 0.01,
          "rainConstantB": 0.6,
          "DrawSensor": true
        }
      }
    }
  }
}

WouterJansen added a commit that referenced this issue Nov 25, 2024
WouterJansen added a commit that referenced this issue Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants