Skip to content

Commit

Permalink
Merge pull request #8 from rickstaa/improve_pybullet_numpy_error
Browse files Browse the repository at this point in the history
refactor: improve pybullet numpy error
  • Loading branch information
jjshoots authored Jul 25, 2023
2 parents abd3315 + 2dc3be4 commit 5f6ba72
Showing 1 changed file with 10 additions and 63 deletions.
73 changes: 10 additions & 63 deletions PyFlyt/__init__.py
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()

0 comments on commit 5f6ba72

Please sign in to comment.