reaf-sim 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reaf/simulation/__init__.py +15 -0
- reaf/simulation/torch/__init__.py +153 -0
- reaf/simulation/torch/_src/builders/__init__.py +17 -0
- reaf/simulation/torch/_src/builders/config.py +69 -0
- reaf/simulation/torch/_src/builders/config_test.py +55 -0
- reaf/simulation/torch/_src/builders/flat_scene/__init__.py +31 -0
- reaf/simulation/torch/_src/builders/flat_scene/build.py +425 -0
- reaf/simulation/torch/_src/builders/flat_scene/build_test.py +257 -0
- reaf/simulation/torch/_src/builders/flat_scene/config.py +350 -0
- reaf/simulation/torch/_src/common/action_history.py +173 -0
- reaf/simulation/torch/_src/common/action_history_test.py +255 -0
- reaf/simulation/torch/_src/common/actuator_device.py +387 -0
- reaf/simulation/torch/_src/common/actuator_device_test.py +448 -0
- reaf/simulation/torch/_src/common/articulated_device.py +176 -0
- reaf/simulation/torch/_src/common/articulated_device_test.py +129 -0
- reaf/simulation/torch/_src/common/batched_camera_device.py +215 -0
- reaf/simulation/torch/_src/common/batched_camera_device_test.py +132 -0
- reaf/simulation/torch/_src/common/camera_device.py +414 -0
- reaf/simulation/torch/_src/common/camera_device_test.py +454 -0
- reaf/simulation/torch/_src/common/clock_device.py +90 -0
- reaf/simulation/torch/_src/common/clock_device_test.py +122 -0
- reaf/simulation/torch/_src/common/contact_sensor_device.py +281 -0
- reaf/simulation/torch/_src/common/contact_sensor_device_test.py +274 -0
- reaf/simulation/torch/_src/common/default_discount_provider.py +65 -0
- reaf/simulation/torch/_src/common/delay_buffer.py +160 -0
- reaf/simulation/torch/_src/common/delay_buffer_test.py +172 -0
- reaf/simulation/torch/_src/common/free_device.py +349 -0
- reaf/simulation/torch/_src/common/free_device_test.py +277 -0
- reaf/simulation/torch/_src/common/functional_device.py +115 -0
- reaf/simulation/torch/_src/common/functional_observation.py +325 -0
- reaf/simulation/torch/_src/common/functional_observation_test.py +603 -0
- reaf/simulation/torch/_src/common/functional_reset.py +105 -0
- reaf/simulation/torch/_src/common/functional_reward.py +174 -0
- reaf/simulation/torch/_src/common/functional_reward_test.py +191 -0
- reaf/simulation/torch/_src/common/functional_termination.py +78 -0
- reaf/simulation/torch/_src/common/functional_termination_test.py +65 -0
- reaf/simulation/torch/_src/common/inside_site_device.py +124 -0
- reaf/simulation/torch/_src/common/inside_site_device_test.py +137 -0
- reaf/simulation/torch/_src/common/math.py +542 -0
- reaf/simulation/torch/_src/common/math_test.py +566 -0
- reaf/simulation/torch/_src/common/model_randomization.py +313 -0
- reaf/simulation/torch/_src/common/model_randomization_test.py +459 -0
- reaf/simulation/torch/_src/common/mujoco_camera_device.py +496 -0
- reaf/simulation/torch/_src/common/mujoco_camera_device_test.py +527 -0
- reaf/simulation/torch/_src/common/multi_asset_device.py +457 -0
- reaf/simulation/torch/_src/common/multi_asset_device_test.py +544 -0
- reaf/simulation/torch/_src/common/noise.py +457 -0
- reaf/simulation/torch/_src/common/noise_test.py +244 -0
- reaf/simulation/torch/_src/common/processors.py +606 -0
- reaf/simulation/torch/_src/common/processors_test.py +478 -0
- reaf/simulation/torch/_src/common/resetter.py +201 -0
- reaf/simulation/torch/_src/common/resetter_test.py +439 -0
- reaf/simulation/torch/_src/common/site_device.py +137 -0
- reaf/simulation/torch/_src/common/site_device_test.py +84 -0
- reaf/simulation/torch/_src/common/spec_helper.py +128 -0
- reaf/simulation/torch/_src/common/tensors.py +46 -0
- reaf/simulation/torch/_src/common/tensors_test.py +85 -0
- reaf/simulation/torch/_src/common/timeout_termination_checker.py +55 -0
- reaf/simulation/torch/_src/common/timeout_termination_checker_test.py +163 -0
- reaf/simulation/torch/_src/common/zero_reward_provider.py +65 -0
- reaf/simulation/torch/_src/common/zero_reward_provider_test.py +60 -0
- reaf/simulation/torch/_src/core/clock.py +96 -0
- reaf/simulation/torch/_src/core/clock_test.py +178 -0
- reaf/simulation/torch/_src/core/device.py +78 -0
- reaf/simulation/torch/_src/core/device_layer.py +297 -0
- reaf/simulation/torch/_src/core/device_layer_test.py +1182 -0
- reaf/simulation/torch/_src/core/discount_provider.py +35 -0
- reaf/simulation/torch/_src/core/environment.py +690 -0
- reaf/simulation/torch/_src/core/environment_test.py +764 -0
- reaf/simulation/torch/_src/core/feature_producer.py +41 -0
- reaf/simulation/torch/_src/core/mujoco_types.py +182 -0
- reaf/simulation/torch/_src/core/mujoco_types_test.py +177 -0
- reaf/simulation/torch/_src/core/observation_space_adapter.py +44 -0
- reaf/simulation/torch/_src/core/profile.py +371 -0
- reaf/simulation/torch/_src/core/protocols.py +165 -0
- reaf/simulation/torch/_src/core/reward_provider.py +44 -0
- reaf/simulation/torch/_src/core/simulator.py +315 -0
- reaf/simulation/torch/_src/core/simulator_test.py +248 -0
- reaf/simulation/torch/_src/core/substep_commands_processor.py +63 -0
- reaf/simulation/torch/_src/core/substep_measurements_processor.py +66 -0
- reaf/simulation/torch/_src/core/task_layer.py +260 -0
- reaf/simulation/torch/_src/core/termination_checker.py +35 -0
- reaf/simulation/torch/_src/core/torch_wrapper.py +1216 -0
- reaf/simulation/torch/_src/core/torch_wrapper_test.py +1658 -0
- reaf/simulation/torch/_src/core/types.py +85 -0
- reaf/simulation/torch/examples/__init__.py +14 -0
- reaf/simulation/torch/examples/cartpole.py +167 -0
- reaf/simulation/torch/examples/cartpole_test.py +78 -0
- reaf/simulation/torch/viewer/__init__.py +17 -0
- reaf/simulation/torch/viewer/_src/sim_backend.py +187 -0
- reaf/simulation/torch/viewer/_src/viewer.py +157 -0
- reaf/simulation/torch/viewer/_src/viewer_test.py +97 -0
- reaf/simulation/viewer/line_plots.py +197 -0
- reaf/simulation/viewer/messages.py +39 -0
- reaf/simulation/viewer/sim_plugin.py +241 -0
- reaf/simulation/viewer/sim_plugin_test.py +281 -0
- reaf/simulation/viewer/viewer_plugin.py +433 -0
- reaf/simulation/viewer/viewer_plugin_test.py +389 -0
- reaf_sim-0.0.1.dist-info/METADATA +128 -0
- reaf_sim-0.0.1.dist-info/RECORD +103 -0
- reaf_sim-0.0.1.dist-info/WHEEL +5 -0
- reaf_sim-0.0.1.dist-info/licenses/LICENSE +201 -0
- reaf_sim-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Robotics Environment Authoring Framework - Simulation Modules."""
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""reaf-sim vectorized simulation framework."""
|
|
16
|
+
|
|
17
|
+
from reaf.simulation.torch._src.builders import flat_scene
|
|
18
|
+
from reaf.simulation.torch._src.common import action_history
|
|
19
|
+
from reaf.simulation.torch._src.common import actuator_device
|
|
20
|
+
from reaf.simulation.torch._src.common import articulated_device
|
|
21
|
+
from reaf.simulation.torch._src.common import batched_camera_device
|
|
22
|
+
from reaf.simulation.torch._src.common import camera_device
|
|
23
|
+
from reaf.simulation.torch._src.common import clock_device
|
|
24
|
+
from reaf.simulation.torch._src.common import contact_sensor_device
|
|
25
|
+
from reaf.simulation.torch._src.common import default_discount_provider
|
|
26
|
+
from reaf.simulation.torch._src.common import delay_buffer
|
|
27
|
+
from reaf.simulation.torch._src.common import free_device
|
|
28
|
+
from reaf.simulation.torch._src.common import functional_device
|
|
29
|
+
from reaf.simulation.torch._src.common import functional_observation
|
|
30
|
+
from reaf.simulation.torch._src.common import functional_reset
|
|
31
|
+
from reaf.simulation.torch._src.common import functional_reward
|
|
32
|
+
from reaf.simulation.torch._src.common import functional_termination
|
|
33
|
+
from reaf.simulation.torch._src.common import inside_site_device
|
|
34
|
+
from reaf.simulation.torch._src.common import math
|
|
35
|
+
from reaf.simulation.torch._src.common import model_randomization
|
|
36
|
+
from reaf.simulation.torch._src.common import mujoco_camera_device
|
|
37
|
+
from reaf.simulation.torch._src.common import multi_asset_device
|
|
38
|
+
from reaf.simulation.torch._src.common import noise
|
|
39
|
+
from reaf.simulation.torch._src.common import processors
|
|
40
|
+
from reaf.simulation.torch._src.common import resetter
|
|
41
|
+
from reaf.simulation.torch._src.common import site_device
|
|
42
|
+
from reaf.simulation.torch._src.common import spec_helper
|
|
43
|
+
from reaf.simulation.torch._src.common import tensors
|
|
44
|
+
from reaf.simulation.torch._src.common import timeout_termination_checker
|
|
45
|
+
from reaf.simulation.torch._src.common import zero_reward_provider
|
|
46
|
+
from reaf.simulation.torch._src.common.action_history import ActionHistory
|
|
47
|
+
from reaf.simulation.torch._src.common.actuator_device import ActuatorDevice
|
|
48
|
+
from reaf.simulation.torch._src.common.actuator_device import ControlMode
|
|
49
|
+
from reaf.simulation.torch._src.common.actuator_device import TransmissionType
|
|
50
|
+
from reaf.simulation.torch._src.common.articulated_device import ArticulatedDevice
|
|
51
|
+
from reaf.simulation.torch._src.common.batched_camera_device import BatchedMujocoCameraDevice
|
|
52
|
+
from reaf.simulation.torch._src.common.camera_device import CameraDevice
|
|
53
|
+
from reaf.simulation.torch._src.common.clock_device import ClockDevice
|
|
54
|
+
from reaf.simulation.torch._src.common.contact_sensor_device import ContactField
|
|
55
|
+
from reaf.simulation.torch._src.common.contact_sensor_device import ContactSensorDevice
|
|
56
|
+
from reaf.simulation.torch._src.common.contact_sensor_device import ObjType
|
|
57
|
+
from reaf.simulation.torch._src.common.contact_sensor_device import ReduceMode
|
|
58
|
+
from reaf.simulation.torch._src.common.default_discount_provider import DefaultDiscountProvider
|
|
59
|
+
from reaf.simulation.torch._src.common.delay_buffer import DelayBuffer
|
|
60
|
+
from reaf.simulation.torch._src.common.free_device import FreeDevice
|
|
61
|
+
from reaf.simulation.torch._src.common.free_device import MocapDevice
|
|
62
|
+
from reaf.simulation.torch._src.common.functional_device import joint
|
|
63
|
+
from reaf.simulation.torch._src.common.functional_device import joint_pos
|
|
64
|
+
from reaf.simulation.torch._src.common.functional_device import joint_vel
|
|
65
|
+
from reaf.simulation.torch._src.common.functional_device import MeasurementDevice
|
|
66
|
+
from reaf.simulation.torch._src.common.functional_observation import FunctionalObservationAdapter
|
|
67
|
+
from reaf.simulation.torch._src.common.functional_reset import FunctionalEnvironmentReset
|
|
68
|
+
from reaf.simulation.torch._src.common.functional_reset import TYPE_KEY
|
|
69
|
+
from reaf.simulation.torch._src.common.functional_reset import TYPE_RESET
|
|
70
|
+
from reaf.simulation.torch._src.common.functional_reset import TYPE_STARTUP
|
|
71
|
+
from reaf.simulation.torch._src.common.functional_reward import FunctionalRewardProvider
|
|
72
|
+
from reaf.simulation.torch._src.common.functional_reward import PassthroughRewardProvider
|
|
73
|
+
from reaf.simulation.torch._src.common.functional_termination import FunctionalTerminationChecker
|
|
74
|
+
from reaf.simulation.torch._src.common.functional_termination import TerminationResult
|
|
75
|
+
from reaf.simulation.torch._src.common.inside_site_device import InsideSiteDevice
|
|
76
|
+
from reaf.simulation.torch._src.common.model_randomization import randomize_actuator_gains
|
|
77
|
+
from reaf.simulation.torch._src.common.model_randomization import randomize_field
|
|
78
|
+
from reaf.simulation.torch._src.common.model_randomization import randomize_quat
|
|
79
|
+
from reaf.simulation.torch._src.common.mujoco_camera_device import MujocoCameraDevice
|
|
80
|
+
from reaf.simulation.torch._src.common.mujoco_camera_device import RenderMode
|
|
81
|
+
from reaf.simulation.torch._src.common.multi_asset_device import MultiAsset
|
|
82
|
+
from reaf.simulation.torch._src.common.multi_asset_device import MultiAssetDevice
|
|
83
|
+
from reaf.simulation.torch._src.common.processors import DeltaActions
|
|
84
|
+
from reaf.simulation.torch._src.common.processors import StochasticSubstepCommands
|
|
85
|
+
from reaf.simulation.torch._src.common.processors import StochasticSubstepMeasurements
|
|
86
|
+
from reaf.simulation.torch._src.common.processors import TransformActions
|
|
87
|
+
from reaf.simulation.torch._src.common.resetter import CompositeResetter
|
|
88
|
+
from reaf.simulation.torch._src.common.resetter import DomainRandomizationResetter
|
|
89
|
+
from reaf.simulation.torch._src.common.resetter import NanTerminationResetter
|
|
90
|
+
from reaf.simulation.torch._src.common.resetter import TerminationResetter
|
|
91
|
+
from reaf.simulation.torch._src.common.site_device import SiteDevice
|
|
92
|
+
from reaf.simulation.torch._src.common.spec_helper import SpecHelper
|
|
93
|
+
from reaf.simulation.torch._src.common.spec_helper import SpecTemplate
|
|
94
|
+
from reaf.simulation.torch._src.common.timeout_termination_checker import TimeoutTerminationChecker
|
|
95
|
+
from reaf.simulation.torch._src.common.zero_reward_provider import ZeroRewardProvider
|
|
96
|
+
from reaf.simulation.torch._src.core import clock
|
|
97
|
+
from reaf.simulation.torch._src.core import device
|
|
98
|
+
from reaf.simulation.torch._src.core import device_layer
|
|
99
|
+
from reaf.simulation.torch._src.core import discount_provider
|
|
100
|
+
from reaf.simulation.torch._src.core import environment
|
|
101
|
+
from reaf.simulation.torch._src.core import feature_producer
|
|
102
|
+
from reaf.simulation.torch._src.core import mujoco_types
|
|
103
|
+
from reaf.simulation.torch._src.core import observation_space_adapter
|
|
104
|
+
from reaf.simulation.torch._src.core import profile
|
|
105
|
+
from reaf.simulation.torch._src.core import protocols
|
|
106
|
+
from reaf.simulation.torch._src.core import reward_provider
|
|
107
|
+
from reaf.simulation.torch._src.core import simulator
|
|
108
|
+
from reaf.simulation.torch._src.core import substep_commands_processor
|
|
109
|
+
from reaf.simulation.torch._src.core import substep_measurements_processor
|
|
110
|
+
from reaf.simulation.torch._src.core import task_layer
|
|
111
|
+
from reaf.simulation.torch._src.core import termination_checker
|
|
112
|
+
from reaf.simulation.torch._src.core import torch_wrapper
|
|
113
|
+
from reaf.simulation.torch._src.core import types
|
|
114
|
+
from reaf.simulation.torch._src.core.clock import Clock
|
|
115
|
+
from reaf.simulation.torch._src.core.device import Device
|
|
116
|
+
from reaf.simulation.torch._src.core.device_layer import DeviceLayer
|
|
117
|
+
from reaf.simulation.torch._src.core.discount_provider import DiscountProvider
|
|
118
|
+
from reaf.simulation.torch._src.core.environment import AutoResetMode
|
|
119
|
+
from reaf.simulation.torch._src.core.environment import EndOfEpisodeHandler
|
|
120
|
+
from reaf.simulation.torch._src.core.environment import Environment
|
|
121
|
+
from reaf.simulation.torch._src.core.environment import EnvironmentReset
|
|
122
|
+
from reaf.simulation.torch._src.core.feature_producer import FeatureProducer
|
|
123
|
+
from reaf.simulation.torch._src.core.mujoco_types import get_spec_by_obj_type
|
|
124
|
+
from reaf.simulation.torch._src.core.mujoco_types import match_names
|
|
125
|
+
from reaf.simulation.torch._src.core.mujoco_types import OBJ_TYPE_TO_ACCESSOR
|
|
126
|
+
from reaf.simulation.torch._src.core.mujoco_types import PREFIX_TO_OBJ_TYPE
|
|
127
|
+
from reaf.simulation.torch._src.core.mujoco_types import resolve_names
|
|
128
|
+
from reaf.simulation.torch._src.core.mujoco_types import resolve_values
|
|
129
|
+
from reaf.simulation.torch._src.core.mujoco_types import soft_joint_limits
|
|
130
|
+
from reaf.simulation.torch._src.core.mujoco_types import SPEC_TYPE_INFO
|
|
131
|
+
from reaf.simulation.torch._src.core.observation_space_adapter import ObservationSpaceAdapter
|
|
132
|
+
from reaf.simulation.torch._src.core.protocols import TorchDeviceLayer
|
|
133
|
+
from reaf.simulation.torch._src.core.reward_provider import RewardProvider
|
|
134
|
+
from reaf.simulation.torch._src.core.reward_provider import RewardSpec
|
|
135
|
+
from reaf.simulation.torch._src.core.reward_provider import RewardValue
|
|
136
|
+
from reaf.simulation.torch._src.core.simulator import Simulator
|
|
137
|
+
from reaf.simulation.torch._src.core.substep_commands_processor import SubstepCommandsProcessor
|
|
138
|
+
from reaf.simulation.torch._src.core.substep_measurements_processor import SubstepMeasurementsProcessor
|
|
139
|
+
from reaf.simulation.torch._src.core.task_layer import TaskLayer
|
|
140
|
+
from reaf.simulation.torch._src.core.termination_checker import TerminationChecker
|
|
141
|
+
from reaf.simulation.torch._src.core.torch_wrapper import JointType
|
|
142
|
+
from reaf.simulation.torch._src.core.torch_wrapper import MjField
|
|
143
|
+
from reaf.simulation.torch._src.core.torch_wrapper import MjObjType
|
|
144
|
+
from reaf.simulation.torch._src.core.torch_wrapper import SetConstLevel
|
|
145
|
+
from reaf.simulation.torch._src.core.torch_wrapper import TorchTensor
|
|
146
|
+
from reaf.simulation.torch._src.core.torch_wrapper import TorchWrapper
|
|
147
|
+
from reaf.simulation.torch._src.core.types import ArrayType
|
|
148
|
+
from reaf.simulation.torch._src.core.types import Data
|
|
149
|
+
from reaf.simulation.torch._src.core.types import Impl
|
|
150
|
+
from reaf.simulation.torch._src.core.types import Model
|
|
151
|
+
from reaf.simulation.torch._src.core.types import NUMPY_TO_TORCH_DTYPE
|
|
152
|
+
from reaf.simulation.torch._src.core.types import Term
|
|
153
|
+
from reaf.simulation.torch._src.core.types import TORCH_TO_NUMPY_DTYPE
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Sim builders package."""
|
|
16
|
+
|
|
17
|
+
from reaf.simulation.torch._src.builders import flat_scene as flat_scene
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Shared configuration for REAF environment builders."""
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from typing import Literal
|
|
19
|
+
|
|
20
|
+
import mujoco
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class Sim:
|
|
25
|
+
"""Simulation parameters."""
|
|
26
|
+
|
|
27
|
+
nworld: int = 1
|
|
28
|
+
xpu_device: str = "cuda:0"
|
|
29
|
+
impl: Literal["warp", "cpp"] = "warp"
|
|
30
|
+
control_timestep: float = 0.02
|
|
31
|
+
simulation_timestep: float = 0.005
|
|
32
|
+
jacobian: mujoco.mjtJacobian | None = None
|
|
33
|
+
integrator: mujoco.mjtIntegrator | None = None
|
|
34
|
+
iterations: int | None = None
|
|
35
|
+
ls_iterations: int | None = None
|
|
36
|
+
impratio: float | None = None
|
|
37
|
+
cone: mujoco.mjtCone | None = None
|
|
38
|
+
solver: mujoco.mjtSolver | None = None
|
|
39
|
+
gravity: tuple[float, float, float] | None = None
|
|
40
|
+
ccd_iterations: int | None = None
|
|
41
|
+
# warp only
|
|
42
|
+
nconmax: int | None = None
|
|
43
|
+
njmax: int | None = None
|
|
44
|
+
nccdmax: int | None = None
|
|
45
|
+
nvmax: int | None = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def apply_sim_config(spec: mujoco.MjSpec, sim: Sim) -> mujoco.MjSpec:
|
|
49
|
+
"""Applies physics and solver parameters from Sim config to an MjSpec."""
|
|
50
|
+
spec.option.timestep = sim.simulation_timestep
|
|
51
|
+
if sim.jacobian is not None:
|
|
52
|
+
spec.option.jacobian = sim.jacobian
|
|
53
|
+
if sim.integrator is not None:
|
|
54
|
+
spec.option.integrator = sim.integrator
|
|
55
|
+
if sim.iterations is not None:
|
|
56
|
+
spec.option.iterations = sim.iterations
|
|
57
|
+
if sim.ls_iterations is not None:
|
|
58
|
+
spec.option.ls_iterations = sim.ls_iterations
|
|
59
|
+
if sim.impratio is not None:
|
|
60
|
+
spec.option.impratio = sim.impratio
|
|
61
|
+
if sim.cone is not None:
|
|
62
|
+
spec.option.cone = sim.cone
|
|
63
|
+
if sim.solver is not None:
|
|
64
|
+
spec.option.solver = sim.solver
|
|
65
|
+
if sim.gravity is not None:
|
|
66
|
+
spec.option.gravity = sim.gravity
|
|
67
|
+
if sim.ccd_iterations is not None:
|
|
68
|
+
spec.option.ccd_iterations = sim.ccd_iterations
|
|
69
|
+
return spec
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Tests for Sim config and helper utilities."""
|
|
16
|
+
|
|
17
|
+
from absl.testing import absltest
|
|
18
|
+
import mujoco
|
|
19
|
+
from reaf.simulation.torch._src.builders import config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ConfigTest(absltest.TestCase):
|
|
23
|
+
|
|
24
|
+
def test_apply_sim_config(self):
|
|
25
|
+
mj_spec = mujoco.MjSpec()
|
|
26
|
+
sim = config.Sim(
|
|
27
|
+
iterations=12,
|
|
28
|
+
ls_iterations=18,
|
|
29
|
+
impratio=2.0,
|
|
30
|
+
solver=mujoco.mjtSolver.mjSOL_CG,
|
|
31
|
+
jacobian=mujoco.mjtJacobian.mjJAC_SPARSE,
|
|
32
|
+
cone=mujoco.mjtCone.mjCONE_ELLIPTIC,
|
|
33
|
+
)
|
|
34
|
+
result = config.apply_sim_config(mj_spec, sim)
|
|
35
|
+
self.assertIs(result, mj_spec)
|
|
36
|
+
self.assertEqual(mj_spec.option.iterations, 12)
|
|
37
|
+
self.assertEqual(mj_spec.option.ls_iterations, 18)
|
|
38
|
+
self.assertAlmostEqual(mj_spec.option.impratio, 2.0)
|
|
39
|
+
self.assertEqual(mj_spec.option.solver, mujoco.mjtSolver.mjSOL_CG)
|
|
40
|
+
self.assertEqual(mj_spec.option.jacobian, mujoco.mjtJacobian.mjJAC_SPARSE)
|
|
41
|
+
self.assertEqual(mj_spec.option.cone, mujoco.mjtCone.mjCONE_ELLIPTIC)
|
|
42
|
+
|
|
43
|
+
def test_apply_sim_config_preserves_unspecified_options(self):
|
|
44
|
+
mj_spec = mujoco.MjSpec()
|
|
45
|
+
mj_spec.option.iterations = 77
|
|
46
|
+
mj_spec.option.impratio = 3.3
|
|
47
|
+
sim = config.Sim()
|
|
48
|
+
result = config.apply_sim_config(mj_spec, sim)
|
|
49
|
+
self.assertIs(result, mj_spec)
|
|
50
|
+
self.assertEqual(mj_spec.option.iterations, 77)
|
|
51
|
+
self.assertAlmostEqual(mj_spec.option.impratio, 3.3)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
absltest.main()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Copyright 2026 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Flat scene builder package."""
|
|
16
|
+
|
|
17
|
+
from reaf.simulation.torch._src.builders.config import apply_sim_config
|
|
18
|
+
from reaf.simulation.torch._src.builders.config import Sim
|
|
19
|
+
from reaf.simulation.torch._src.builders.flat_scene.build import build_device_layer
|
|
20
|
+
from reaf.simulation.torch._src.builders.flat_scene.build import build_env
|
|
21
|
+
from reaf.simulation.torch._src.builders.flat_scene.build import build_scene
|
|
22
|
+
from reaf.simulation.torch._src.builders.flat_scene.build import build_task_layer
|
|
23
|
+
from reaf.simulation.torch._src.builders.flat_scene.build import make_deployment_config
|
|
24
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import Component
|
|
25
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import DeviceLayer
|
|
26
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import Environment
|
|
27
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import Obs
|
|
28
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import ObsGroup
|
|
29
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import Reward
|
|
30
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import TaskLayer
|
|
31
|
+
from reaf.simulation.torch._src.builders.flat_scene.config import Term
|