Skip to content

Fix the camera and custom wind examples - #102

Open
vishwagw wants to merge 6 commits into
jjshoots:masterfrom
vishwagw:fix/camera-and-wind-examples
Open

vishwagw wants to merge 6 commits into
jjshoots:masterfrom
vishwagw:fix/camera-and-wind-examples

Conversation

@vishwagw

Copy link
Copy Markdown

Uploading through the GitHub website. Make branch fix/camera-and-wind-examples with the first upload, then upload the rest to the same branch, one folder at a time, with these commit messages. Each upload replaces the existing file.

  1. examples/core/04_camera.py:
    examples: fix camera example for camera_angle_degrees
  2. examples/core/10_custom_wind.py:
    examples: fix custom wind example for np.random.Generator
  3. PyFlyt/core/abstractions/base_wind_field.py:
    core: use standard_normal in the WindFieldClass docstring example
  4. docs_source/documentation/core/wind.md:
    docs: document np_random as an np.random.Generator
  5. docs_source/documentation/core/abstractions/base_drone.md:
    docs: document np_random as an np.random.Generator on the drone page

Description

Two of the core examples fail on the current code.

examples/core/04_camera.py (#71) still passes camera_angle, which QuadX renamed to camera_angle_degrees:

TypeError: QuadX.__init__() got an unexpected keyword argument 'camera_angle'
  • It now passes camera_angle_degrees.
  • The step-count comment now says 100 steps (~1 second), matching the loop. It previously said 1000.
  • The example drew the RGBA, depth and segmentation images onto the same axes, so only the segmentation image was visible. They're now shown side by side.

examples/core/10_custom_wind.py calls self.np_random.randn(). The Aviary passes wind fields an np.random.Generator (np.random.default_rng()), which has no randn, so the example fails on its first step:

AttributeError: 'numpy.random._generator.Generator' object has no attribute 'randn'. Did you mean: 'random'?
  • It now uses standard_normal(wind.shape).
  • The same line is in the WindFieldClass docstring, which the wind docs page shows as the custom wind example, so that line is updated too.
  • The wind and drone docs pages listed np_random as np.random.RandomState. They now say np.random.Generator, which matches the type hints in WindFieldClass and DroneClass.

Fixes #71

Testing

Run on Linux under xvfb with Python 3.12, numpy 1.26.4, pybullet 3.2.7 and matplotlib, with plt.show() saving the figure:

  • I ran all ten examples in examples/core on master. 04_camera.py and 10_custom_wind.py failed with the errors above, and the other eight ran to completion. With this PR, both run to completion: 10_custom_wind.py runs all 1000 steps.
  • The camera example's figure now shows all three images (attached).
  • Pre-commit passes on the changed files, apart from pyright, which reports gymnasium 1.4 spaces.Dict typing errors in other files on master too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The camera in the example is not updated

1 participant