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

feat(environments): update safe issac gym environments #65

Merged
merged 11 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ repos:
- id: check-added-large-files
exclude: |
(?x)(
^safety_gymnasium/tasks/safe_issac_gym/assets/|
^safety_gymnasium/assets/meshes/|
^safety_gymnasium/assets/textures/|
)
Expand All @@ -35,6 +36,10 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: |
(?x)(
^safety_gymnasium/tasks/safe_issac_gym/
)
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down Expand Up @@ -64,6 +69,7 @@ repos:
- flake8-simplify
exclude: |
(?x)(
^safety_gymnasium/tasks/safe_issac_gym/|
^examples/|
^tests/|
^docs/conf.py$
Expand All @@ -75,6 +81,7 @@ repos:
additional_dependencies: [".[toml]"]
exclude: |
(?x)(
^safety_gymnasium/tasks/safe_issac_gym/assets/urdf/xarm_description/urdf/camera.gazebo.xacro$|
^docs/spelling_wordlist.txt$
)
- repo: local
Expand All @@ -87,6 +94,7 @@ repos:
require_serial: true
exclude: |
(?x)(
^safety_gymnasium/tasks/safe_issac_gym/|
^examples/|
^tests/|
^setup.py$|
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ pylint: pylint-install
$(PYTHON) -m pylint $(PROJECT_PATH)

flake8: flake8-install
$(PYTHON) -m flake8 --count --show-source --statistics
$(PYTHON) -m flake8 --count --show-source --statistics --exclude=safety_gymnasium/tasks/safe_issac_gym

py-format: py-format-install
$(PYTHON) -m isort --project $(PROJECT_PATH) --check $(PYTHON_FILES) && \
$(PYTHON) -m black --check $(PYTHON_FILES)

ruff: ruff-install
$(PYTHON) -m ruff check .
$(PYTHON) -m ruff check --exclude=safety_gymnasium/tasks/safe_issac_gym/ .

ruff-fix: ruff-install
$(PYTHON) -m ruff check . --fix --exit-non-zero-on-fix
Expand Down
4 changes: 2 additions & 2 deletions docs/components_of_environments/tasks/task_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Goal1
from safety_gymnasium.assets.geoms import Hazards
from safety_gymnasium.assets.objects import Vases
# Inherit the previous difficulty
from safety_gymnasium.tasks.goal.goal_level0 import GoalLevel0
from safety_gymnasium.tasks.safe_navigation.goal.goal_level0 import GoalLevel0


class GoalLevel1(GoalLevel0):
Expand Down Expand Up @@ -120,7 +120,7 @@ Goal2
"""Goal level 2."""

# Inherit the previous difficulty
from safety_gymnasium.tasks.goal.goal_level1 import GoalLevel1
from safety_gymnasium.tasks.safe_navigation.goal.goal_level1 import GoalLevel1


class GoalLevel2(GoalLevel1):
Expand Down
2 changes: 1 addition & 1 deletion examples/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ def run_random(env_name):

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--env', default='SafetyDoggoRace2-v0')
parser.add_argument('--env', default='SafetyAntVelocity-v0')
args = parser.parse_args()
run_random(args.env)
24 changes: 12 additions & 12 deletions safety_gymnasium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,80 +173,80 @@ def __combine(tasks, agents, max_episode_steps):

__register_helper(
env_id='SafetyHalfCheetahVelocity-v0',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_half_cheetah_velocity_v0:SafetyHalfCheetahVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_half_cheetah_velocity_v0:SafetyHalfCheetahVelocityEnv',
max_episode_steps=1000,
reward_threshold=4800.0,
)

__register_helper(
env_id='SafetyHopperVelocity-v0',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_hopper_velocity_v0:SafetyHopperVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_hopper_velocity_v0:SafetyHopperVelocityEnv',
max_episode_steps=1000,
reward_threshold=3800.0,
)

__register_helper(
env_id='SafetySwimmerVelocity-v0',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_swimmer_velocity_v0:SafetySwimmerVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_swimmer_velocity_v0:SafetySwimmerVelocityEnv',
max_episode_steps=1000,
reward_threshold=360.0,
)

__register_helper(
env_id='SafetyWalker2dVelocity-v0',
max_episode_steps=1000,
entry_point='safety_gymnasium.tasks.safety_velocity.safety_walker2d_velocity_v0:SafetyWalker2dVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_walker2d_velocity_v0:SafetyWalker2dVelocityEnv',
)

__register_helper(
env_id='SafetyAntVelocity-v0',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_ant_velocity_v0:SafetyAntVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_ant_velocity_v0:SafetyAntVelocityEnv',
max_episode_steps=1000,
reward_threshold=6000.0,
)

__register_helper(
env_id='SafetyHumanoidVelocity-v0',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_humanoid_velocity_v0:SafetyHumanoidVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_humanoid_velocity_v0:SafetyHumanoidVelocityEnv',
max_episode_steps=1000,
)

__register_helper(
env_id='SafetyHalfCheetahVelocity-v1',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_half_cheetah_velocity_v1:SafetyHalfCheetahVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_half_cheetah_velocity_v1:SafetyHalfCheetahVelocityEnv',
max_episode_steps=1000,
reward_threshold=4800.0,
)

__register_helper(
env_id='SafetyHopperVelocity-v1',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_hopper_velocity_v1:SafetyHopperVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_hopper_velocity_v1:SafetyHopperVelocityEnv',
max_episode_steps=1000,
reward_threshold=3800.0,
)

__register_helper(
env_id='SafetySwimmerVelocity-v1',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_swimmer_velocity_v1:SafetySwimmerVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_swimmer_velocity_v1:SafetySwimmerVelocityEnv',
max_episode_steps=1000,
reward_threshold=360.0,
)

__register_helper(
env_id='SafetyWalker2dVelocity-v1',
max_episode_steps=1000,
entry_point='safety_gymnasium.tasks.safety_velocity.safety_walker2d_velocity_v1:SafetyWalker2dVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_walker2d_velocity_v1:SafetyWalker2dVelocityEnv',
)

__register_helper(
env_id='SafetyAntVelocity-v1',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_ant_velocity_v1:SafetyAntVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_ant_velocity_v1:SafetyAntVelocityEnv',
max_episode_steps=1000,
reward_threshold=6000.0,
)

__register_helper(
env_id='SafetyHumanoidVelocity-v1',
entry_point='safety_gymnasium.tasks.safety_velocity.safety_humanoid_velocity_v1:SafetyHumanoidVelocityEnv',
entry_point='safety_gymnasium.tasks.safe_velocity.safety_humanoid_velocity_v1:SafetyHumanoidVelocityEnv',
max_episode_steps=1000,
)
47 changes: 28 additions & 19 deletions safety_gymnasium/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@
# ==============================================================================
"""Tasks in Safety-Gymnasium."""

from safety_gymnasium.tasks.button.button_level0 import ButtonLevel0
from safety_gymnasium.tasks.button.button_level1 import ButtonLevel1
from safety_gymnasium.tasks.button.button_level2 import ButtonLevel2
from safety_gymnasium.tasks.circle.circle_level0 import CircleLevel0
from safety_gymnasium.tasks.circle.circle_level1 import CircleLevel1
from safety_gymnasium.tasks.circle.circle_level2 import CircleLevel2
from safety_gymnasium.tasks.fading.fading_level0 import FadingEasyLevel0, FadingHardLevel0
from safety_gymnasium.tasks.fading.fading_level1 import FadingEasyLevel1, FadingHardLevel1
from safety_gymnasium.tasks.fading.fading_level2 import FadingEasyLevel2, FadingHardLevel2
from safety_gymnasium.tasks.goal.goal_level0 import GoalLevel0
from safety_gymnasium.tasks.goal.goal_level1 import GoalLevel1
from safety_gymnasium.tasks.goal.goal_level2 import GoalLevel2
from safety_gymnasium.tasks.push.push_level0 import PushLevel0
from safety_gymnasium.tasks.push.push_level1 import PushLevel1
from safety_gymnasium.tasks.push.push_level2 import PushLevel2
from safety_gymnasium.tasks.race.race_level0 import RaceLevel0
from safety_gymnasium.tasks.race.race_level1 import RaceLevel1
from safety_gymnasium.tasks.race.race_level2 import RaceLevel2
from safety_gymnasium.tasks.run.run import RunLevel0
from safety_gymnasium.tasks.safe_navigation.button.button_level0 import ButtonLevel0
from safety_gymnasium.tasks.safe_navigation.button.button_level1 import ButtonLevel1
from safety_gymnasium.tasks.safe_navigation.button.button_level2 import ButtonLevel2
from safety_gymnasium.tasks.safe_navigation.circle.circle_level0 import CircleLevel0
from safety_gymnasium.tasks.safe_navigation.circle.circle_level1 import CircleLevel1
from safety_gymnasium.tasks.safe_navigation.circle.circle_level2 import CircleLevel2
from safety_gymnasium.tasks.safe_navigation.goal.goal_level0 import GoalLevel0
from safety_gymnasium.tasks.safe_navigation.goal.goal_level1 import GoalLevel1
from safety_gymnasium.tasks.safe_navigation.goal.goal_level2 import GoalLevel2
from safety_gymnasium.tasks.safe_navigation.push.push_level0 import PushLevel0
from safety_gymnasium.tasks.safe_navigation.push.push_level1 import PushLevel1
from safety_gymnasium.tasks.safe_navigation.push.push_level2 import PushLevel2
from safety_gymnasium.tasks.safe_navigation.run.run import RunLevel0
from safety_gymnasium.tasks.safe_vision.fading.fading_level0 import (
FadingEasyLevel0,
FadingHardLevel0,
)
from safety_gymnasium.tasks.safe_vision.fading.fading_level1 import (
FadingEasyLevel1,
FadingHardLevel1,
)
from safety_gymnasium.tasks.safe_vision.fading.fading_level2 import (
FadingEasyLevel2,
FadingHardLevel2,
)
from safety_gymnasium.tasks.safe_vision.race.race_level0 import RaceLevel0
from safety_gymnasium.tasks.safe_vision.race.race_level1 import RaceLevel1
from safety_gymnasium.tasks.safe_vision.race.race_level2 import RaceLevel2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"min": [-0.256442, -0.837097, -0.255704], "max": [0.270453, 0.997018, 0.270788]}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"model_id": "f0a5f6d2cf8fcb72c12d8e00a78db6e2", "anno_id": "4064", "user_id": "zhouwenxian", "time_in_sec": "88", "version": "3", "model_cat": "Bottle"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" ?>
<robot name="partnet_f0a5f6d2cf8fcb72c12d8e00a78db6e2">
<link name="base"/>
<link name="link_0">
<visual name="lid-7">
<origin xyz="-0.007005959241653967 0 -0.007542109902568375"/>
<geometry>
<mesh filename="textured_objs/original-7.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<collision>
<origin xyz="-0.007005959241653967 0 -0.007542109902568375"/>
<geometry>
<mesh filename="textured_objs/original-7.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
</link>
<joint name="joint_0" type="continuous">
<origin xyz="0.0 0 0.0"/>
<axis xyz="0 1 0"/>
<child link="link_0"/>
<parent link="link_0_helper"/>
</joint>
<link name="link_1">
<visual name="body-5">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-4.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<visual name="body-5">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-3.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<visual name="body-5">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-8.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<visual name="body-5">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-6.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<visual name="body-5">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-2.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<visual name="neck-6">
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-5.obj" scale="0.15 0.15 0.15"/>
</geometry>
</visual>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-4.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-3.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-8.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-6.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-2.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
<collision>
<origin xyz="0 0 0"/>
<geometry>
<mesh filename="textured_objs/original-5.obj" scale="0.15 0.15 0.15"/>
</geometry>
</collision>
</link>
<joint name="joint_1" type="fixed">
<origin rpy="1.570796326794897 0 -1.570796326794897" xyz="0 0 0"/>
<child link="link_1"/>
<parent link="base"/>
</joint>
<link name="link_0_helper"/>
<joint name="joint_2" type="prismatic">
<origin xyz="0.007005959241653967 0 0.007542109902568375"/>
<axis xyz="0 1 0"/>
<child link="link_0_helper"/>
<parent link="link_1"/>
<limit lower="0" upper="0.06400000000000006"/>
</joint>
</robot>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":0,"parent":1,"joint":"slider","name":"lid","parts":[{"id":7,"name":"lid","children":[]}],"jointData":{"axis":{"origin":[0.007005959241653967,0,0.007542109902568375],"direction":[0,1,0]},"limit":{"a":0,"b":0.06400000000000006,"noLimit":false,"rotates":true,"noRotationLimit":false,"rotationLimit":180}}},{"id":1,"parent":-1,"joint":"free","name":"body","parts":[{"id":5,"name":"body","children":[]},{"id":6,"name":"neck","children":[]}],"jointData":{}}]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 bottle Bottle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 normal_bottle Normal Bottle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 body Body
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6 neck Neck
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 lid Lid
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 bottle bottle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 normal_bottle normal_bottle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 body body
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3 neck neck
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 lid lid
Loading