Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: qgallouedec/panda-gym
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.7
Choose a base ref
...
head repository: qgallouedec/panda-gym
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 2 commits
  • 7 files changed
  • 2 contributors

Commits on Jun 10, 2024

  1. Manually trigger workflow (#92)

    * fix ci macos
    
    * is_success consistency
    
    * signature for compute_reward
    
    * update actions versions
    
    * try another ci
    
    * secret token
    
    * build only pr
    
    * upload only py3.10
    
    * workflow dispact
    qgallouedec authored Jun 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    746ee4d View commit details

Commits on Jul 4, 2024

  1. Better seed (#97)

    * better seed
    
    * numpy dep
    
    ---------
    
    Co-authored-by: Quentin Gallouédec <[email protected]>
    qgallouedec and qgallouedec authored Jul 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    10c4d8a View commit details
Showing with 19 additions and 10 deletions.
  1. +1 −1 .github/workflows/build.yml
  2. +1 −1 panda_gym/envs/core.py
  3. +1 −1 panda_gym/envs/tasks/flip.py
  4. +3 −1 panda_gym/utils.py
  5. +1 −1 setup.py
  6. +7 −0 test/envs_test.py
  7. +5 −5 test/save_and_restore_test.py
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build

on: [pull_request]
on: [pull_request, workflow_dispatch]

jobs:
test:
2 changes: 1 addition & 1 deletion panda_gym/envs/core.py
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ def reset(
self, seed: Optional[int] = None, options: Optional[dict] = None
) -> Tuple[Dict[str, np.ndarray], Dict[str, Any]]:
super().reset(seed=seed, options=options)
self.task.np_random, seed = seeding.np_random(seed)
self.task.np_random = self.np_random
with self.sim.no_rendering():
self.robot.reset()
self.task.reset()
2 changes: 1 addition & 1 deletion panda_gym/envs/tasks/flip.py
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ def reset(self) -> None:

def _sample_goal(self) -> np.ndarray:
"""Randomize goal."""
goal = R.random().as_quat()
goal = R.random(random_state=self.np_random).as_quat()
return goal

def _sample_object(self) -> Tuple[np.ndarray, np.ndarray]:
4 changes: 3 additions & 1 deletion panda_gym/utils.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ def distance(a: np.ndarray, b: np.ndarray) -> np.ndarray:
np.ndarray: The distance between the arrays.
"""
assert a.shape == b.shape
return np.linalg.norm(a - b, axis=-1)
dist = np.linalg.norm(a - b, axis=-1)
# round at 1e-6 (ensure determinism and avoid numerical noise)
return np.round(dist, 6)


def angle_distance(a: np.ndarray, b: np.ndarray) -> np.ndarray:
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
include_package_data=True,
package_data={"panda_gym": ["version.txt"]},
version=__version__,
install_requires=["gymnasium>=0.26", "pybullet", "numpy", "scipy"],
install_requires=["gymnasium>=0.26", "pybullet", "numpy<2", "scipy"],
extras_require={
"develop": ["pytest-cov", "black", "isort", "pytype", "sphinx", "sphinx-rtd-theme"],
},
7 changes: 7 additions & 0 deletions test/envs_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gymnasium as gym
import pytest
from gymnasium.utils.env_checker import check_env

import panda_gym

@@ -22,3 +23,9 @@ def test_env(env_id):
"""Tests running panda gym envs."""
env = gym.make(env_id)
run_env(env)


@pytest.mark.parametrize("env_id", panda_gym.ENV_IDS)
def test_check_env(env_id):
"""Check envs with the env checker."""
check_env(gym.make(env_id).unwrapped, skip_render_check=True)
10 changes: 5 additions & 5 deletions test/save_and_restore_test.py
Original file line number Diff line number Diff line change
@@ -10,15 +10,15 @@ def test_save_and_restore_state():
env = gym.make("PandaReach-v3")
env.reset()

state_id = env.save_state()
state_id = env.unwrapped.save_state()

# Perform the action
action = env.action_space.sample()
observation1, _, _, _, _ = env.step(action)

# Restore and perform the same action
env.reset()
env.restore_state(state_id)
env.unwrapped.restore_state(state_id)
observation2, _, _, _, _ = env.step(action)

# The observations in both cases should be equals
@@ -30,7 +30,7 @@ def test_save_and_restore_state():
def test_remove_state():
env = gym.make("PandaReach-v3")
env.reset()
state_id = env.save_state()
env.remove_state(state_id)
state_id = env.unwrapped.save_state()
env.unwrapped.remove_state(state_id)
with pytest.raises(pybullet.error):
env.restore_state(state_id)
env.unwrapped.restore_state(state_id)