Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KincoActuatorIsaacLab
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kevin
KincoActuatorIsaacLab
Commits
a666312e
Commit
a666312e
authored
Jul 24, 2023
by
Mayank Mittal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes extra file for test_reward_manager.py
parent
f9eca34c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
97 deletions
+0
-97
test_reward_manager.py
...e/extensions/omni.isaac.orbit/test/test_reward_manager.py
+0
-97
No files found.
source/extensions/omni.isaac.orbit/test/test_reward_manager.py
deleted
100644 → 0
View file @
f9eca34c
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import
unittest
from
collections
import
namedtuple
from
omni.isaac.orbit.utils.mdp.reward_manager
import
RewardManager
class
DefaultRewardManager
(
RewardManager
):
def
grilled_chicken
(
self
,
env
):
return
1
def
grilled_chicken_with_bbq
(
self
,
env
,
bbq
:
bool
):
return
0
def
grilled_chicken_with_curry
(
self
,
env
,
hot
:
bool
):
return
0
def
grilled_chicken_with_yoghurt
(
self
,
env
,
hot
:
bool
,
bland
:
float
):
return
0
class
TestRewardManager
(
unittest
.
TestCase
):
"""Test cases for various situations with reward manager."""
def
setUp
(
self
)
->
None
:
self
.
env
=
namedtuple
(
"IsaacEnv"
,
[])()
self
.
device
=
"cpu"
self
.
num_envs
=
20
self
.
dt
=
0.1
def
test_str
(
self
):
cfg
=
{
"grilled_chicken"
:
{
"weight"
:
10
},
"grilled_chicken_with_bbq"
:
{
"weight"
:
5
,
"bbq"
:
True
},
"grilled_chicken_with_yoghurt"
:
{
"weight"
:
1.0
,
"hot"
:
False
,
"bland"
:
2.0
},
}
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
self
.
assertEqual
(
len
(
self
.
rew_man
.
active_terms
),
3
)
# print the expected string
print
()
print
(
self
.
rew_man
)
def
test_config_terms
(
self
):
cfg
=
{
"grilled_chicken"
:
{
"weight"
:
10
},
"grilled_chicken_with_curry"
:
{
"weight"
:
0.0
,
"hot"
:
False
}}
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
self
.
assertEqual
(
len
(
self
.
rew_man
.
active_terms
),
1
)
def
test_compute
(
self
):
cfg
=
{
"grilled_chicken"
:
{
"weight"
:
10
},
"grilled_chicken_with_curry"
:
{
"weight"
:
0.0
,
"hot"
:
False
}}
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
# compute expected reward
expected_reward
=
cfg
[
"grilled_chicken"
][
"weight"
]
*
self
.
dt
# compute reward using manager
rewards
=
self
.
rew_man
.
compute
()
# check the reward for environment index 0
self
.
assertEqual
(
float
(
rewards
[
0
]),
expected_reward
)
def
test_active_terms
(
self
):
cfg
=
{
"grilled_chicken"
:
{
"weight"
:
10
},
"grilled_chicken_with_bbq"
:
{
"weight"
:
5
,
"bbq"
:
True
},
"grilled_chicken_with_curry"
:
{
"weight"
:
0.0
,
"hot"
:
False
},
}
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
self
.
assertEqual
(
len
(
self
.
rew_man
.
active_terms
),
2
)
def
test_invalid_reward_name
(
self
):
cfg
=
{
"grilled_chicken"
:
{
"weight"
:
10
},
"grilled_chicken_with_bbq"
:
{
"weight"
:
5
,
"bbq"
:
True
},
"grilled_chicken_with_no_bbq"
:
{
"weight"
:
0.1
,
"hot"
:
False
},
}
with
self
.
assertRaises
(
AttributeError
):
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
def
test_invalid_reward_weight_config
(
self
):
cfg
=
{
"grilled_chicken"
:
{}}
with
self
.
assertRaises
(
KeyError
):
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
def
test_invalid_reward_config
(
self
):
cfg
=
{
"grilled_chicken_with_bbq"
:
{
"weight"
:
0.1
,
"hot"
:
False
},
"grilled_chicken_with_yoghurt"
:
{
"weight"
:
2.0
,
"hot"
:
False
},
}
with
self
.
assertRaises
(
ValueError
):
self
.
rew_man
=
DefaultRewardManager
(
cfg
,
self
.
env
,
self
.
num_envs
,
self
.
dt
,
self
.
device
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment