composabl-cli-dev 0.9.0.dev66__cp310-cp310-macosx_10_9_universal2.whl → 0.18.6.dev13__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.
- 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/agent.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/template/agent_composabl/agent.py +90 -0
- composabl_cli/template/agent_docker/agent.py +99 -0
- composabl_cli/template/agent_local/agent.py +96 -0
- composabl_cli/template/perceptor/pyproject.toml +4 -1
- composabl_cli/template/selector_controller/pyproject.toml +12 -0
- composabl_cli/template/selector_controller/{{NAME_MODULE}}/controller.py +52 -0
- composabl_cli/template/selector_teacher/README.md +67 -0
- composabl_cli/template/{skill_coach → selector_teacher}/pyproject.toml +2 -2
- composabl_cli/template/{skill_teacher/my_skill → selector_teacher/{{NAME_MODULE}}}/teacher.py +4 -2
- composabl_cli/template/sim/pyproject.toml +1 -1
- composabl_cli/template/sim/{my_sim → {{NAME_MODULE}}}/sim.py +13 -26
- composabl_cli/template/sim/{my_sim → {{NAME_MODULE}}}/sim_impl.py +2 -2
- composabl_cli/template/sim_docker/Dockerfile +45 -0
- composabl_cli/template/sim_docker/README.md +17 -0
- composabl_cli/template/sim_docker/docker/sim-start.sh +14 -0
- composabl_cli/template/sim_docker/main.py +55 -0
- composabl_cli/template/sim_docker/module/README.md +39 -0
- composabl_cli/template/sim_docker/module/pyproject.toml +20 -0
- composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim.py +253 -0
- composabl_cli/template/sim_docker/module/{{NAME_MODULE}}/sim_impl.py +115 -0
- composabl_cli/template/skill_controller/pyproject.toml +1 -1
- composabl_cli/template/skill_controller/{{NAME_MODULE}}/__init__.py +3 -0
- composabl_cli/template/skill_controller/{my_skill → {{NAME_MODULE}}}/controller.py +6 -4
- composabl_cli/template/skill_coordinated_population/README.md +67 -0
- composabl_cli/template/skill_coordinated_population/pyproject.toml +12 -0
- composabl_cli/template/skill_coordinated_population/{{NAME_MODULE}}/__init__.py +3 -0
- composabl_cli/template/{skill_coach/my_skill → skill_coordinated_population/{{NAME_MODULE}}}/coach.py +4 -2
- composabl_cli/template/skill_coordinated_set/README.md +67 -0
- composabl_cli/template/skill_coordinated_set/pyproject.toml +12 -0
- composabl_cli/template/skill_coordinated_set/{{NAME_MODULE}}/__init__.py +3 -0
- composabl_cli/template/skill_coordinated_set/{{NAME_MODULE}}/coach.py +70 -0
- composabl_cli/template/skill_teacher/pyproject.toml +1 -1
- composabl_cli/template/skill_teacher/{{NAME_MODULE}}/__init__.py +3 -0
- composabl_cli/template/skill_teacher/{{NAME_MODULE}}/teacher.py +70 -0
- {composabl_cli_dev-0.9.0.dev66.dist-info → composabl_cli_dev-0.18.6.dev13.dist-info}/METADATA +12 -8
- composabl_cli_dev-0.18.6.dev13.dist-info/RECORD +71 -0
- {composabl_cli_dev-0.9.0.dev66.dist-info → composabl_cli_dev-0.18.6.dev13.dist-info}/WHEEL +1 -1
- composabl_cli_dev-0.9.0.dev66.dist-info/RECORD +0 -44
- /composabl_cli/template/perceptor/{my_perceptor → {{NAME_MODULE}}}/__init__.py +0 -0
- /composabl_cli/template/perceptor/{my_perceptor → {{NAME_MODULE}}}/perceptor.py +0 -0
- /composabl_cli/template/{skill_coach → selector_controller}/README.md +0 -0
- /composabl_cli/template/{sim/my_sim → selector_controller/{{NAME_MODULE}}}/__init__.py +0 -0
- /composabl_cli/template/{skill_coach/my_skill → selector_teacher/{{NAME_MODULE}}}/__init__.py +0 -0
- /composabl_cli/template/{skill_controller/my_skill → sim/{{NAME_MODULE}}}/__init__.py +0 -0
- /composabl_cli/template/{skill_teacher/my_skill → sim_docker/module/{{NAME_MODULE}}}/__init__.py +0 -0
- {composabl_cli_dev-0.9.0.dev66.dist-info → composabl_cli_dev-0.18.6.dev13.dist-info}/entry_points.txt +0 -0
- {composabl_cli_dev-0.9.0.dev66.dist-info → composabl_cli_dev-0.18.6.dev13.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
|
|
Binary file
|
|
@@ -0,0 +1,90 @@
|
|
|
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()
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
"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()
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
"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()
|
|
@@ -4,9 +4,12 @@ version = "0.1.0"
|
|
|
4
4
|
description = "{{DESCRIPTION}}"
|
|
5
5
|
authors = [{ name = "John Doe", email = "john.doe@composabl.com" }]
|
|
6
6
|
dependencies = [
|
|
7
|
-
"composabl-core"
|
|
7
|
+
"composabl-core{{COMPOSABL_DEV}}{{COMPOSABL_CORE_VERSION}}",
|
|
8
8
|
]
|
|
9
9
|
|
|
10
10
|
[composabl]
|
|
11
11
|
type = "perceptor"
|
|
12
|
+
variables = [
|
|
13
|
+
"counter_derived"
|
|
14
|
+
]
|
|
12
15
|
entrypoint = "{{NAME_MODULE}}.perceptor:DemoPerceptor"
|
|
@@ -0,0 +1,12 @@
|
|
|
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{{COMPOSABL_DEV}}{{COMPOSABL_CORE_VERSION}}",
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
[composabl]
|
|
11
|
+
type = "selector-controller"
|
|
12
|
+
entrypoint = "{{NAME_MODULE}}.controller:Controller"
|
|
@@ -0,0 +1,52 @@
|
|
|
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 Dict, List
|
|
6
|
+
|
|
7
|
+
from composabl_core import SkillController
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Controller(SkillController):
|
|
11
|
+
"""
|
|
12
|
+
We start at 10 reward and count down to 0 the goal is that the agent stays
|
|
13
|
+
above or equal to 0 this means it learned to cound +1 each time
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, *args, **kwargs):
|
|
17
|
+
self.past_obs = None
|
|
18
|
+
self.counter = 10
|
|
19
|
+
self.sensor_name = "counter"
|
|
20
|
+
|
|
21
|
+
async def compute_action(self, transformed_sensors: Dict, action) -> List[float]:
|
|
22
|
+
"""
|
|
23
|
+
Compute action in a programme selector is to select the best skill based in a rule or an optimization.
|
|
24
|
+
Let's supose that we have three skills:
|
|
25
|
+
1 - Decrease counter
|
|
26
|
+
2 - Increase counter
|
|
27
|
+
3 - Stop
|
|
28
|
+
"""
|
|
29
|
+
# return Skill 1 = decrease
|
|
30
|
+
if self.counter > 10:
|
|
31
|
+
return [0]
|
|
32
|
+
# return Skill 2 = increase
|
|
33
|
+
elif self.counter < 10:
|
|
34
|
+
return [1]
|
|
35
|
+
# return Skill 3 = stop
|
|
36
|
+
else:
|
|
37
|
+
return [3]
|
|
38
|
+
|
|
39
|
+
async def compute_success_criteria(self, transformed_sensors: Dict, action) -> bool:
|
|
40
|
+
return bool(transformed_sensors[self.sensor_name] >= 10)
|
|
41
|
+
|
|
42
|
+
async def compute_termination(self, transformed_sensors: Dict, action) -> bool:
|
|
43
|
+
return bool(transformed_sensors[self.sensor_name] <= -10)
|
|
44
|
+
|
|
45
|
+
async def transform_sensors(self, sensors, action) -> str:
|
|
46
|
+
return sensors
|
|
47
|
+
|
|
48
|
+
async def transform_action(self, transformed_sensors: Dict, action) -> float:
|
|
49
|
+
return action
|
|
50
|
+
|
|
51
|
+
async def filtered_sensor_space(self) -> List[str]:
|
|
52
|
+
return ["counter"]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
This is a template for creating a new Perceptor. A Perceptor is a component that is responsible for processing data and returning a result. This can be used for example in a Machine Learning model, where the Perceptor is responsible for processing the data and returning the prediction.
|
|
4
|
+
|
|
5
|
+
## Tree Structure
|
|
6
|
+
|
|
7
|
+
The template is structured as follows:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
my-perceptor/ # Root folder
|
|
11
|
+
├── my_perceptor/ # Main package folder
|
|
12
|
+
│ ├── __init__.py # Package init file
|
|
13
|
+
│ └── perceptor.py # Main perceptor file
|
|
14
|
+
├── pyproject.toml # Project configuration, containing [composabl]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## PyProject [composabl] Section
|
|
18
|
+
|
|
19
|
+
We add the `[composabl]` section to the `pyproject.toml` file to specify the type of component we are creating as well as its entrypoint. This is used by the Composabl CLI to determine the type of
|
|
20
|
+
component and how to handle it.
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
[composabl]
|
|
26
|
+
type = "teacher"
|
|
27
|
+
entrypoint = "my_perceptor.perceptor:MyPerceptor"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
To work on the Perceptor, you can simply create a temporary file or main file that starts up and executes the `compute` method of the portable Perceptor. Example, we can create a `test.py` file with:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from composabl_perceptor_my_perceptor.perceptor import MyPerceptor
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
async def start():
|
|
39
|
+
p = MyPerceptor()
|
|
40
|
+
res = await t.compute(None, [1.0])
|
|
41
|
+
print(res)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
import asyncio
|
|
46
|
+
|
|
47
|
+
asyncio.run(start())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Which we can then run with
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Install the module
|
|
54
|
+
pip install -e my-perceptor
|
|
55
|
+
|
|
56
|
+
# Run the test file
|
|
57
|
+
python my-perceptor/test.py
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Preparing for Upload
|
|
61
|
+
|
|
62
|
+
Once we are ready for uploading, we can create a `.tar.gz` file that contains the version. This can be done with the following command:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Tar GZ the plugin
|
|
66
|
+
tar -czvf my-perceptor-0.0.1.tar.gz my-perceptor
|
|
67
|
+
```
|
composabl_cli/template/{skill_teacher/my_skill → selector_teacher/{{NAME_MODULE}}}/teacher.py
RENAMED
|
@@ -49,7 +49,9 @@ class Teacher(SkillTeacher):
|
|
|
49
49
|
else:
|
|
50
50
|
return -2 * math.exp(-abs(counter - 10)) + 100
|
|
51
51
|
|
|
52
|
-
async def compute_action_mask(
|
|
52
|
+
async def compute_action_mask(
|
|
53
|
+
self, transformed_sensors: Dict, action
|
|
54
|
+
) -> List[bool]:
|
|
53
55
|
return None
|
|
54
56
|
|
|
55
57
|
async def compute_success_criteria(self, transformed_sensors: Dict, action) -> bool:
|
|
@@ -65,4 +67,4 @@ class Teacher(SkillTeacher):
|
|
|
65
67
|
return action
|
|
66
68
|
|
|
67
69
|
async def filtered_sensor_space(self) -> List[str]:
|
|
68
|
-
return [
|
|
70
|
+
return ["counter"]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import math
|
|
6
6
|
import random
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Optional
|
|
8
8
|
|
|
9
9
|
import gymnasium as gym
|
|
10
10
|
import numpy as np
|
|
@@ -22,9 +22,13 @@ class Env(gym.Env):
|
|
|
22
22
|
"angle_speed": {"low": -3, "high": 3},
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
deg_to_rad = 0.01745329
|
|
26
|
+
self.max_gimble = 20 * deg_to_rad
|
|
27
|
+
self.min_gimble = -self.max_gimble
|
|
28
|
+
|
|
25
29
|
self.action_constraints = {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
30
|
+
"angle": {"low": self.min_gimble, "high": self.max_gimble},
|
|
31
|
+
"thrust": {"low": 0.4, "high": 1},
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
low_list = [x["low"] for x in self.obs_space_constraints.values()]
|
|
@@ -120,24 +124,12 @@ class Env(gym.Env):
|
|
|
120
124
|
self.min_thrust = 880 * 1000 # N
|
|
121
125
|
self.max_thrust = 1 * 2210 * 1000 # kN
|
|
122
126
|
|
|
123
|
-
deg_to_rad = 0.01745329
|
|
124
|
-
|
|
125
|
-
self.max_gimble = 20 * deg_to_rad
|
|
126
|
-
self.min_gimble = -self.max_gimble
|
|
127
|
-
|
|
128
127
|
# Define scenario in the simulation ******
|
|
129
128
|
if isinstance(self.scenario, Scenario):
|
|
130
129
|
sample = self.scenario.sample()
|
|
131
130
|
|
|
132
131
|
for key in list(sample.keys()):
|
|
133
132
|
setattr(self, key, sample[key])
|
|
134
|
-
else:
|
|
135
|
-
self.x_obs0 = x_obs0
|
|
136
|
-
self.x_speed0 = x_speed0
|
|
137
|
-
self.y_obs0 = y_obs0
|
|
138
|
-
self.y_speed0 = y_speed0
|
|
139
|
-
self.angle0 = angle0
|
|
140
|
-
self.ang_speed0 = ang_speed0
|
|
141
133
|
|
|
142
134
|
# Set the number of steps and the timestep (dt)
|
|
143
135
|
steps = 400
|
|
@@ -164,7 +156,7 @@ class Env(gym.Env):
|
|
|
164
156
|
self.angle = self.x[self.cnt, 4]
|
|
165
157
|
self.ang_speed = self.x[self.cnt, 5]
|
|
166
158
|
|
|
167
|
-
self.t = 0
|
|
159
|
+
self.t = 0.4
|
|
168
160
|
self.a = 0
|
|
169
161
|
self.reward_value = 0
|
|
170
162
|
|
|
@@ -193,16 +185,14 @@ class Env(gym.Env):
|
|
|
193
185
|
v = sum([x**2 for x in lt])
|
|
194
186
|
return v
|
|
195
187
|
|
|
196
|
-
|
|
197
|
-
|
|
188
|
+
angle = action[0]
|
|
189
|
+
thrust = action[1]
|
|
198
190
|
|
|
199
191
|
actuator_noise = 0
|
|
200
|
-
self.t
|
|
192
|
+
self.t = thrust + random.uniform(
|
|
201
193
|
-actuator_noise * thrust, actuator_noise * thrust
|
|
202
194
|
)
|
|
203
|
-
self.a
|
|
204
|
-
-actuator_noise * angle, actuator_noise * angle
|
|
205
|
-
)
|
|
195
|
+
self.a = angle + random.uniform(-actuator_noise * angle, actuator_noise * angle)
|
|
206
196
|
|
|
207
197
|
self.t = np.clip(self.t, 0.4, 1)
|
|
208
198
|
self.a = np.clip(self.a, self.min_gimble, self.max_gimble)
|
|
@@ -228,9 +218,6 @@ class Env(gym.Env):
|
|
|
228
218
|
self.angle = self.x[self.cnt, 4]
|
|
229
219
|
self.ang_speed = self.x[self.cnt, 5]
|
|
230
220
|
|
|
231
|
-
# self.x_goal = obs['desired_goal'][0]
|
|
232
|
-
# self.y_goal = obs['desired_goal'][1]
|
|
233
|
-
|
|
234
221
|
# update obs with new state values
|
|
235
222
|
self.obs = {
|
|
236
223
|
"x": self.x_obs,
|
|
@@ -243,7 +230,7 @@ class Env(gym.Env):
|
|
|
243
230
|
# add noise
|
|
244
231
|
for key in list(self.obs.keys()):
|
|
245
232
|
val = float(self.obs[key])
|
|
246
|
-
sensor_noise = 0.0
|
|
233
|
+
sensor_noise = 0.0
|
|
247
234
|
self.obs[key] = val + random.uniform(
|
|
248
235
|
-val * sensor_noise, val * sensor_noise
|
|
249
236
|
)
|
|
@@ -7,10 +7,10 @@ from typing import Any, Dict, SupportsFloat, Tuple
|
|
|
7
7
|
import composabl_core.utils.logger as logger_util
|
|
8
8
|
import gymnasium as gym
|
|
9
9
|
from composabl_core.agent.scenario import Scenario
|
|
10
|
-
from composabl_core.networking.server_composabl import ServerComposabl
|
|
10
|
+
from composabl_core.networking.sim.server_composabl import ServerComposabl
|
|
11
11
|
from gymnasium.envs.registration import EnvSpec
|
|
12
12
|
|
|
13
|
-
from
|
|
13
|
+
from .sim import Env
|
|
14
14
|
|
|
15
15
|
logger = logger_util.get_logger(__name__)
|
|
16
16
|
|
|
@@ -0,0 +1,45 @@
|
|
|
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"]
|