reaf 1.0.0__tar.gz

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.
Files changed (102) hide show
  1. reaf-1.0.0/CMakeLists.txt +76 -0
  2. reaf-1.0.0/CONTRIBUTING.md +6 -0
  3. reaf-1.0.0/LICENSE +202 -0
  4. reaf-1.0.0/PKG-INFO +206 -0
  5. reaf-1.0.0/README.md +179 -0
  6. reaf-1.0.0/example/agent_environment_loop_example.py +102 -0
  7. reaf-1.0.0/example/ideal_robot.py +86 -0
  8. reaf-1.0.0/example/ideal_robot_coordinator.py +37 -0
  9. reaf-1.0.0/example/ideal_robot_device.py +75 -0
  10. reaf-1.0.0/example/pd_agent.py +104 -0
  11. reaf-1.0.0/example/robot_environment.py +164 -0
  12. reaf-1.0.0/example/stdout_logger.py +46 -0
  13. reaf-1.0.0/example/task_logic_elements.py +153 -0
  14. reaf-1.0.0/pyproject.toml +63 -0
  15. reaf-1.0.0/src/reaf/__init__.py +0 -0
  16. reaf-1.0.0/src/reaf/common/clip_commands_processor.py +123 -0
  17. reaf-1.0.0/src/reaf/common/concatenate_features_producer.py +204 -0
  18. reaf-1.0.0/src/reaf/common/crop_image_features_producer.py +131 -0
  19. reaf-1.0.0/src/reaf/common/delta_to_absolute_commands_processor.py +137 -0
  20. reaf-1.0.0/src/reaf/common/environment_reset_from_callable.py +28 -0
  21. reaf-1.0.0/src/reaf/common/external_signal_sparse_reward_provider.py +81 -0
  22. reaf-1.0.0/src/reaf/common/external_signal_termination_checker.py +69 -0
  23. reaf-1.0.0/src/reaf/common/flatten_features_producer.py +117 -0
  24. reaf-1.0.0/src/reaf/common/map_utils.py +70 -0
  25. reaf-1.0.0/src/reaf/common/maximum_steps_termination_checker.py +94 -0
  26. reaf-1.0.0/src/reaf/common/maximum_wall_clock_time_termination_checker.py +97 -0
  27. reaf-1.0.0/src/reaf/common/moving_average_filter_commands_processor.py +120 -0
  28. reaf-1.0.0/src/reaf/common/out_of_bounds_termination_checker.py +70 -0
  29. reaf-1.0.0/src/reaf/common/partitioner_action_space_adapter.py +145 -0
  30. reaf-1.0.0/src/reaf/common/position_to_velocity_commands_processor.py +210 -0
  31. reaf-1.0.0/src/reaf/common/relative_clip_commands_processor.py +193 -0
  32. reaf-1.0.0/src/reaf/common/rotation_matrix_to_quaternion_feature_producer.py +81 -0
  33. reaf-1.0.0/src/reaf/common/sequential_end_of_episode_handler.py +38 -0
  34. reaf-1.0.0/src/reaf/common/sequential_environment_reset.py +34 -0
  35. reaf-1.0.0/src/reaf/common/stack_features_producer.py +144 -0
  36. reaf-1.0.0/src/reaf/common/time_trigger.py +37 -0
  37. reaf-1.0.0/src/reaf/common/time_trigger_deps/clock.cc +74 -0
  38. reaf-1.0.0/src/reaf/common/time_trigger_deps/clock.h +56 -0
  39. reaf-1.0.0/src/reaf/common/time_trigger_deps/cycle_timer.cc +74 -0
  40. reaf-1.0.0/src/reaf/common/time_trigger_deps/cycle_timer.h +38 -0
  41. reaf-1.0.0/src/reaf/common/time_trigger_deps/python/cycle_timer.cc +45 -0
  42. reaf-1.0.0/src/reaf/common/time_trigger_deps/python/cycle_timer.pyi +3 -0
  43. reaf-1.0.0/src/reaf/common/timestamp_features_producer.py +40 -0
  44. reaf-1.0.0/src/reaf/common/workspace_limits_termination_checker.py +118 -0
  45. reaf-1.0.0/src/reaf/core/action_space_adapter.py +43 -0
  46. reaf-1.0.0/src/reaf/core/commands_processor.py +91 -0
  47. reaf-1.0.0/src/reaf/core/data_acquisition_and_control_layer.py +170 -0
  48. reaf-1.0.0/src/reaf/core/default_discount_provider.py +79 -0
  49. reaf-1.0.0/src/reaf/core/default_observation_space_adapter.py +231 -0
  50. reaf-1.0.0/src/reaf/core/device.py +54 -0
  51. reaf-1.0.0/src/reaf/core/device_coordinator.py +87 -0
  52. reaf-1.0.0/src/reaf/core/discount_provider.py +61 -0
  53. reaf-1.0.0/src/reaf/core/environment.py +467 -0
  54. reaf-1.0.0/src/reaf/core/features_observer.py +34 -0
  55. reaf-1.0.0/src/reaf/core/features_producer.py +56 -0
  56. reaf-1.0.0/src/reaf/core/logger.py +80 -0
  57. reaf-1.0.0/src/reaf/core/numpy_mock_assertions.py +98 -0
  58. reaf-1.0.0/src/reaf/core/observation_space_adapter.py +42 -0
  59. reaf-1.0.0/src/reaf/core/pass_through_action_space_adapter.py +55 -0
  60. reaf-1.0.0/src/reaf/core/reward_provider.py +292 -0
  61. reaf-1.0.0/src/reaf/core/task_logic_layer.py +342 -0
  62. reaf-1.0.0/src/reaf/core/termination_checker.py +94 -0
  63. reaf-1.0.0/src/reaf/core/trigger.py +29 -0
  64. reaf-1.0.0/src/reaf/core/zero_reward_provider.py +48 -0
  65. reaf-1.0.0/src/reaf/testing/device_assertions.py +65 -0
  66. reaf-1.0.0/src/reaf/testing/fakes.py +344 -0
  67. reaf-1.0.0/src/reaf/testing/tree_spec_validation_assertions.py +63 -0
  68. reaf-1.0.0/tests/reaf/common/clip_commands_processor_test.py +183 -0
  69. reaf-1.0.0/tests/reaf/common/concatenate_features_producer_test.py +193 -0
  70. reaf-1.0.0/tests/reaf/common/crop_image_features_producer_test.py +258 -0
  71. reaf-1.0.0/tests/reaf/common/delta_to_absolute_commands_processor_test.py +226 -0
  72. reaf-1.0.0/tests/reaf/common/environment_reset_from_callable_test.py +37 -0
  73. reaf-1.0.0/tests/reaf/common/external_signal_sparse_reward_provider_test.py +63 -0
  74. reaf-1.0.0/tests/reaf/common/external_signal_termination_checker_test.py +79 -0
  75. reaf-1.0.0/tests/reaf/common/flatten_features_producer_test.py +106 -0
  76. reaf-1.0.0/tests/reaf/common/map_utils_test.py +46 -0
  77. reaf-1.0.0/tests/reaf/common/maximum_steps_termination_checker_test.py +119 -0
  78. reaf-1.0.0/tests/reaf/common/maximum_wall_clock_time_termination_checker_test.py +182 -0
  79. reaf-1.0.0/tests/reaf/common/moving_average_filter_commands_processor_test.py +297 -0
  80. reaf-1.0.0/tests/reaf/common/out_of_bounds_termination_checker_test.py +132 -0
  81. reaf-1.0.0/tests/reaf/common/partitioner_action_space_adapter_test.py +148 -0
  82. reaf-1.0.0/tests/reaf/common/position_to_velocity_commands_processor_test.py +476 -0
  83. reaf-1.0.0/tests/reaf/common/relative_clip_commands_processor_test.py +220 -0
  84. reaf-1.0.0/tests/reaf/common/rotation_matrix_to_quaternion_feature_producer_test.py +86 -0
  85. reaf-1.0.0/tests/reaf/common/sequential_end_of_episode_handler_test.py +53 -0
  86. reaf-1.0.0/tests/reaf/common/sequential_environment_reset_test.py +64 -0
  87. reaf-1.0.0/tests/reaf/common/stack_features_producer_test.py +207 -0
  88. reaf-1.0.0/tests/reaf/common/time_trigger_deps/python/cycle_timer_test.py +56 -0
  89. reaf-1.0.0/tests/reaf/common/time_trigger_test.py +43 -0
  90. reaf-1.0.0/tests/reaf/common/timestamp_features_producer_test.py +47 -0
  91. reaf-1.0.0/tests/reaf/common/workspace_limits_termination_checker_test.py +125 -0
  92. reaf-1.0.0/tests/reaf/core/data_acquisition_and_control_layer_test.py +312 -0
  93. reaf-1.0.0/tests/reaf/core/default_discount_provider_test.py +67 -0
  94. reaf-1.0.0/tests/reaf/core/default_observation_space_adapter_test.py +366 -0
  95. reaf-1.0.0/tests/reaf/core/environment_test.py +1739 -0
  96. reaf-1.0.0/tests/reaf/core/pass_through_action_space_adapter_test.py +72 -0
  97. reaf-1.0.0/tests/reaf/core/reward_provider_test.py +208 -0
  98. reaf-1.0.0/tests/reaf/core/task_logic_layer_test.py +1016 -0
  99. reaf-1.0.0/tests/reaf/core/termination_checker_test.py +129 -0
  100. reaf-1.0.0/tests/reaf/core/zero_reward_provider_test.py +52 -0
  101. reaf-1.0.0/tests/reaf/testing/device_assertions_test.py +152 -0
  102. reaf-1.0.0/tests/reaf/testing/tree_spec_validation_assertions_test.py +82 -0
@@ -0,0 +1,76 @@
1
+ # Copyright 2025 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
+ cmake_minimum_required(VERSION 3.15)
16
+ project(reaf LANGUAGES CXX)
17
+
18
+ set(PYBIND11_FINDPYTHON ON)
19
+ set(USE_SYSTEM_PYBIND ON) # Disable fetch pybind11 from pybind11-abseil.
20
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
21
+
22
+ # Explicitly find Python. This is to avoid issues when PyBind tries to find it
23
+ # (incorrectly).
24
+ find_package(Python3 COMPONENTS Interpreter Development)
25
+ find_package(pybind11 CONFIG REQUIRED)
26
+
27
+
28
+ include(FetchContent)
29
+ FetchContent_Declare(
30
+ abseil-cpp
31
+ # Specify the commit you depend on and update it regularly.
32
+ URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20240722.0.tar.gz
33
+ )
34
+ set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
35
+
36
+ # Note: pybind11_abseil will internally try to fetch both abseil-cpp and
37
+ # pybind11.
38
+ # abseil-cpp is not a problem as it is declared above and our declaration, being
39
+ # done first, takes precedence.
40
+ # pybind11 is more of a problem. We will allow pybind11_abseil to fetch it and
41
+ # we will check for its existence just to be on the safe side.
42
+ FetchContent_Declare(
43
+ pybind11_abseil
44
+ GIT_REPOSITORY https://github.com/pybind/pybind11_abseil.git
45
+ GIT_TAG master
46
+ )
47
+ # pybind11_abseil internally forces interprocedural optimization to off. But
48
+ # this is not propagated up to the top level CMakeLists.txt, which means that
49
+ # there will be incompatibility between our targets and the one defined by
50
+ # pybind11_abseil.
51
+ # We force it to on here.
52
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON CACHE BOOL "" FORCE)
53
+ FetchContent_MakeAvailable(abseil-cpp pybind11_abseil)
54
+
55
+ # Cycle timer dependencies
56
+ add_library(reaf_clock)
57
+ target_sources(reaf_clock PRIVATE src/reaf/common/time_trigger_deps/clock.h
58
+ src/reaf/common/time_trigger_deps/clock.cc)
59
+ target_include_directories(reaf_clock PRIVATE src/reaf/common/time_trigger_deps)
60
+ target_link_libraries(reaf_clock PUBLIC absl::time absl::log)
61
+
62
+ add_library(cycle_timer_cc)
63
+ target_sources(cycle_timer_cc PRIVATE src/reaf/common/time_trigger_deps/cycle_timer.h
64
+ src/reaf/common/time_trigger_deps/cycle_timer.cc)
65
+ target_include_directories(cycle_timer_cc PRIVATE src/reaf/common/time_trigger_deps)
66
+ target_link_libraries(cycle_timer_cc PUBLIC reaf_clock absl::time absl::log absl::check absl::str_format)
67
+
68
+ # Cycle timer module.
69
+ pybind11_add_module(cycle_timer src/reaf/common/time_trigger_deps/python/cycle_timer.cc)
70
+ target_include_directories(cycle_timer PRIVATE src/reaf/common/time_trigger_deps)
71
+ target_link_libraries(cycle_timer PUBLIC
72
+ cycle_timer_cc reaf_clock absl::time absl::log absl::check absl::str_format
73
+ absl::memory pybind11_abseil::absl_casters)
74
+
75
+ # Destination is in the target Python path, i.e. without src.
76
+ install(TARGETS cycle_timer DESTINATION reaf/common/time_trigger_deps/python)
@@ -0,0 +1,6 @@
1
+ # How to Contribute
2
+
3
+ We welcome all feedback you can provide in the form of GitHub issues, but this
4
+ library is widely used in our research code, so we are unlikely to be able
5
+ to accept changes without prior discussion. Feel free to contact us by opening
6
+ an issue to discuss the proposal before implementing the change.
reaf-1.0.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
reaf-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: reaf
3
+ Version: 1.0.0
4
+ Summary: Robotics Environment Authoring Framework.
5
+ Keywords: RL,Reinforcement Learning,AI,ML,Environment,Authoring tool
6
+ Author-Email: Google DeepMind <robotics+oss@google.com>
7
+ Maintainer-Email: Antoine Laurens <alaurens@google.com>, Francesco Romano <fraromano@google.com>, Jose Enrique Chen <josechenf@google.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Typing :: Typed
14
+ Project-URL: Repository, https://github.com/google-deepmind/reaf.git
15
+ Project-URL: Issues, https://github.com/google-deepmind/reaf/issues
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: numpy>=2
18
+ Requires-Dist: absl-py
19
+ Requires-Dist: dm-env
20
+ Requires-Dist: gdm_robotics
21
+ Requires-Dist: typing-extensions
22
+ Requires-Dist: immutabledict
23
+ Requires-Dist: pytest
24
+ Requires-Dist: StrEnum
25
+ Requires-Dist: scipy
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Robotics Environment Authoring Framework (REAF)
29
+
30
+ The Robotics Environment Authoring Framework (REAF) simplifies creating
31
+ environments that adhere to the
32
+ [GDM Robotics Environment interface](https://github.com/google-deepmind/gdm_robotics/interfaces/environment.py).
33
+
34
+ ## How to install
35
+
36
+ `reaf` can be installed from PyPI using `pip`:
37
+
38
+ ```bash
39
+ pip install reaf
40
+ ```
41
+
42
+ ## Directory Structure
43
+
44
+ Currently, the directory structure is designed as standalone subdirectories with
45
+ a well-defined dependency graph.
46
+
47
+ ```
48
+ reaf
49
+ ├── core: Core libraries and interfaces for REAF.
50
+ ├── testing: General tooling for testing REAF interfaces and environments.
51
+ ├── common: Libraries with shared functionality across setups and platforms.
52
+ ```
53
+
54
+ ## Design
55
+
56
+ REAF is a framework designed to simplify the creation of robotics environments.
57
+ It adopts a layered architecture to promote modularity and reusability. The core
58
+ components of a REAF environment are:
59
+
60
+ 1. **Environment:** The top-level interface for interacting with the
61
+ environment, conforming to the
62
+ [GDM Robotics Environment interface](https://github.com/google-deepmind/gdm_robotics/interfaces/environment.py).
63
+ It handles stepping, resetting, and action/observation specs.
64
+ 2. **Task Logic Layer (TLL):** Responsible for defining the task itself,
65
+ including reward calculation, termination conditions, features generation,
66
+ and commands processing.
67
+ 3. **Data Acquisition and Control Layer (DACL):** Interfaces with the physical
68
+ or simulated robotic setup, managing commands to actuators and retrieving
69
+ measurements from sensors.
70
+ 4. **Adapters:** Bridge the gap between the abstract GDMR interfaces and the
71
+ specific requirements of the TLL. These adapters translate agent actions
72
+ into TLL commands and TLL features into agent observations.
73
+ 5. **Reset and End of Episode Handlers:** Support customized behavior during
74
+ environment resets and episode termination.
75
+
76
+ ### Environment
77
+
78
+ The `Environment` class serves as the primary interface for interacting with the
79
+ robotic environment. It coordinates the interactions between the TLL and DACL,
80
+ manages the environment's state, and handles stepping through the environment.
81
+ Key functionalities include:
82
+
83
+ * **`reset_with_options()`:** Resets the environment to a new initial state
84
+ based on the provided options. This involves resetting the DACL, computing
85
+ initial features and observations.
86
+ * **`step()`:** Advances the environment by one step. This method takes an
87
+ agent action, processes it into commands, steps the DACL, computes features,
88
+ reward, discount, termination conditions, and new observations, and returns
89
+ a `TimeStep` object containing this information.
90
+ * **`action_spec()`:** Returns the specification for valid agent actions. This
91
+ is determined by the `ActionSpaceAdapter`.
92
+ * **`timestep_spec()`:** Returns the specification for the `TimeStep` objects
93
+ returned by `step()` and `reset()`.
94
+ * **Logging:** Facilitates adding and removing loggers to monitor internal
95
+ operations.
96
+
97
+ ### Task Logic Layer (TLL)
98
+
99
+ The TLL defines the logic and rules governing the robotic task. It comprises
100
+ several core components:
101
+
102
+ * **`FeaturesProducer`:** Generates additional features based on existing
103
+ features and measurements from the DACL. Each producer has a
104
+ `produced_features_spec()` defining the features it generates and
105
+ `required_features_keys()` indicating the features it depends on.
106
+ * **`CommandsProcessor`:** Modifies commands before they are sent to the DACL.
107
+ Processors can transform, filter, or augment commands. The
108
+ `consumed_commands_spec()` describes the commands accepted by the processor,
109
+ and `produced_commands_keys()` defines the output commands.
110
+ * **`RewardProvider`:** Calculates the reward signal based on the current
111
+ features. It exposes a `reward_spec()` defining the structure of the reward.
112
+ * **`TerminationChecker`:** Determines whether the episode should terminate
113
+ based on features and returns a `TerminationResult` indicating the type of
114
+ termination.
115
+ * **`DiscountProvider`:** Computes the discount factor based on features and
116
+ the termination state.
117
+ * **`FeaturesObserver`:** Passive components that observe features without
118
+ modifying them. This is useful for logging or analysis.
119
+ * **`Logger`:** Records measurements, features, and commands during
120
+ environment interactions. Methods like `record_measurements()`,
121
+ `record_features()`, and `record_commands_processing()` are called at
122
+ specific points in the environment's lifecycle.
123
+
124
+ The TLL also provides methods to:
125
+
126
+ * **`compute_all_features()`:** Computes all features based on measurements
127
+ from the DACL and the output of `FeaturesProducer`s.
128
+ * **`compute_final_commands()`:** Processes the policy's commands using the
129
+ `CommandsProcessor`s and outputs the DACL command.
130
+ * **`compute_reward()`:** Calculates the reward using the `RewardProvider`.
131
+ * **`check_for_termination()`:** Checks termination conditions using
132
+ `TerminationChecker`s.
133
+ * **`compute_discount()`:** Computes the discount using the
134
+ `DiscountProvider`.
135
+ * **`validate_spec()`:** Verifies the consistency of the specs across the TLL
136
+ and DACL.
137
+
138
+ ### Data Acquisition and Control Layer (DACL)
139
+
140
+ The DACL serves as the bridge between the REAF environment and the robotic
141
+ hardware. It's responsible for sending commands to the robot and receiving
142
+ measurements from sensors. The DACL is built around:
143
+
144
+ * **`Device`:** Represents a single hardware component (e.g., robot arm,
145
+ camera). It provides methods like `set_commands()` and `get_measurements()`
146
+ for interacting with the hardware.
147
+ * **`DeviceCoordinator`:** Manages a collection of `Device` objects,
148
+ coordinating their actions and data exchange. It provides lifecycle
149
+ management through `start()` and `stop()` methods and synchronization points
150
+ through `before_set_commands()` and `before_get_measurements()`.
151
+
152
+ The DACL's key functions are:
153
+
154
+ * **`begin_stepping()`:** Initializes the DACL and returns the initial
155
+ measurements.
156
+ * **`step()`:** Sends commands to the devices, retrieves new measurements, and
157
+ returns them.
158
+ * **`end_stepping()`:** Performs cleanup operations at the end of an episode.
159
+ * **`commands_spec()`:** Returns the specification for valid commands. The
160
+ user is expected to pass the full command dictionary.
161
+ * **`measurements_spec()`:** Returns the specification for the measurements
162
+ returned by `get_measurements()`.
163
+
164
+ ### Adapters
165
+
166
+ REAF utilizes adapters to translate between the generic agent interface and the
167
+ specific format required by the TLL.
168
+
169
+ * **`ActionSpaceAdapter`:** Converts the agent's actions into a commands
170
+ dictionary understood by the TLL.
171
+ * **`ObservationSpaceAdapter`:** Transforms the features generated by the TLL
172
+ into observations suitable for the agent.
173
+
174
+ ### Reset and End of Episode Handler
175
+
176
+ * **`EnvironmentReset`:** Defines the reset behavior of the environment,
177
+ including a `do_reset()` method and a default reset configuration. The reset
178
+ is a complex step and very hard to predict how this will be written. The
179
+ intention is to leave complete control to the user so they can pass whatever
180
+ object is needed to the reset without any restrictions. The user can use
181
+ this to check that everything is working properly, reset the state of any
182
+ features producers, etc...
183
+ * **`EndOfEpisodeHandler`:** Provides a callback function,
184
+ `on_end_of_episode_stepping()`, that is invoked at the end of each episode
185
+ after the last step. This is useful for logging, cleanup, or custom logic
186
+ that needs to be executed when an episode ends.
187
+
188
+ ## Licence and Disclaimer
189
+
190
+ Copyright 2025 Google LLC
191
+
192
+ All software is licensed under the Apache License, Version 2.0 (Apache 2.0); you
193
+ may not use this file except in compliance with the Apache 2.0 license. You may
194
+ obtain a copy of the Apache 2.0 license at: https://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ All other materials are licensed under the Creative Commons Attribution 4.0
197
+ International License (CC-BY). You may obtain a copy of the CC-BY license at:
198
+ https://creativecommons.org/licenses/by/4.0/legalcode
199
+
200
+ Unless required by applicable law or agreed to in writing, all software and
201
+ materials distributed here under the Apache 2.0 or CC-BY licenses are
202
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
203
+ either express or implied. See the licenses for the specific language governing
204
+ permissions and limitations under those licenses.
205
+
206
+ This is not an official Google product.
reaf-1.0.0/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # Robotics Environment Authoring Framework (REAF)
2
+
3
+ The Robotics Environment Authoring Framework (REAF) simplifies creating
4
+ environments that adhere to the
5
+ [GDM Robotics Environment interface](https://github.com/google-deepmind/gdm_robotics/interfaces/environment.py).
6
+
7
+ ## How to install
8
+
9
+ `reaf` can be installed from PyPI using `pip`:
10
+
11
+ ```bash
12
+ pip install reaf
13
+ ```
14
+
15
+ ## Directory Structure
16
+
17
+ Currently, the directory structure is designed as standalone subdirectories with
18
+ a well-defined dependency graph.
19
+
20
+ ```
21
+ reaf
22
+ ├── core: Core libraries and interfaces for REAF.
23
+ ├── testing: General tooling for testing REAF interfaces and environments.
24
+ ├── common: Libraries with shared functionality across setups and platforms.
25
+ ```
26
+
27
+ ## Design
28
+
29
+ REAF is a framework designed to simplify the creation of robotics environments.
30
+ It adopts a layered architecture to promote modularity and reusability. The core
31
+ components of a REAF environment are:
32
+
33
+ 1. **Environment:** The top-level interface for interacting with the
34
+ environment, conforming to the
35
+ [GDM Robotics Environment interface](https://github.com/google-deepmind/gdm_robotics/interfaces/environment.py).
36
+ It handles stepping, resetting, and action/observation specs.
37
+ 2. **Task Logic Layer (TLL):** Responsible for defining the task itself,
38
+ including reward calculation, termination conditions, features generation,
39
+ and commands processing.
40
+ 3. **Data Acquisition and Control Layer (DACL):** Interfaces with the physical
41
+ or simulated robotic setup, managing commands to actuators and retrieving
42
+ measurements from sensors.
43
+ 4. **Adapters:** Bridge the gap between the abstract GDMR interfaces and the
44
+ specific requirements of the TLL. These adapters translate agent actions
45
+ into TLL commands and TLL features into agent observations.
46
+ 5. **Reset and End of Episode Handlers:** Support customized behavior during
47
+ environment resets and episode termination.
48
+
49
+ ### Environment
50
+
51
+ The `Environment` class serves as the primary interface for interacting with the
52
+ robotic environment. It coordinates the interactions between the TLL and DACL,
53
+ manages the environment's state, and handles stepping through the environment.
54
+ Key functionalities include:
55
+
56
+ * **`reset_with_options()`:** Resets the environment to a new initial state
57
+ based on the provided options. This involves resetting the DACL, computing
58
+ initial features and observations.
59
+ * **`step()`:** Advances the environment by one step. This method takes an
60
+ agent action, processes it into commands, steps the DACL, computes features,
61
+ reward, discount, termination conditions, and new observations, and returns
62
+ a `TimeStep` object containing this information.
63
+ * **`action_spec()`:** Returns the specification for valid agent actions. This
64
+ is determined by the `ActionSpaceAdapter`.
65
+ * **`timestep_spec()`:** Returns the specification for the `TimeStep` objects
66
+ returned by `step()` and `reset()`.
67
+ * **Logging:** Facilitates adding and removing loggers to monitor internal
68
+ operations.
69
+
70
+ ### Task Logic Layer (TLL)
71
+
72
+ The TLL defines the logic and rules governing the robotic task. It comprises
73
+ several core components:
74
+
75
+ * **`FeaturesProducer`:** Generates additional features based on existing
76
+ features and measurements from the DACL. Each producer has a
77
+ `produced_features_spec()` defining the features it generates and
78
+ `required_features_keys()` indicating the features it depends on.
79
+ * **`CommandsProcessor`:** Modifies commands before they are sent to the DACL.
80
+ Processors can transform, filter, or augment commands. The
81
+ `consumed_commands_spec()` describes the commands accepted by the processor,
82
+ and `produced_commands_keys()` defines the output commands.
83
+ * **`RewardProvider`:** Calculates the reward signal based on the current
84
+ features. It exposes a `reward_spec()` defining the structure of the reward.
85
+ * **`TerminationChecker`:** Determines whether the episode should terminate
86
+ based on features and returns a `TerminationResult` indicating the type of
87
+ termination.
88
+ * **`DiscountProvider`:** Computes the discount factor based on features and
89
+ the termination state.
90
+ * **`FeaturesObserver`:** Passive components that observe features without
91
+ modifying them. This is useful for logging or analysis.
92
+ * **`Logger`:** Records measurements, features, and commands during
93
+ environment interactions. Methods like `record_measurements()`,
94
+ `record_features()`, and `record_commands_processing()` are called at
95
+ specific points in the environment's lifecycle.
96
+
97
+ The TLL also provides methods to:
98
+
99
+ * **`compute_all_features()`:** Computes all features based on measurements
100
+ from the DACL and the output of `FeaturesProducer`s.
101
+ * **`compute_final_commands()`:** Processes the policy's commands using the
102
+ `CommandsProcessor`s and outputs the DACL command.
103
+ * **`compute_reward()`:** Calculates the reward using the `RewardProvider`.
104
+ * **`check_for_termination()`:** Checks termination conditions using
105
+ `TerminationChecker`s.
106
+ * **`compute_discount()`:** Computes the discount using the
107
+ `DiscountProvider`.
108
+ * **`validate_spec()`:** Verifies the consistency of the specs across the TLL
109
+ and DACL.
110
+
111
+ ### Data Acquisition and Control Layer (DACL)
112
+
113
+ The DACL serves as the bridge between the REAF environment and the robotic
114
+ hardware. It's responsible for sending commands to the robot and receiving
115
+ measurements from sensors. The DACL is built around:
116
+
117
+ * **`Device`:** Represents a single hardware component (e.g., robot arm,
118
+ camera). It provides methods like `set_commands()` and `get_measurements()`
119
+ for interacting with the hardware.
120
+ * **`DeviceCoordinator`:** Manages a collection of `Device` objects,
121
+ coordinating their actions and data exchange. It provides lifecycle
122
+ management through `start()` and `stop()` methods and synchronization points
123
+ through `before_set_commands()` and `before_get_measurements()`.
124
+
125
+ The DACL's key functions are:
126
+
127
+ * **`begin_stepping()`:** Initializes the DACL and returns the initial
128
+ measurements.
129
+ * **`step()`:** Sends commands to the devices, retrieves new measurements, and
130
+ returns them.
131
+ * **`end_stepping()`:** Performs cleanup operations at the end of an episode.
132
+ * **`commands_spec()`:** Returns the specification for valid commands. The
133
+ user is expected to pass the full command dictionary.
134
+ * **`measurements_spec()`:** Returns the specification for the measurements
135
+ returned by `get_measurements()`.
136
+
137
+ ### Adapters
138
+
139
+ REAF utilizes adapters to translate between the generic agent interface and the
140
+ specific format required by the TLL.
141
+
142
+ * **`ActionSpaceAdapter`:** Converts the agent's actions into a commands
143
+ dictionary understood by the TLL.
144
+ * **`ObservationSpaceAdapter`:** Transforms the features generated by the TLL
145
+ into observations suitable for the agent.
146
+
147
+ ### Reset and End of Episode Handler
148
+
149
+ * **`EnvironmentReset`:** Defines the reset behavior of the environment,
150
+ including a `do_reset()` method and a default reset configuration. The reset
151
+ is a complex step and very hard to predict how this will be written. The
152
+ intention is to leave complete control to the user so they can pass whatever
153
+ object is needed to the reset without any restrictions. The user can use
154
+ this to check that everything is working properly, reset the state of any
155
+ features producers, etc...
156
+ * **`EndOfEpisodeHandler`:** Provides a callback function,
157
+ `on_end_of_episode_stepping()`, that is invoked at the end of each episode
158
+ after the last step. This is useful for logging, cleanup, or custom logic
159
+ that needs to be executed when an episode ends.
160
+
161
+ ## Licence and Disclaimer
162
+
163
+ Copyright 2025 Google LLC
164
+
165
+ All software is licensed under the Apache License, Version 2.0 (Apache 2.0); you
166
+ may not use this file except in compliance with the Apache 2.0 license. You may
167
+ obtain a copy of the Apache 2.0 license at: https://www.apache.org/licenses/LICENSE-2.0
168
+
169
+ All other materials are licensed under the Creative Commons Attribution 4.0
170
+ International License (CC-BY). You may obtain a copy of the CC-BY license at:
171
+ https://creativecommons.org/licenses/by/4.0/legalcode
172
+
173
+ Unless required by applicable law or agreed to in writing, all software and
174
+ materials distributed here under the Apache 2.0 or CC-BY licenses are
175
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
176
+ either express or implied. See the licenses for the specific language governing
177
+ permissions and limitations under those licenses.
178
+
179
+ This is not an official Google product.