-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from rickstaa/improve_pybullet_numpy_error
refactor: improve pybullet numpy error
- Loading branch information
Showing
1 changed file
with
10 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,12 @@ | ||
"""PyFlyt - Multi UAV simulation environment for reinforcement learning research.""" | ||
|
||
|
||
def test_numpy(): | ||
"""Tests whether pybullet was installed with Numpy.""" | ||
import pybullet as p | ||
|
||
p.connect(p.DIRECT) | ||
|
||
_, _, rgbaImg, _, _ = p.getCameraImage( | ||
height=10, | ||
width=10, | ||
viewMatrix=( | ||
0.0, | ||
0.3420201539993286, | ||
-0.9396926760673523, | ||
0.0, | ||
-1.0, | ||
0.0, | ||
-0.0, | ||
0.0, | ||
0.0, | ||
0.9396926760673523, | ||
0.3420201539993286, | ||
0.0, | ||
-0.1599999964237213, | ||
-4.414617538452148, | ||
9.205257415771484, | ||
1.0, | ||
), | ||
projectionMatrix=( | ||
0.9999999403953552, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.9999999403953552, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
-1.0007846355438232, | ||
-1.0, | ||
0.0, | ||
0.0, | ||
-0.20007847249507904, | ||
0.0, | ||
), | ||
import pybullet | ||
|
||
# Throw error if pybullet is not installed with numpy support. | ||
if not pybullet.isNumpyEnabled(): | ||
raise RuntimeError( | ||
"PyBullet is not installed properly with Numpy functionality,\n" | ||
"Please fix this by installing Numpy again, then rebuilding PyBullet:\n" | ||
"\tpip3 uninstall pybullet -y\n" | ||
"\tpip3 install numpy\n" | ||
"\tpip3 install pybullet --no-cache-dir\n" | ||
) | ||
|
||
try: | ||
rgbaImg.reshape(-1) | ||
except Exception: | ||
raise RuntimeError( | ||
"PyBullet is not installed properly with Numpy functionality,\n" | ||
"Please fix this by installing Numpy again, then rebuilding PyBullet:\n" | ||
"\tpip3 uninstall pybullet -y\n" | ||
"\tpip3 install numpy\n" | ||
"\tpip3 install pybullet --no-cache-dir\n" | ||
) | ||
|
||
p.disconnect() | ||
|
||
|
||
test_numpy() |