composabl-cli 0.9.2__cp310-cp310-macosx_10_9_universal2.whl → 0.9.3__cp310-cp310-macosx_10_9_universal2.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.
Potentially problematic release.
This version of composabl-cli might be problematic. Click here for more details.
- composabl_cli/cli/__init__.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_agent.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_benchmark.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_debug.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_historian.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_job.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_main.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_perceptor.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_selector.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_sim.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_skill.cpython-310-darwin.so +0 -0
- composabl_cli/cli/cli_version.cpython-310-darwin.so +0 -0
- composabl_cli/k8s/k8s_train.cpython-310-darwin.so +0 -0
- composabl_cli/k8s/util.cpython-310-darwin.so +0 -0
- composabl_cli/main/perceptor.cpython-310-darwin.so +0 -0
- composabl_cli/main/selector.cpython-310-darwin.so +0 -0
- composabl_cli/main/sim.cpython-310-darwin.so +0 -0
- composabl_cli/main/skill.cpython-310-darwin.so +0 -0
- {composabl_cli-0.9.2.dist-info → composabl_cli-0.9.3.dist-info}/METADATA +4 -4
- composabl_cli-0.9.3.dist-info/RECORD +54 -0
- composabl_cli/main/agent.cpython-310-darwin.so +0 -0
- composabl_cli/template/agent_composabl/agent.py +0 -90
- composabl_cli/template/agent_docker/agent.py +0 -99
- composabl_cli/template/agent_local/agent.py +0 -96
- composabl_cli/template/sim_docker/Dockerfile +0 -45
- composabl_cli/template/sim_docker/README.md +0 -17
- composabl_cli/template/sim_docker/docker/sim-start.sh +0 -14
- composabl_cli/template/sim_docker/main.py +0 -55
- composabl_cli/template/sim_docker/module/README.md +0 -39
- composabl_cli/template/sim_docker/module/pyproject.toml +0 -20
- composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim.py +0 -255
- composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim_impl.py +0 -115
- composabl_cli/template/skill_teacher/{{NAME_MODULE}}/__init__.py +0 -3
- composabl_cli-0.9.2.dist-info/RECORD +0 -67
- /composabl_cli/template/perceptor/{{{NAME_MODULE}} → my_perceptor}/__init__.py +0 -0
- /composabl_cli/template/perceptor/{{{NAME_MODULE}} → my_perceptor}/perceptor.py +0 -0
- /composabl_cli/template/selector_controller/{{{NAME_MODULE}} → my_selector}/__init__.py +0 -0
- /composabl_cli/template/selector_controller/{{{NAME_MODULE}} → my_selector}/controller.py +0 -0
- /composabl_cli/template/selector_teacher/{{{NAME_MODULE}} → my_selector}/__init__.py +0 -0
- /composabl_cli/template/selector_teacher/{{{NAME_MODULE}} → my_selector}/teacher.py +0 -0
- /composabl_cli/template/sim/{{{NAME_MODULE}} → my_sim}/__init__.py +0 -0
- /composabl_cli/template/sim/{{{NAME_MODULE}} → my_sim}/sim.py +0 -0
- /composabl_cli/template/sim/{{{NAME_MODULE}} → my_sim}/sim_impl.py +0 -0
- /composabl_cli/template/{sim_docker/module/{{NAME_MODULE}} → skill_coach/my_skill}/__init__.py +0 -0
- /composabl_cli/template/skill_coach/{{{NAME_MODULE}} → my_skill}/coach.py +0 -0
- /composabl_cli/template/{skill_coach/{{NAME_MODULE}} → skill_controller/my_skill}/__init__.py +0 -0
- /composabl_cli/template/skill_controller/{{{NAME_MODULE}} → my_skill}/controller.py +0 -0
- /composabl_cli/template/{skill_controller/{{NAME_MODULE}} → skill_teacher/my_skill}/__init__.py +0 -0
- /composabl_cli/template/skill_teacher/{{{NAME_MODULE}} → my_skill}/teacher.py +0 -0
- {composabl_cli-0.9.2.dist-info → composabl_cli-0.9.3.dist-info}/WHEEL +0 -0
- {composabl_cli-0.9.2.dist-info → composabl_cli-0.9.3.dist-info}/entry_points.txt +0 -0
- {composabl_cli-0.9.2.dist-info → composabl_cli-0.9.3.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: composabl-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.3
|
|
4
4
|
Summary: the Composabl CLI
|
|
5
5
|
Author-email: Composabl <info@composabl.com>
|
|
6
6
|
Requires-Python: >=3.10, <3.12
|
|
@@ -10,9 +10,9 @@ Requires-Dist: cython
|
|
|
10
10
|
Requires-Dist: docker
|
|
11
11
|
Requires-Dist: kubernetes
|
|
12
12
|
Requires-Dist: jinja2
|
|
13
|
-
Requires-Dist: composabl-core>=0.9.
|
|
14
|
-
Requires-Dist: composabl-train>=0.9.
|
|
15
|
-
Requires-Dist: composabl-api>=0.9.
|
|
13
|
+
Requires-Dist: composabl-core>=0.9.3
|
|
14
|
+
Requires-Dist: composabl-train>=0.9.3
|
|
15
|
+
Requires-Dist: composabl-api>=0.9.3
|
|
16
16
|
Requires-Dist: ruff
|
|
17
17
|
Requires-Dist: simple-term-menu
|
|
18
18
|
Dynamic: description
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
composabl_cli/__init__.py,sha256=S2R_1v6FRZ7Pb0vVWYZXFLcUFuRuHXYd0ZoWxYpquM8,316
|
|
2
|
+
composabl_cli/k8s/k8s_train.cpython-310-darwin.so,sha256=ByseIjEoI9p-FkaKLrfU3A5Q2HxGT9Bv7QkuNbReka8,292816
|
|
3
|
+
composabl_cli/k8s/util.cpython-310-darwin.so,sha256=dQgYrUx-Worp8Aawb9wYnSDJetZLCWYEAxIRFHsS6o4,129504
|
|
4
|
+
composabl_cli/template/skill_teacher/pyproject.toml,sha256=pShZXJHFw5-6cJYzw3jsbu_hbPjPQ_YXaOQhyOYUP84,269
|
|
5
|
+
composabl_cli/template/skill_teacher/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
6
|
+
composabl_cli/template/skill_teacher/my_skill/teacher.py,sha256=2MZKUN7gUkfUb-pQD7hh7BlPGRcy66YRq13eqVQvWNw,2585
|
|
7
|
+
composabl_cli/template/skill_teacher/my_skill/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
8
|
+
composabl_cli/template/selector_controller/pyproject.toml,sha256=WKB_pY17udJqOpYRhFOrQNqJcfHLjrvrVndCcnk9Ndg,281
|
|
9
|
+
composabl_cli/template/selector_controller/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
10
|
+
composabl_cli/template/selector_controller/my_selector/controller.py,sha256=ScK28F5cMb0Ek4ERBUAmrWbcPWDlmpA1zsxNBJgo2Rk,1744
|
|
11
|
+
composabl_cli/template/selector_controller/my_selector/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
12
|
+
composabl_cli/template/selector_teacher/pyproject.toml,sha256=abFMd5916s3nbYsG60IdNAvkjcC0JNbIJxny67HIQvE,272
|
|
13
|
+
composabl_cli/template/selector_teacher/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
14
|
+
composabl_cli/template/selector_teacher/my_selector/teacher.py,sha256=2MZKUN7gUkfUb-pQD7hh7BlPGRcy66YRq13eqVQvWNw,2585
|
|
15
|
+
composabl_cli/template/selector_teacher/my_selector/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
16
|
+
composabl_cli/template/perceptor/pyproject.toml,sha256=5C4jS4v-5Ai6NaSAcSYUwHDfC93fe5a0oGm1mkeTG0I,273
|
|
17
|
+
composabl_cli/template/perceptor/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
18
|
+
composabl_cli/template/perceptor/my_perceptor/perceptor.py,sha256=OADD3zG17GxIGtO_my1yMq3Sw3KcV9ARJcCFXcIvMEc,1165
|
|
19
|
+
composabl_cli/template/perceptor/my_perceptor/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
20
|
+
composabl_cli/template/skill_coach/pyproject.toml,sha256=NJ4XaFkRjzocUwbBjGX6SxkpfPLE9Q-dUEvdPrCp7HY,263
|
|
21
|
+
composabl_cli/template/skill_coach/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
22
|
+
composabl_cli/template/skill_coach/my_skill/coach.py,sha256=xC_4_cFI2uXcl-8mVVaS_ADsWL9M8UI3-bcd_kc1WB4,2603
|
|
23
|
+
composabl_cli/template/skill_coach/my_skill/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
24
|
+
composabl_cli/template/sim/pyproject.toml,sha256=XCnRtO15K0sW5P521lZbjzZ2ScS4cSwnAQuC1-QGITA,490
|
|
25
|
+
composabl_cli/template/sim/README.md,sha256=XjNdgOyS9RPMkgK2pGLVmYGHIuq9zNFv1HTCaqELmyw,1117
|
|
26
|
+
composabl_cli/template/sim/my_sim/sim.py,sha256=mbwpUQCN3kXxTvtZBNP3teMm7b__cKcfkww8j-J514k,7215
|
|
27
|
+
composabl_cli/template/sim/my_sim/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
28
|
+
composabl_cli/template/sim/my_sim/sim_impl.py,sha256=f7DzBBmD9cKmauWskoSmUpnSVHkubmqGtJQ5d-9Kf-M,2926
|
|
29
|
+
composabl_cli/template/skill_controller/pyproject.toml,sha256=cxs9x2geQxCIzWQ6j4J8F8BmE3sMREPfWuWtwSbUGjE,278
|
|
30
|
+
composabl_cli/template/skill_controller/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
31
|
+
composabl_cli/template/skill_controller/my_skill/controller.py,sha256=h-K6MLRwJuMKva5H8pp5ZLJ9WH4Z6_IIsKxnfVacASY,1372
|
|
32
|
+
composabl_cli/template/skill_controller/my_skill/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
33
|
+
composabl_cli/cli/cli.cpython-310-darwin.so,sha256=YQWaEE9PR_Cbj0d9SrsaG9La8QTsW52Tt630sJ6kzyA,163824
|
|
34
|
+
composabl_cli/cli/cli_sim.cpython-310-darwin.so,sha256=uk1aDSmoRurWmJ1Qcf3eymNKRG1E9SuXN_Z4Er_YOV0,624640
|
|
35
|
+
composabl_cli/cli/cli_perceptor.cpython-310-darwin.so,sha256=9MZEQzvcQ7x6Ci268ghNz3T1DnH8lu0R5eA9rtONYQs,295496
|
|
36
|
+
composabl_cli/cli/cli_version.cpython-310-darwin.so,sha256=BWuTtnqfOCaayhwjlkcqXFCEgV82Pnzx4PmF3TbujFE,164232
|
|
37
|
+
composabl_cli/cli/cli_main.cpython-310-darwin.so,sha256=KfxWc14C3fq4jfKqRd_T8tmg621L3DK9as5YgSGOPmU,275504
|
|
38
|
+
composabl_cli/cli/cli_historian.cpython-310-darwin.so,sha256=WpRy9pRZNkjgqGGFbLxKn-j5YC98acT9_1Q2ieRvPSo,217288
|
|
39
|
+
composabl_cli/cli/__init__.cpython-310-darwin.so,sha256=2cnvZX2bZaGy0ahLL29kxBQ5peW87HJdeTAfSXMpv00,88592
|
|
40
|
+
composabl_cli/cli/cli_skill.cpython-310-darwin.so,sha256=nfu7hN_WWIVFGy9fs1LXI0aNeToyrv50MS3DRIdbyu0,329792
|
|
41
|
+
composabl_cli/cli/cli_benchmark.cpython-310-darwin.so,sha256=dlLSZ3vE5WfZSwWStZvwnG1ymh9PqKILqwU7cWx1bIA,183416
|
|
42
|
+
composabl_cli/cli/cli_selector.cpython-310-darwin.so,sha256=4DK4TOIm0fH3f5_-CUeA4TdqOs68atLWsAMmuURybxY,329880
|
|
43
|
+
composabl_cli/cli/cli_debug.cpython-310-darwin.so,sha256=5VMrsqGF-7-xdg5CWiOTeM0lXVYlmb8771kgzOSCRJY,147824
|
|
44
|
+
composabl_cli/cli/cli_agent.cpython-310-darwin.so,sha256=H6eCGtYdJiTXcBa1RtRx5OpLV-xCCZxnZsCQqnzP-hE,186880
|
|
45
|
+
composabl_cli/cli/cli_job.cpython-310-darwin.so,sha256=l39FuYcwFPnxq27urwyr97FZMzIT0n0MV2Og2EF2wkQ,329040
|
|
46
|
+
composabl_cli/main/selector.cpython-310-darwin.so,sha256=G_xmPy-kpOWqXZQaqadLrprM8svAD_kYnfTgy4UnGdU,274272
|
|
47
|
+
composabl_cli/main/perceptor.cpython-310-darwin.so,sha256=KTkj26ksr6XdiA3GhoBZkJrh38D8BoM6gL60LkaCx2c,239920
|
|
48
|
+
composabl_cli/main/sim.cpython-310-darwin.so,sha256=RrzXHvuMolRZFw9WjJjHx2QzygF9rNMEZzjHbkLRy0g,239936
|
|
49
|
+
composabl_cli/main/skill.cpython-310-darwin.so,sha256=VRV22P7fxmERFiBGiOkEvpkQd3FoFXtzgUMEYOivK6U,274608
|
|
50
|
+
composabl_cli-0.9.3.dist-info/RECORD,,
|
|
51
|
+
composabl_cli-0.9.3.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
|
|
52
|
+
composabl_cli-0.9.3.dist-info/entry_points.txt,sha256=WrLVbw0dPbDvkgFcNa275XoyuBvDoP-453FEPMn_cG8,56
|
|
53
|
+
composabl_cli-0.9.3.dist-info/top_level.txt,sha256=EGQnCayGP2E4xx8Z-rUeCIw8n3qRhuqDYQREYU08lwY,14
|
|
54
|
+
composabl_cli-0.9.3.dist-info/METADATA,sha256=QOKkW6gPcB2TjFC-1MXzizfYWzr3Y0WJdcIGQ9e6ZwA,1953
|
|
Binary file
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
from typing import Dict
|
|
7
|
-
|
|
8
|
-
from composabl import Agent, MaintainGoal, Sensor, Skill, Trainer
|
|
9
|
-
|
|
10
|
-
# Accept the EULA
|
|
11
|
-
os.environ["COMPOSABL_EULA_AGREED"] = "1"
|
|
12
|
-
|
|
13
|
-
# Set the license
|
|
14
|
-
# os.environ["COMPOSABL_LICENSE"] = "YOUR_LICENSE_KEY"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class BalanceTeacher(MaintainGoal):
|
|
18
|
-
def __init__(self, *args, **kwargs):
|
|
19
|
-
super().__init__(
|
|
20
|
-
"pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
# defaults the BL and BR
|
|
24
|
-
|
|
25
|
-
async def compute_action_mask(self, transformed_sensors: Dict, action):
|
|
26
|
-
# Cartpole might not use an action mask, so this can return None
|
|
27
|
-
return None
|
|
28
|
-
|
|
29
|
-
async def transform_sensors(self, sensors, action):
|
|
30
|
-
# For Cartpole, might just return sensors directly
|
|
31
|
-
return sensors
|
|
32
|
-
|
|
33
|
-
async def transform_action(self, transformed_sensors: Dict, action):
|
|
34
|
-
# No transformation needed for discrete action space
|
|
35
|
-
return action
|
|
36
|
-
|
|
37
|
-
async def filtered_sensor_space(self):
|
|
38
|
-
# Return relevant sensors
|
|
39
|
-
return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def main():
|
|
43
|
-
# Create the agent
|
|
44
|
-
a = Agent()
|
|
45
|
-
|
|
46
|
-
# https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
|
|
47
|
-
a.add_sensors(
|
|
48
|
-
[
|
|
49
|
-
Sensor(
|
|
50
|
-
"cart_pos",
|
|
51
|
-
"The Cart Position between [-4.8, 4.8]",
|
|
52
|
-
lambda sensors: sensors[0],
|
|
53
|
-
),
|
|
54
|
-
Sensor(
|
|
55
|
-
"cart_vel",
|
|
56
|
-
"The Cart Position between [-inf, inf]",
|
|
57
|
-
lambda sensors: sensors[1],
|
|
58
|
-
),
|
|
59
|
-
Sensor(
|
|
60
|
-
"pole_theta",
|
|
61
|
-
"The Pole Angle [-0.418 rad, 0.418 rad]",
|
|
62
|
-
lambda sensors: sensors[2],
|
|
63
|
-
),
|
|
64
|
-
Sensor(
|
|
65
|
-
"pole_alpha",
|
|
66
|
-
"The Pole Angular Velocity [-inf, inf]",
|
|
67
|
-
lambda sensors: sensors[3],
|
|
68
|
-
),
|
|
69
|
-
]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
skill = Skill("pole-balance", BalanceTeacher)
|
|
73
|
-
a.add_skill(skill)
|
|
74
|
-
|
|
75
|
-
# Create trainer and train the agent
|
|
76
|
-
r = Trainer(
|
|
77
|
-
{
|
|
78
|
-
"target": {"composabl"},
|
|
79
|
-
"resources": {
|
|
80
|
-
"sim_count": 2,
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
r.train(a, train_cycles=5)
|
|
86
|
-
r.close()
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if __name__ == "__main__":
|
|
90
|
-
main()
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
from typing import Dict
|
|
7
|
-
|
|
8
|
-
from composabl import Agent, MaintainGoal, Sensor, Skill, Trainer
|
|
9
|
-
|
|
10
|
-
# Accept the EULA
|
|
11
|
-
os.environ["COMPOSABL_EULA_AGREED"] = "1"
|
|
12
|
-
|
|
13
|
-
# Set the license
|
|
14
|
-
# os.environ["COMPOSABL_LICENSE"] = "YOUR_LICENSE_KEY"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class BalanceTeacher(MaintainGoal):
|
|
18
|
-
def __init__(self, *args, **kwargs):
|
|
19
|
-
super().__init__(
|
|
20
|
-
"pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
# defaults the BL and BR
|
|
24
|
-
|
|
25
|
-
async def compute_action_mask(self, transformed_sensors: Dict, action):
|
|
26
|
-
# Cartpole might not use an action mask, so this can return None
|
|
27
|
-
return None
|
|
28
|
-
|
|
29
|
-
async def transform_sensors(self, sensors, action):
|
|
30
|
-
# For Cartpole, might just return sensors directly
|
|
31
|
-
return sensors
|
|
32
|
-
|
|
33
|
-
async def transform_action(self, transformed_sensors: Dict, action):
|
|
34
|
-
# No transformation needed for discrete action space
|
|
35
|
-
return action
|
|
36
|
-
|
|
37
|
-
async def filtered_sensor_space(self):
|
|
38
|
-
# Return relevant sensors
|
|
39
|
-
return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def main():
|
|
43
|
-
# Create the agent
|
|
44
|
-
a = Agent()
|
|
45
|
-
|
|
46
|
-
# https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
|
|
47
|
-
a.add_sensors(
|
|
48
|
-
[
|
|
49
|
-
Sensor(
|
|
50
|
-
"cart_pos",
|
|
51
|
-
"The Cart Position between [-4.8, 4.8]",
|
|
52
|
-
lambda sensors: sensors[0],
|
|
53
|
-
),
|
|
54
|
-
Sensor(
|
|
55
|
-
"cart_vel",
|
|
56
|
-
"The Cart Position between [-inf, inf]",
|
|
57
|
-
lambda sensors: sensors[1],
|
|
58
|
-
),
|
|
59
|
-
Sensor(
|
|
60
|
-
"pole_theta",
|
|
61
|
-
"The Pole Angle [-0.418 rad, 0.418 rad]",
|
|
62
|
-
lambda sensors: sensors[2],
|
|
63
|
-
),
|
|
64
|
-
Sensor(
|
|
65
|
-
"pole_alpha",
|
|
66
|
-
"The Pole Angular Velocity [-inf, inf]",
|
|
67
|
-
lambda sensors: sensors[3],
|
|
68
|
-
),
|
|
69
|
-
]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
skill = Skill("pole-balance", BalanceTeacher)
|
|
73
|
-
a.add_skill(skill)
|
|
74
|
-
|
|
75
|
-
# Create trainer and train the agent
|
|
76
|
-
r = Trainer(
|
|
77
|
-
{
|
|
78
|
-
"target": {"docker": {"image": "composabl/sim-cartpole-dev:latest"}},
|
|
79
|
-
"resources": {
|
|
80
|
-
"sim_count": 2,
|
|
81
|
-
},
|
|
82
|
-
"post_processing": {
|
|
83
|
-
"record": {
|
|
84
|
-
"is_enabled": True,
|
|
85
|
-
"file_path": "/tmp/composabl/recordings",
|
|
86
|
-
"avi_file_name": "output.avi",
|
|
87
|
-
"gif_file_name": "output.gif",
|
|
88
|
-
"gif_max_frames": 24 * 5,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
r.train(a, train_cycles=5)
|
|
95
|
-
r.close()
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if __name__ == "__main__":
|
|
99
|
-
main()
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
from typing import Dict
|
|
7
|
-
|
|
8
|
-
from composabl import Agent, MaintainGoal, Sensor, Skill, Trainer
|
|
9
|
-
|
|
10
|
-
# Accept the EULA
|
|
11
|
-
os.environ["COMPOSABL_EULA_AGREED"] = "1"
|
|
12
|
-
|
|
13
|
-
# Set the license
|
|
14
|
-
# os.environ["COMPOSABL_LICENSE"] = "YOUR_LICENSE_KEY"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class BalanceTeacher(MaintainGoal):
|
|
18
|
-
def __init__(self, *args, **kwargs):
|
|
19
|
-
super().__init__(
|
|
20
|
-
"pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
# defaults the BL and BR
|
|
24
|
-
|
|
25
|
-
async def compute_action_mask(self, transformed_sensors: Dict, action):
|
|
26
|
-
# Cartpole might not use an action mask, so this can return None
|
|
27
|
-
return None
|
|
28
|
-
|
|
29
|
-
async def transform_sensors(self, sensors, action):
|
|
30
|
-
# For Cartpole, might just return sensors directly
|
|
31
|
-
return sensors
|
|
32
|
-
|
|
33
|
-
async def transform_action(self, transformed_sensors: Dict, action):
|
|
34
|
-
# No transformation needed for discrete action space
|
|
35
|
-
return action
|
|
36
|
-
|
|
37
|
-
async def filtered_sensor_space(self):
|
|
38
|
-
# Return relevant sensors
|
|
39
|
-
return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def main():
|
|
43
|
-
# Create the agent
|
|
44
|
-
a = Agent()
|
|
45
|
-
|
|
46
|
-
# https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
|
|
47
|
-
a.add_sensors(
|
|
48
|
-
[
|
|
49
|
-
Sensor(
|
|
50
|
-
"cart_pos",
|
|
51
|
-
"The Cart Position between [-4.8, 4.8]",
|
|
52
|
-
lambda sensors: sensors[0],
|
|
53
|
-
),
|
|
54
|
-
Sensor(
|
|
55
|
-
"cart_vel",
|
|
56
|
-
"The Cart Position between [-inf, inf]",
|
|
57
|
-
lambda sensors: sensors[1],
|
|
58
|
-
),
|
|
59
|
-
Sensor(
|
|
60
|
-
"pole_theta",
|
|
61
|
-
"The Pole Angle [-0.418 rad, 0.418 rad]",
|
|
62
|
-
lambda sensors: sensors[2],
|
|
63
|
-
),
|
|
64
|
-
Sensor(
|
|
65
|
-
"pole_alpha",
|
|
66
|
-
"The Pole Angular Velocity [-inf, inf]",
|
|
67
|
-
lambda sensors: sensors[3],
|
|
68
|
-
),
|
|
69
|
-
]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
skill = Skill("pole-balance", BalanceTeacher)
|
|
73
|
-
a.add_skill(skill)
|
|
74
|
-
|
|
75
|
-
# Create trainer and train the agent
|
|
76
|
-
r = Trainer(
|
|
77
|
-
{
|
|
78
|
-
"target": {"local": {"address": "localhost:1337"}},
|
|
79
|
-
"post_processing": {
|
|
80
|
-
"record": {
|
|
81
|
-
"is_enabled": True,
|
|
82
|
-
"file_path": "/tmp/composabl/recordings",
|
|
83
|
-
"avi_file_name": "output.avi",
|
|
84
|
-
"gif_file_name": "output.gif",
|
|
85
|
-
"gif_max_frames": 24 * 5,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
r.train(a, train_cycles=5)
|
|
92
|
-
r.close()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if __name__ == "__main__":
|
|
96
|
-
main()
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
######################################################
|
|
2
|
-
# Composabl Image
|
|
3
|
-
######################################################
|
|
4
|
-
FROM python:3.11-slim
|
|
5
|
-
|
|
6
|
-
# Set working directory
|
|
7
|
-
WORKDIR /opt/composabl
|
|
8
|
-
|
|
9
|
-
# ######################################################
|
|
10
|
-
# Install Dependencies
|
|
11
|
-
# ######################################################
|
|
12
|
-
RUN apt update; apt install -y unzip tree
|
|
13
|
-
|
|
14
|
-
# ######################################################
|
|
15
|
-
# Make `python3` available as `python`
|
|
16
|
-
# ######################################################
|
|
17
|
-
RUN ln -s /usr/bin/python3 /usr/bin/python
|
|
18
|
-
|
|
19
|
-
# ######################################################
|
|
20
|
-
# Install Composabl
|
|
21
|
-
# ######################################################
|
|
22
|
-
RUN pip install composabl-core
|
|
23
|
-
|
|
24
|
-
# ######################################################
|
|
25
|
-
# Install Python Module
|
|
26
|
-
# ######################################################
|
|
27
|
-
COPY module/ /opt/composabl/sim/
|
|
28
|
-
RUN pip install /opt/composabl/sim/
|
|
29
|
-
|
|
30
|
-
# ######################################################
|
|
31
|
-
# Install Composabl Code and Docker scripts
|
|
32
|
-
# ######################################################
|
|
33
|
-
# Copy over the scripts
|
|
34
|
-
COPY docker /docker
|
|
35
|
-
RUN chmod +x /docker/*.sh
|
|
36
|
-
|
|
37
|
-
# Copy over the main startup file
|
|
38
|
-
# this file takes care of starting the Composabl server
|
|
39
|
-
COPY *.py /opt/composabl/
|
|
40
|
-
|
|
41
|
-
# ######################################################
|
|
42
|
-
# Define run
|
|
43
|
-
# ######################################################
|
|
44
|
-
EXPOSE 1337
|
|
45
|
-
CMD ["/docker/sim-start.sh", "/opt/composabl/sim"]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# README
|
|
2
|
-
|
|
3
|
-
This is an example of how to build a composabl suitable container yourself for full control.
|
|
4
|
-
|
|
5
|
-
### Build the Sim
|
|
6
|
-
|
|
7
|
-
To build the sim wrapper, run the following command:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
docker build -t composabl/sim-demo .
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Run the Sim
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
docker run --rm -it -p 1337:1337 composabl/sim-demo
|
|
17
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/bin/bash -e
|
|
2
|
-
################################################################################
|
|
3
|
-
## File: sim-start.sh
|
|
4
|
-
## Desc: Start the Composabl Sim Wrapper
|
|
5
|
-
################################################################################
|
|
6
|
-
PATH_SIM=${1:-/composabl/sim}
|
|
7
|
-
SIM_CONFIG_JSON=${2:-"{}"}
|
|
8
|
-
|
|
9
|
-
HOST=${HOST:-"0.0.0.0"}
|
|
10
|
-
PORT=${PORT:-"1337"}
|
|
11
|
-
|
|
12
|
-
# Start the Sim Client Wrapper
|
|
13
|
-
echo "$0: Starting the Sim Wrapper"
|
|
14
|
-
python3 /opt/composabl/main.py --path $PATH_SIM --config $SIM_CONFIG_JSON --port $PORT --host $HOST
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
import argparse
|
|
6
|
-
import os
|
|
7
|
-
from typing import Optional
|
|
8
|
-
|
|
9
|
-
from composabl_core.networking.server import make_from_sim_path
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
async def _run(
|
|
13
|
-
path: Optional[str] = "./",
|
|
14
|
-
host: Optional[str] = "0.0.0.0",
|
|
15
|
-
port: Optional[int] = 1337,
|
|
16
|
-
protocol: Optional[str] = "grpc",
|
|
17
|
-
config: Optional[dict] = {},
|
|
18
|
-
):
|
|
19
|
-
"""
|
|
20
|
-
Try to run the sim situated in the given location
|
|
21
|
-
"""
|
|
22
|
-
path_abs = os.path.abspath(path)
|
|
23
|
-
|
|
24
|
-
print(f"Running sim from path: {path_abs}")
|
|
25
|
-
print(f"Params: {path}, {host}, {port}, {protocol}, {config}")
|
|
26
|
-
|
|
27
|
-
server = make_from_sim_path(path, host, port, config=config, protocol=protocol)
|
|
28
|
-
print(f"Running on {host}:{port}")
|
|
29
|
-
|
|
30
|
-
try:
|
|
31
|
-
await server.start()
|
|
32
|
-
except KeyboardInterrupt:
|
|
33
|
-
print("KeyboardInterrupt, Gracefully stopping the server")
|
|
34
|
-
except Exception as e:
|
|
35
|
-
print(f"Unknown error: {e}, Gracefully stopping the server")
|
|
36
|
-
finally:
|
|
37
|
-
print("Stopping the server")
|
|
38
|
-
if server is not None:
|
|
39
|
-
await server.stop()
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if __name__ == "__main__":
|
|
43
|
-
parser = argparse.ArgumentParser()
|
|
44
|
-
parser.add_argument("--path", type=str, default="./")
|
|
45
|
-
parser.add_argument("--host", type=str, default="0.0.0.0")
|
|
46
|
-
parser.add_argument("--port", type=int, default=1337)
|
|
47
|
-
parser.add_argument("--protocol", type=str, default="grpc")
|
|
48
|
-
parser.add_argument("--config", type=str, default="{}")
|
|
49
|
-
args = parser.parse_args()
|
|
50
|
-
|
|
51
|
-
config_parsed = eval(args.config)
|
|
52
|
-
|
|
53
|
-
import asyncio
|
|
54
|
-
|
|
55
|
-
asyncio.run(_run(args.path, args.host, args.port, args.protocol, config_parsed))
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# README
|
|
2
|
-
|
|
3
|
-
## Tree Structure
|
|
4
|
-
|
|
5
|
-
The template is structured as follows:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
my-sim/ # Root folder
|
|
9
|
-
├── my_sim/ # Main package folder
|
|
10
|
-
│ ├── __init__.py # Package init file
|
|
11
|
-
│ ├── sim_impl.py # Sim Implementation
|
|
12
|
-
│ └── sim.py # Sim Itself
|
|
13
|
-
├── pyproject.toml # Project configuration, containing [composabl]
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## PyProject [composabl] Section
|
|
17
|
-
|
|
18
|
-
We add the `[composabl]` section to the `pyproject.toml` file to specify the sim we are creating as well as its entrypoint. This is used by the Composabl Sim Container to determine how to start the sim.
|
|
19
|
-
|
|
20
|
-
Example:
|
|
21
|
-
|
|
22
|
-
```toml
|
|
23
|
-
[composabl]
|
|
24
|
-
type = "sim"
|
|
25
|
-
entrypoint = "my_sim.sim_impl:MySimImpl"
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Development
|
|
29
|
-
|
|
30
|
-
To work on the Sim, you can simply run `composabl sim run <folder>`. This will do the same but locally.
|
|
31
|
-
|
|
32
|
-
## Preparing for Upload
|
|
33
|
-
|
|
34
|
-
Once we are ready for uploading, we can create a `.zip` file that contains the version and is prefixed with `composabl-sim-`. This can be done with the following command:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Zip the Sim
|
|
38
|
-
zip -r composabl-sim-demo-0.0.1.zip sim-demo/
|
|
39
|
-
```
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "{{NAME}}"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
description = "{{DESCRIPTION}}"
|
|
5
|
-
authors = [{ name = "John Doe", email = "john.doe@composabl.com" }]
|
|
6
|
-
dependencies = [
|
|
7
|
-
"composabl-core"
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
[composabl]
|
|
11
|
-
type = "sim"
|
|
12
|
-
entrypoint = "{{NAME_MODULE}}.sim_impl:SimImpl"
|
|
13
|
-
dependencies_system = [] # include additional apt-get packages to be installed
|
|
14
|
-
|
|
15
|
-
# Include additional data files
|
|
16
|
-
[tool.setuptools.packages.find]
|
|
17
|
-
where = ["{{NAME_MODULE}}"]
|
|
18
|
-
|
|
19
|
-
[tool.setuptools.package-data]
|
|
20
|
-
"*" = ["*.json", "*.pkl"]
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
import math
|
|
6
|
-
import random
|
|
7
|
-
from typing import Optional
|
|
8
|
-
|
|
9
|
-
import gymnasium as gym
|
|
10
|
-
import numpy as np
|
|
11
|
-
from composabl_core.agent.scenario import Scenario
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Env(gym.Env):
|
|
15
|
-
def __init__(self):
|
|
16
|
-
self.obs_space_constraints = {
|
|
17
|
-
"x": {"low": -400, "high": 400},
|
|
18
|
-
"x_speed": {"low": -100, "high": 100},
|
|
19
|
-
"y": {"low": 0, "high": 1000},
|
|
20
|
-
"y_speed": {"low": -1000, "high": 1000},
|
|
21
|
-
"angle": {"low": -3.15 * 2, "high": 3.15 * 2},
|
|
22
|
-
"angle_speed": {"low": -3, "high": 3},
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
deg_to_rad = 0.01745329
|
|
26
|
-
self.max_gimble = 20 * deg_to_rad
|
|
27
|
-
self.min_gimble = -self.max_gimble
|
|
28
|
-
|
|
29
|
-
self.action_constraints = {
|
|
30
|
-
"angle": {"low": self.min_gimble, "high": self.max_gimble},
|
|
31
|
-
"thrust": {"low": 0.4, "high": 1},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
low_list = [x["low"] for x in self.obs_space_constraints.values()]
|
|
35
|
-
high_list = [x["high"] for x in self.obs_space_constraints.values()]
|
|
36
|
-
|
|
37
|
-
self.sensor_space = gym.spaces.Box(
|
|
38
|
-
low=np.array(low_list), high=np.array(high_list)
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
low_act_list = [x["low"] for x in self.action_constraints.values()]
|
|
42
|
-
high_act_list = [x["high"] for x in self.action_constraints.values()]
|
|
43
|
-
|
|
44
|
-
self.action_space = gym.spaces.Box(
|
|
45
|
-
low=np.array(low_act_list), high=np.array(high_act_list)
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
self.state_models = {}
|
|
49
|
-
self.reward_models = {}
|
|
50
|
-
self.scenario: Scenario = None
|
|
51
|
-
|
|
52
|
-
self.x_obs0 = 0
|
|
53
|
-
self.x_speed0 = 0
|
|
54
|
-
self.y_obs0 = 1000
|
|
55
|
-
self.y_speed0 = -80
|
|
56
|
-
self.angle0 = -np.pi / 2
|
|
57
|
-
self.ang_speed0 = 0
|
|
58
|
-
|
|
59
|
-
def starship_simulation(self, x, u):
|
|
60
|
-
g = 9.8
|
|
61
|
-
m = 100000 # kg
|
|
62
|
-
min_thrust = 880 * 1000 # N
|
|
63
|
-
max_thrust = 1 * 2210 * 1000 # kN
|
|
64
|
-
|
|
65
|
-
length = 50 # m
|
|
66
|
-
width = 10
|
|
67
|
-
|
|
68
|
-
# Inertia for a uniform density rod
|
|
69
|
-
I = (1 / 12) * m * length**2
|
|
70
|
-
|
|
71
|
-
deg_to_rad = 0.01745329
|
|
72
|
-
|
|
73
|
-
max_gimble = 20 * deg_to_rad
|
|
74
|
-
min_gimble = -max_gimble
|
|
75
|
-
|
|
76
|
-
theta = x[4]
|
|
77
|
-
|
|
78
|
-
thrust = u[0]
|
|
79
|
-
thrust_angle = u[1]
|
|
80
|
-
|
|
81
|
-
# Horizontal force
|
|
82
|
-
F_x = max_thrust * thrust * math.sin(thrust_angle + theta)
|
|
83
|
-
x_dot = x[1]
|
|
84
|
-
x_dotdot = (F_x) / m
|
|
85
|
-
|
|
86
|
-
# Vertical force
|
|
87
|
-
F_y = max_thrust * thrust * math.cos(thrust_angle + theta)
|
|
88
|
-
y_dot = x[3]
|
|
89
|
-
y_dotdot = (F_y) / m - g
|
|
90
|
-
|
|
91
|
-
# Torque
|
|
92
|
-
T = -length / 2 * max_thrust * thrust * math.sin(thrust_angle)
|
|
93
|
-
theta_dot = x[5]
|
|
94
|
-
theta_dotdot = T / I
|
|
95
|
-
|
|
96
|
-
return [x_dot, x_dotdot, y_dot, y_dotdot, theta_dot, theta_dotdot]
|
|
97
|
-
|
|
98
|
-
def reset(
|
|
99
|
-
self,
|
|
100
|
-
*,
|
|
101
|
-
seed: Optional[int] = None,
|
|
102
|
-
options: Optional[dict] = None,
|
|
103
|
-
x_obs0: float = 0,
|
|
104
|
-
x_speed0: float = 0,
|
|
105
|
-
y_obs0: float = 1000,
|
|
106
|
-
y_speed0: float = -80,
|
|
107
|
-
angle0: float = -np.pi / 2,
|
|
108
|
-
ang_speed0: float = 0
|
|
109
|
-
):
|
|
110
|
-
"""
|
|
111
|
-
# x[0] = x position (m)
|
|
112
|
-
# x[1] = x velocity (m/)
|
|
113
|
-
# x[2] = y position (m)
|
|
114
|
-
# x[3] = y velocity (m/s)
|
|
115
|
-
# x[4] = angle (rad)
|
|
116
|
-
# x[5] = angular velocity (rad/s)
|
|
117
|
-
|
|
118
|
-
# u[0] = thrust (percent)
|
|
119
|
-
# u[1] = thrust angle (rad)
|
|
120
|
-
|
|
121
|
-
"""
|
|
122
|
-
super().reset(seed=seed)
|
|
123
|
-
self.cnt = 0
|
|
124
|
-
self.min_thrust = 880 * 1000 # N
|
|
125
|
-
self.max_thrust = 1 * 2210 * 1000 # kN
|
|
126
|
-
|
|
127
|
-
# Define scenario in the simulation ******
|
|
128
|
-
if isinstance(self.scenario, Scenario):
|
|
129
|
-
sample = self.scenario.sample()
|
|
130
|
-
|
|
131
|
-
for key in list(sample.keys()):
|
|
132
|
-
setattr(self, key, sample[key])
|
|
133
|
-
|
|
134
|
-
# Set the number of steps and the timestep (dt)
|
|
135
|
-
steps = 400
|
|
136
|
-
self.t_step = 0.04
|
|
137
|
-
self.cnt = 0
|
|
138
|
-
|
|
139
|
-
self.x = np.zeros((steps + 1, 6))
|
|
140
|
-
self.u = np.zeros((steps + 1, 2))
|
|
141
|
-
|
|
142
|
-
self.x[0, :] = [
|
|
143
|
-
self.x_obs0,
|
|
144
|
-
self.x_speed0,
|
|
145
|
-
self.y_obs0,
|
|
146
|
-
self.y_speed0,
|
|
147
|
-
self.angle0,
|
|
148
|
-
self.ang_speed0,
|
|
149
|
-
]
|
|
150
|
-
self.x[steps - 1, :] = [0, 0, 0, 0, 0, 0]
|
|
151
|
-
|
|
152
|
-
self.x_obs = self.x[self.cnt, 0]
|
|
153
|
-
self.x_speed = self.x[self.cnt, 1]
|
|
154
|
-
self.y_obs = self.x[self.cnt, 2]
|
|
155
|
-
self.y_speed = self.x[self.cnt, 3]
|
|
156
|
-
self.angle = self.x[self.cnt, 4]
|
|
157
|
-
self.ang_speed = self.x[self.cnt, 5]
|
|
158
|
-
|
|
159
|
-
self.t = 0.4
|
|
160
|
-
self.a = 0
|
|
161
|
-
self.reward_value = 0
|
|
162
|
-
|
|
163
|
-
self.obs = {
|
|
164
|
-
"x": self.x_obs,
|
|
165
|
-
"x_speed": self.x_speed,
|
|
166
|
-
"y": self.y_obs,
|
|
167
|
-
"y_speed": self.y_speed,
|
|
168
|
-
"angle": self.angle,
|
|
169
|
-
"angle_speed": self.ang_speed,
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
self.obs = np.array(list(self.obs.values()))
|
|
173
|
-
info = {}
|
|
174
|
-
return self.obs, info
|
|
175
|
-
|
|
176
|
-
def set_scenario(self, scenario):
|
|
177
|
-
self.scenario = scenario
|
|
178
|
-
|
|
179
|
-
def step(self, action):
|
|
180
|
-
terminated = False
|
|
181
|
-
discount = 0
|
|
182
|
-
reward = 0
|
|
183
|
-
|
|
184
|
-
def sumsqr(lt):
|
|
185
|
-
v = sum([x**2 for x in lt])
|
|
186
|
-
return v
|
|
187
|
-
|
|
188
|
-
angle = action[0]
|
|
189
|
-
thrust = action[1]
|
|
190
|
-
|
|
191
|
-
actuator_noise = 0
|
|
192
|
-
self.t = thrust + random.uniform(
|
|
193
|
-
-actuator_noise * thrust, actuator_noise * thrust
|
|
194
|
-
)
|
|
195
|
-
self.a = angle + random.uniform(
|
|
196
|
-
-actuator_noise * angle, actuator_noise * angle
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
self.t = np.clip(self.t, 0.4, 1)
|
|
200
|
-
self.a = np.clip(self.a, self.min_gimble, self.max_gimble)
|
|
201
|
-
|
|
202
|
-
# update u
|
|
203
|
-
self.u[self.cnt, 0] = self.t
|
|
204
|
-
self.u[self.cnt, 1] = self.a
|
|
205
|
-
|
|
206
|
-
res = self.starship_simulation(self.x[self.cnt, :], self.u[self.cnt, :])
|
|
207
|
-
res = [v * self.t_step for v in res]
|
|
208
|
-
|
|
209
|
-
self.x[self.cnt + 1, :] = [
|
|
210
|
-
sum(value) for value in zip(self.x[self.cnt, :], res)
|
|
211
|
-
]
|
|
212
|
-
|
|
213
|
-
# Increase time
|
|
214
|
-
self.cnt += 1
|
|
215
|
-
# update values
|
|
216
|
-
self.x_obs = self.x[self.cnt, 0]
|
|
217
|
-
self.x_speed = self.x[self.cnt, 1]
|
|
218
|
-
self.y_obs = self.x[self.cnt, 2]
|
|
219
|
-
self.y_speed = self.x[self.cnt, 3]
|
|
220
|
-
self.angle = self.x[self.cnt, 4]
|
|
221
|
-
self.ang_speed = self.x[self.cnt, 5]
|
|
222
|
-
|
|
223
|
-
# update obs with new state values
|
|
224
|
-
self.obs = {
|
|
225
|
-
"x": self.x_obs,
|
|
226
|
-
"x_speed": self.x_speed,
|
|
227
|
-
"y": self.y_obs,
|
|
228
|
-
"y_speed": self.y_speed,
|
|
229
|
-
"angle": self.angle,
|
|
230
|
-
"angle_speed": self.ang_speed,
|
|
231
|
-
}
|
|
232
|
-
# add noise
|
|
233
|
-
for key in list(self.obs.keys()):
|
|
234
|
-
val = float(self.obs[key])
|
|
235
|
-
sensor_noise = 0.0
|
|
236
|
-
self.obs[key] = val + random.uniform(
|
|
237
|
-
-val * sensor_noise, val * sensor_noise
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
# end the simulation
|
|
241
|
-
if self.y_obs < 0:
|
|
242
|
-
terminated = True
|
|
243
|
-
elif (
|
|
244
|
-
not self.obs_space_constraints["x"]["low"]
|
|
245
|
-
<= self.x_obs
|
|
246
|
-
<= self.obs_space_constraints["x"]["high"]
|
|
247
|
-
):
|
|
248
|
-
terminated = True
|
|
249
|
-
|
|
250
|
-
self.obs = np.array(list(self.obs.values()))
|
|
251
|
-
info = {}
|
|
252
|
-
return self.obs, reward, terminated, False, info
|
|
253
|
-
|
|
254
|
-
def render(self, mode="auto"):
|
|
255
|
-
pass
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Copyright (C) Composabl, Inc - All Rights Reserved
|
|
2
|
-
# Unauthorized copying of this file, via any medium is strictly prohibited
|
|
3
|
-
# Proprietary and confidential
|
|
4
|
-
|
|
5
|
-
from typing import Any, Dict, SupportsFloat, Tuple
|
|
6
|
-
|
|
7
|
-
import composabl_core.utils.logger as logger_util
|
|
8
|
-
import gymnasium as gym
|
|
9
|
-
from composabl_core.agent.scenario import Scenario
|
|
10
|
-
from composabl_core.networking.server_composabl import ServerComposabl
|
|
11
|
-
from gymnasium.envs.registration import EnvSpec
|
|
12
|
-
|
|
13
|
-
from {{NAME_MODULE}}.sim import Env
|
|
14
|
-
|
|
15
|
-
logger = logger_util.get_logger(__name__)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class SimImpl(ServerComposabl):
|
|
19
|
-
def __init__(self):
|
|
20
|
-
self.env = Env()
|
|
21
|
-
|
|
22
|
-
async def make(self, env_id: str, env_init: dict) -> EnvSpec:
|
|
23
|
-
"""
|
|
24
|
-
Make the environment
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
- env_id (str): Environment ID
|
|
28
|
-
- env_init (dict): Environment Initialization
|
|
29
|
-
|
|
30
|
-
Returns:
|
|
31
|
-
- EnvSpec: Environment Specification
|
|
32
|
-
"""
|
|
33
|
-
spec = {"id": "starship", "max_episode_steps": 400}
|
|
34
|
-
return spec
|
|
35
|
-
|
|
36
|
-
async def sensor_space_info(self) -> gym.Space:
|
|
37
|
-
"""
|
|
38
|
-
Get the sensor space information
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
- Space: Sensor Space in Gymnasium Specification
|
|
42
|
-
"""
|
|
43
|
-
return self.env.sensor_space
|
|
44
|
-
|
|
45
|
-
async def action_space_info(self) -> gym.Space:
|
|
46
|
-
"""
|
|
47
|
-
Get the action space information
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
- Space: Action Space in Gymnasium Specification
|
|
51
|
-
"""
|
|
52
|
-
return self.env.action_space
|
|
53
|
-
|
|
54
|
-
async def action_space_sample(self) -> Any:
|
|
55
|
-
"""
|
|
56
|
-
Get the action space sample
|
|
57
|
-
|
|
58
|
-
Returns:
|
|
59
|
-
- List[Any]: A list of samples
|
|
60
|
-
"""
|
|
61
|
-
return self.env.action_space.sample()
|
|
62
|
-
|
|
63
|
-
async def reset(self) -> Tuple[Any, Dict[str, Any]]:
|
|
64
|
-
"""
|
|
65
|
-
Reset the environment
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
- Tuple[Any, Dict[str, Any]]: The observation and the info
|
|
69
|
-
"""
|
|
70
|
-
sensors, info = self.env.reset()
|
|
71
|
-
return sensors, info
|
|
72
|
-
|
|
73
|
-
async def step(
|
|
74
|
-
self, action
|
|
75
|
-
) -> Tuple[Any, SupportsFloat, bool, bool, Dict[str, Any]]:
|
|
76
|
-
"""
|
|
77
|
-
Step the environment
|
|
78
|
-
|
|
79
|
-
Args:
|
|
80
|
-
- action: The action to take
|
|
81
|
-
|
|
82
|
-
Returns:
|
|
83
|
-
- Tuple[Any, SupportsFloat, bool, bool, Dict[str, Any]]: The observation, reward, is_truncated, is_done, info
|
|
84
|
-
"""
|
|
85
|
-
return self.env.step(action)
|
|
86
|
-
|
|
87
|
-
async def close(self):
|
|
88
|
-
"""
|
|
89
|
-
Close the environment
|
|
90
|
-
"""
|
|
91
|
-
self.env.close()
|
|
92
|
-
|
|
93
|
-
async def set_scenario(self, scenario):
|
|
94
|
-
"""
|
|
95
|
-
Set the scenario
|
|
96
|
-
"""
|
|
97
|
-
self.env.scenario = scenario
|
|
98
|
-
|
|
99
|
-
async def get_scenario(self):
|
|
100
|
-
"""
|
|
101
|
-
Get the scenario
|
|
102
|
-
"""
|
|
103
|
-
if self.env.scenario is None:
|
|
104
|
-
return Scenario({"dummy": 0})
|
|
105
|
-
|
|
106
|
-
return self.env.scenario
|
|
107
|
-
|
|
108
|
-
async def get_render(self):
|
|
109
|
-
"""
|
|
110
|
-
Get the render
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
- render_mode: The render mode
|
|
114
|
-
"""
|
|
115
|
-
return self.env.get_render_frame()
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
composabl_cli/__init__.py,sha256=S2R_1v6FRZ7Pb0vVWYZXFLcUFuRuHXYd0ZoWxYpquM8,316
|
|
2
|
-
composabl_cli/k8s/k8s_train.cpython-310-darwin.so,sha256=XzZOF1WJPYfth0IC12QaqfG-6s4vNE6q5beHEEtr7qI,292592
|
|
3
|
-
composabl_cli/k8s/util.cpython-310-darwin.so,sha256=TPlh1yCqDEHQDDBihuFTwm1zhGFetrw9uZpUM6zKlMM,129504
|
|
4
|
-
composabl_cli/template/agent_composabl/agent.py,sha256=bgLhCZ7hHVen-8WcPgFRTw-HBIQdU2KAUNfXLySmnu4,2451
|
|
5
|
-
composabl_cli/template/agent_docker/agent.py,sha256=8z__Fpola2jmmKR7QeoP-EHW0KzXzHNlyX48Ik714JA,2841
|
|
6
|
-
composabl_cli/template/skill_teacher/pyproject.toml,sha256=pShZXJHFw5-6cJYzw3jsbu_hbPjPQ_YXaOQhyOYUP84,269
|
|
7
|
-
composabl_cli/template/skill_teacher/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
8
|
-
composabl_cli/template/skill_teacher/{{NAME_MODULE}}/teacher.py,sha256=2MZKUN7gUkfUb-pQD7hh7BlPGRcy66YRq13eqVQvWNw,2585
|
|
9
|
-
composabl_cli/template/skill_teacher/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
10
|
-
composabl_cli/template/selector_controller/pyproject.toml,sha256=WKB_pY17udJqOpYRhFOrQNqJcfHLjrvrVndCcnk9Ndg,281
|
|
11
|
-
composabl_cli/template/selector_controller/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
12
|
-
composabl_cli/template/selector_controller/{{NAME_MODULE}}/controller.py,sha256=ScK28F5cMb0Ek4ERBUAmrWbcPWDlmpA1zsxNBJgo2Rk,1744
|
|
13
|
-
composabl_cli/template/selector_controller/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
14
|
-
composabl_cli/template/sim_docker/Dockerfile,sha256=4EDDU8maYY6SzoLGjwfJ9Vzx_KYruMueVQwmbsOsdsM,1486
|
|
15
|
-
composabl_cli/template/sim_docker/README.md,sha256=buW49KLG-j7-A_8qZehEvG3TafeaK5_F92Z5ZfMMgAU,308
|
|
16
|
-
composabl_cli/template/sim_docker/main.py,sha256=Z5PBWiYPeqdpTdAYksVoZCKqA_3GBz8HORzzS0wkFgs,1711
|
|
17
|
-
composabl_cli/template/sim_docker/docker/sim-start.sh,sha256=aGd_9HayqKClNgFr80MAn7JGPiMiZTKJmzUV0PaLiHw,515
|
|
18
|
-
composabl_cli/template/sim_docker/module/pyproject.toml,sha256=XCnRtO15K0sW5P521lZbjzZ2ScS4cSwnAQuC1-QGITA,490
|
|
19
|
-
composabl_cli/template/sim_docker/module/README.md,sha256=XjNdgOyS9RPMkgK2pGLVmYGHIuq9zNFv1HTCaqELmyw,1117
|
|
20
|
-
composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim.py,sha256=mbwpUQCN3kXxTvtZBNP3teMm7b__cKcfkww8j-J514k,7215
|
|
21
|
-
composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
22
|
-
composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim_impl.py,sha256=f7DzBBmD9cKmauWskoSmUpnSVHkubmqGtJQ5d-9Kf-M,2926
|
|
23
|
-
composabl_cli/template/selector_teacher/pyproject.toml,sha256=abFMd5916s3nbYsG60IdNAvkjcC0JNbIJxny67HIQvE,272
|
|
24
|
-
composabl_cli/template/selector_teacher/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
25
|
-
composabl_cli/template/selector_teacher/{{NAME_MODULE}}/teacher.py,sha256=2MZKUN7gUkfUb-pQD7hh7BlPGRcy66YRq13eqVQvWNw,2585
|
|
26
|
-
composabl_cli/template/selector_teacher/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
27
|
-
composabl_cli/template/perceptor/pyproject.toml,sha256=5C4jS4v-5Ai6NaSAcSYUwHDfC93fe5a0oGm1mkeTG0I,273
|
|
28
|
-
composabl_cli/template/perceptor/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
29
|
-
composabl_cli/template/perceptor/{{NAME_MODULE}}/perceptor.py,sha256=OADD3zG17GxIGtO_my1yMq3Sw3KcV9ARJcCFXcIvMEc,1165
|
|
30
|
-
composabl_cli/template/perceptor/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
31
|
-
composabl_cli/template/skill_coach/pyproject.toml,sha256=NJ4XaFkRjzocUwbBjGX6SxkpfPLE9Q-dUEvdPrCp7HY,263
|
|
32
|
-
composabl_cli/template/skill_coach/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
33
|
-
composabl_cli/template/skill_coach/{{NAME_MODULE}}/coach.py,sha256=xC_4_cFI2uXcl-8mVVaS_ADsWL9M8UI3-bcd_kc1WB4,2603
|
|
34
|
-
composabl_cli/template/skill_coach/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
35
|
-
composabl_cli/template/sim/pyproject.toml,sha256=XCnRtO15K0sW5P521lZbjzZ2ScS4cSwnAQuC1-QGITA,490
|
|
36
|
-
composabl_cli/template/sim/README.md,sha256=XjNdgOyS9RPMkgK2pGLVmYGHIuq9zNFv1HTCaqELmyw,1117
|
|
37
|
-
composabl_cli/template/sim/{{NAME_MODULE}}/sim.py,sha256=mbwpUQCN3kXxTvtZBNP3teMm7b__cKcfkww8j-J514k,7215
|
|
38
|
-
composabl_cli/template/sim/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
39
|
-
composabl_cli/template/sim/{{NAME_MODULE}}/sim_impl.py,sha256=f7DzBBmD9cKmauWskoSmUpnSVHkubmqGtJQ5d-9Kf-M,2926
|
|
40
|
-
composabl_cli/template/agent_local/agent.py,sha256=rIi0OpCQvHjsXrI6KOOwHsGcSj1jYXbUsAruYW6hgCc,2749
|
|
41
|
-
composabl_cli/template/skill_controller/pyproject.toml,sha256=cxs9x2geQxCIzWQ6j4J8F8BmE3sMREPfWuWtwSbUGjE,278
|
|
42
|
-
composabl_cli/template/skill_controller/README.md,sha256=6xT3EUAvnNT0zVaVzwVPdBFyp9tOBuQvcEYDYAbeml8,1859
|
|
43
|
-
composabl_cli/template/skill_controller/{{NAME_MODULE}}/controller.py,sha256=h-K6MLRwJuMKva5H8pp5ZLJ9WH4Z6_IIsKxnfVacASY,1372
|
|
44
|
-
composabl_cli/template/skill_controller/{{NAME_MODULE}}/__init__.py,sha256=XAEQrdYyHgWwuZZQOoG2r0RnTegCpEhZUPY63WptO7Y,159
|
|
45
|
-
composabl_cli/cli/cli.cpython-310-darwin.so,sha256=4prajQdHZYWen02GdEGAQC2Y8BOTlg6mMMHi7xTEzH4,163824
|
|
46
|
-
composabl_cli/cli/cli_sim.cpython-310-darwin.so,sha256=EbiuxXNrs_X3zeSDObaHKCwnqSEW3DYkH_1QhtpysKQ,608432
|
|
47
|
-
composabl_cli/cli/cli_perceptor.cpython-310-darwin.so,sha256=IOIj08mAbrJ39P05HQPZXtcwQqNfTp6et545EjoQiRw,295496
|
|
48
|
-
composabl_cli/cli/cli_version.cpython-310-darwin.so,sha256=eCYUMVRZ2kWaesCcjhT90OgoxJVo56Zw7OqIlPCq4ZA,164232
|
|
49
|
-
composabl_cli/cli/cli_main.cpython-310-darwin.so,sha256=ciTfmQvWJgRiZdw1Ua0jRz8Vd8jpmhQDrkAtdsmrwEM,275680
|
|
50
|
-
composabl_cli/cli/cli_historian.cpython-310-darwin.so,sha256=f1gyrVh0MLk-zIk-AacwTacPo5Fu3yRnt_Ez4ASk9vY,217288
|
|
51
|
-
composabl_cli/cli/__init__.cpython-310-darwin.so,sha256=rSYvq9CBuW6K_kV66SmKqIy_I8JxzMpLMF9Ab0t2EAo,88592
|
|
52
|
-
composabl_cli/cli/cli_skill.cpython-310-darwin.so,sha256=12fXOx5ZhKeCWTfQqCP3muAJqRjF6GjlswBdQtFOU-Y,329744
|
|
53
|
-
composabl_cli/cli/cli_benchmark.cpython-310-darwin.so,sha256=adsN4giptwuHg3M8g835tKIuVAQLC_e_H32XvtEC04U,183416
|
|
54
|
-
composabl_cli/cli/cli_selector.cpython-310-darwin.so,sha256=oKcjHwU2w8Eh-HDeZ1UEdx7HsOtVPmxqfL5IZIocDho,329880
|
|
55
|
-
composabl_cli/cli/cli_debug.cpython-310-darwin.so,sha256=LajhsoSr4T5peotY9VQQcm59yFOYv89o2GmZH-9KEu8,147824
|
|
56
|
-
composabl_cli/cli/cli_agent.cpython-310-darwin.so,sha256=zNd9xY4Id1C1RaNZG8DeWSVqaUTgRTuOKHoq8dZaU2w,222736
|
|
57
|
-
composabl_cli/cli/cli_job.cpython-310-darwin.so,sha256=_DXFs5mu-GOY58dvtZQFRgpHQE7LkyZVw93_hljprFI,329040
|
|
58
|
-
composabl_cli/main/selector.cpython-310-darwin.so,sha256=Hoq9P4gsJAvnEzPTmrBRsHYGO83RwRhQpTdr5DEQBBA,240256
|
|
59
|
-
composabl_cli/main/perceptor.cpython-310-darwin.so,sha256=48YEK1X_-hfA1Y7ovxFe9VqbdWFBizFNy_9pvoPbw4A,223120
|
|
60
|
-
composabl_cli/main/sim.cpython-310-darwin.so,sha256=WMxwfw6oaIlEGHDGa9h-8VDW-mhtTJu8gjKk-MR8Q-8,223216
|
|
61
|
-
composabl_cli/main/agent.cpython-310-darwin.so,sha256=PPDwC2E_zynzWK8iEfo3uw5cmDnOFcb-vQrGJSQGz8g,146704
|
|
62
|
-
composabl_cli/main/skill.cpython-310-darwin.so,sha256=yRECArIpL6eqW44OS8tb83JoEnCZqdbCPu2xkmbNM2Q,240304
|
|
63
|
-
composabl_cli-0.9.2.dist-info/RECORD,,
|
|
64
|
-
composabl_cli-0.9.2.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
|
|
65
|
-
composabl_cli-0.9.2.dist-info/entry_points.txt,sha256=WrLVbw0dPbDvkgFcNa275XoyuBvDoP-453FEPMn_cG8,56
|
|
66
|
-
composabl_cli-0.9.2.dist-info/top_level.txt,sha256=EGQnCayGP2E4xx8Z-rUeCIw8n3qRhuqDYQREYU08lwY,14
|
|
67
|
-
composabl_cli-0.9.2.dist-info/METADATA,sha256=AH8LKtx68uI6z5ceEk1vhayUhJYl-nRlu4nk55tez-w,1953
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/composabl_cli/template/{sim_docker/module/{{NAME_MODULE}} → skill_coach/my_skill}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
/composabl_cli/template/{skill_coach/{{NAME_MODULE}} → skill_controller/my_skill}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
/composabl_cli/template/{skill_controller/{{NAME_MODULE}} → skill_teacher/my_skill}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|