forked from erwincoumans/motion_imitation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_function.drawio
176 lines (176 loc) · 43.1 KB
/
graph_function.drawio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<mxfile>
<diagram id="Lm4nKWto8GY6URv-1aVc" name="Page-1">
<mxGraphModel dx="3300" dy="2543" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="60" value="motion_imitation/run.py [func defs] + main" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="-820" y="-960" width="370" height="290" as="geometry"/>
</mxCell>
<mxCell id="69" value="<font face="helvetica" style="line-height: 130%"># startup file | functions :<br>- set_rand_seed()<br>- build_model()<br>- train()<br>- test()<br>- main()<br></font>" style="text;whiteSpace=wrap;html=1;" parent="60" vertex="1">
<mxGeometry y="26" width="370" height="114" as="geometry"/>
</mxCell>
<mxCell id="62" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="60" vertex="1">
<mxGeometry y="140" width="370" height="8" as="geometry"/>
</mxCell>
<mxCell id="68" value="<p style="line-height: 130%">main() : # parse command args<br><br># get num of CPUs<br><br># build environement<br>env = env_builder.build_imitation_env()<br>- motion_files, num_cpu</p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" parent="60" vertex="1">
<mxGeometry y="148" width="370" height="142" as="geometry"/>
</mxCell>
<mxCell id="70" value="motion_imitation/envs/env_builder.py : [func defs]" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="-820" y="-260" width="700" height="680" as="geometry">
<mxRectangle x="-1440" y="-200" width="320" height="26" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="71" value="<b>## creates the gym env | functions :</b>&nbsp;<br>build_laikago_env()<br>build_imitation_env()<br>build_regular_env()" style="text;whiteSpace=wrap;html=1;" parent="70" vertex="1">
<mxGeometry y="26" width="700" height="74" as="geometry"/>
</mxCell>
<mxCell id="72" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="70" vertex="1">
<mxGeometry y="100" width="700" height="8" as="geometry"/>
</mxCell>
<mxCell id="73" value="<p style="line-height: 130%"></p><div style="text-align: justify"><span style="font-style: normal">build_imitation_env(motion_files, num_parallel_envs, mode, enable_randomizer, enable_rendering, robot_class=laikago.Laikago,&nbsp;</span></div><span style="font-style: normal"><div style="text-align: justify"><span>trajectory_generator=simple_openloop.LaikagoPoseOffsetGenerator(action_limit=laikago.UPPER_BOUND)) :</span></div></span><div style="text-align: justify"><span># sets episode length</span></div><div style="text-align: justify"><br></div><div style="text-align: justify"><span># creates simulation parameters</span></div><span style="font-style: normal"><div style="text-align: justify"><span>sim_params = SimulationParameters()</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>sim_params = ...</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># sets simulation parameters</span></div><span style="font-style: normal"><div style="text-align: justify"><span>gym_config = LocomotionGymConfig(sim_params)</span></div></span><div style="text-align: justify"><br></div><span style="font-style: normal"><div style="text-align: justify"><span># sets sensors</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>HistoricSensorWrapper()</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>MotorAngleSensor</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>IMUSensor</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>LastActionsSensor</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># sets tast : imitation task</span></div><span style="font-style: normal"><div style="text-align: justify"><span>task = imitation_task.ImitationTask()</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># sets randomizers</span></div><span style="font-style: normal"><div style="text-align: justify"><span>randomizer = ControllableEnvRandomizerFromConfig()</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># creates the env</span></div><span style="font-style: normal"><div style="text-align: justify"><span>env = LocomotionGymEnv(gym_config, robot_class = Laikago, randomizers, sensors, task)</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># flatten observation . transcript it to an array</span></div><span style="font-style: normal"><div style="text-align: justify"><span>env = ObservationDictionnaryToArrayWrapper(env)</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"><span># add the trajectory</span></div><span style="font-style: normal"><div style="text-align: justify"><span>env = TrajectoryGeneratorWrapper(env, trajectory_generator)</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>btw : traj_gen = simple_openloop.LaikagoPoseOffsetGenerator()</span></div></span><div style="text-align: justify"><br></div><div style="text-align: justify"># another wrapper :&nbsp; <span style="font-style: normal"><b>Important !! -&gt; modifies observation (the policy NN input) by concatenating original observation from simulation and observation from dog walk mocap</b></span></div><span style="font-style: normal"><div style="text-align: justify"><span>env = imitationWrapperEnv()</span></div></span><span style="font-style: normal"><div style="text-align: justify"><span>return env</span></div></span><p></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontStyle=2;html=1;whiteSpace=wrap;" parent="70" vertex="1">
<mxGeometry y="108" width="700" height="572" as="geometry"/>
</mxCell>
<mxCell id="74" value="motion_imitation/envs/locomotion_gym_env.py [class]" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="-1780" y="290" width="710" height="1320" as="geometry">
<mxRectangle x="-510" y="110" width="340" height="26" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="75" value="<p style="line-height: 130%"><span><b><i>## class used for the creation of the gym env</i></b><br><u>// attr / args :&nbsp;</u><br></span><span>- gym_config : An instance of LocomotionGymConfig</span><br style="padding: 0px ; margin: 0px"><span>- robot_class :A class of robot. We provide a class rather than an instance due to hard_reset&nbsp;</span><br style="padding: 0px ; margin: 0px"><span>functionality.</span><br style="padding: 0px ; margin: 0px"><span>- sensors : A list of environmental sensors for observation</span><br style="padding: 0px ; margin: 0px"><span>- task : A callable function/class to calculate the reward and termination condition. Takes the gym&nbsp;</span><br style="padding: 0px ; margin: 0px"><span>env as argument when calling.</span><br style="padding: 0px ; margin: 0px"><span>- env_randomizers :&nbsp; A list of EnvRandomizers(s). An EnvRandomizer may randomize the physical</span><br style="padding: 0px ; margin: 0px"><span>property of minitaur, change the terrain during reset(), or add perturbation forces durring step().</span><br style="padding: 0px ; margin: 0px"><br style="padding: 0px ; margin: 0px"><span>Raises : ValueError :&nbsp; If the num_action_repeat is less than 1<br></span><span><br><u>// attrs :</u><br>- world_dict : A dictionnary containing the objects in the world other than the robot<br>- other many miscellaneous attrs...<br><br><u>// functions :</u><br>__init__(self, gym_config, robot_class, env_sensors, robot_sensors, task, env_randomizers)<br>_build_action_space(self) : builds action space based on motor control mode</span></p><p style="line-height: 140%"><span>close(self)</span></p><p style="line-height: 140%"><span>seed(self, seed=None)</span></p><p style="line-height: 140%"><span>all_sensors(self) : Returns all the robot and env sensors</span><span><br></span></p><p style="line-height: 140%"><span>sensor_by_name(self, name) : Returns the sensor with the given name, or None if not exist</span><span><br></span></p><p style="line-height: 140%">**reset(self, initial_motor_angles=None, reset_duration=0.0, reset_visualization_camera=True) : Resets the robot's position in the world or rebuild the sim world.&nbsp;The simulation world will be rebuilt if self._hard_reset is True.**&nbsp;<i>&nbsp;</i><b>C'est ici que je modifie le terrain</b></p><p style="line-height: 140%">**step(self, action) : Step forward the simulation, given the action.**</p><p style="line-height: 140%">render(self, mode='rgb_array')</p><p style="line-height: 140%">get_ground(self)</p><p style="line-height: 140%">set_ground(self)</p><p style="line-height: 140%">// other misc functions</p><p style="line-height: 140%">_get_observation(self): Get observation of this environment from a list of sensors.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Returns : observations : sensory observation in the numpy array format</p><p style="line-height: 140%">**set_time_step(self, num_action_repeat, sim_step=0.001)** : Sets the time step of the environment</p><p style="line-height: 140%"><br></p>" style="text;whiteSpace=wrap;html=1;" parent="74" vertex="1">
<mxGeometry y="26" width="710" height="724" as="geometry"/>
</mxCell>
<mxCell id="76" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="74" vertex="1">
<mxGeometry y="750" width="710" height="8" as="geometry"/>
</mxCell>
<mxCell id="77" value="<p style="line-height: 130%">**reset()** : Args</p><p style="line-height: 130%">initial motor_angles : A list of Floats. The desired joint angles after reset. If None, the robot will use its built-in value&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reset_duration : Float. The time (in seconds) needed to rotate all motors to the desired initial values.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reset_visalization_camera : Whether to reset debug visualization camera on reset.</p><p style="line-height: 130%"><span>Returns : A numpy array contains the initial observation after reset.</span></p><p style="line-height: 130%">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------</p><p style="line-height: 130%">**step()** : Args</p><p style="line-height: 130%">action : Can be a list of desired motor angles for all motors when the robot is in position control mode; A list of desired motor torques. Or a list of tuples, (q, qdot, kp, kd, tau) for hybrid control mode. The action must be compatible with robot's motor control mode. Also, we are not going to use the leg space (swing/extension) definition at the gym level, since they are specific to Minitaur.</p><p style="line-height: 130%">Returns :&nbsp;</p><p style="line-height: 130%">observations : The observation dictionnary. The keys are the sensor names and the values are the sensor readings.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reward : The reward for the current state-action pair.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; done : Whether the episode has ended.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; info : A dictionnary that stores diagnostic information</p><p style="line-height: 130%">Raises :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ValueError : The action dimension is not the same as the number of motors.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ValueError : The magnitude fo actions is out of bounds.</p>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>**set_time_step** :<br>Args :<br>num_action_repeat: The number of simulation steps/action repeats to be executed when calling env.step()<br>sim_step : The simulation time step in Pybullet. By default, the simulation step is 0.001s, which is a good trade-off between simulation speed and accuracy.<br><br>Raises:&nbsp;<br>ValueError : If the num_action_repeat is less than 1." style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;whiteSpace=wrap;" parent="74" vertex="1">
<mxGeometry y="758" width="710" height="562" as="geometry"/>
</mxCell>
<mxCell id="78" value="" style="html=1;verticalAlign=bottom;labelBackgroundColor=none;endArrow=block;endFill=1;exitX=0.003;exitY=0.684;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.003;entryY=0.023;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="68" target="73" edge="1">
<mxGeometry width="160" relative="1" as="geometry">
<mxPoint x="-1530" y="-80" as="sourcePoint"/>
<mxPoint x="-1390" y="-30" as="targetPoint"/>
<Array as="points">
<mxPoint x="-950" y="-715"/>
<mxPoint x="-960" y="-140"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="79" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0;exitDx=0;exitDy=0;entryX=-0.001;entryY=0.701;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="75" target="73" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="80" value="motion_imitation/envs/env_wrappers/imitation_wrapper_env.py : [class]" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="-820" y="620" width="700" height="370" as="geometry">
<mxRectangle x="-1440" y="-200" width="320" height="26" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="81" value="<span>## An env using for training policy with motion imitation<br><span style="font-weight: 400"><u>//Args :</u><br>gym_env (attr)<br>episode_length_start (attr)<br>episode_length_end (attr)<br>curriculum_steps<br>num_parallel_envs<br><br><u>//Attrs:</u><br>_curriculum_steps = int(ceil(curriculum_steps/num_parallel_envs)<br>_total_step_count = 0<br><br><u>// Functions:</u><br>__init__()<br>__getattr__()<br></span><span style="font-weight: 400">step() : steps the wrapped env<br></span><span style="font-weight: normal">reset() : resets the robot's position in the world or rebuild the sim world<br></span><span style="font-weight: normal">_modify_observation() : appends target observations from the reference motion to the observations<br>_build_observation_space() : constructs the obs space, including target obervations from the reference motion<br></span><span style="font-weight: 400">_enable_curriculum() :&nbsp; check if curriculum is enabled<br>_update_time_limit() : updates the current episode length depending on the number of environnement steps taken so far</span><br></span>" style="text;whiteSpace=wrap;html=1;fontStyle=1" parent="80" vertex="1">
<mxGeometry y="26" width="700" height="314" as="geometry"/>
</mxCell>
<mxCell id="82" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="80" vertex="1">
<mxGeometry y="340" width="700" height="8" as="geometry"/>
</mxCell>
<mxCell id="83" value="<p style="line-height: 130%"></p><div style="text-align: justify"><br></div><p></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontStyle=2;html=1;" parent="80" vertex="1">
<mxGeometry y="348" width="700" height="22" as="geometry"/>
</mxCell>
<mxCell id="84" value="" style="endArrow=classic;html=1;entryX=0;entryY=0.015;entryDx=0;entryDy=0;entryPerimeter=0;exitX=-0.006;exitY=0.941;exitDx=0;exitDy=0;exitPerimeter=0;" parent="1" source="73" target="80" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="-830" y="370" as="sourcePoint"/>
<mxPoint x="-630" y="650" as="targetPoint"/>
<Array as="points">
<mxPoint x="-850" y="386"/>
<mxPoint x="-850" y="626"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="90" value="motion_imitation/envs/env_wrappers/imitation_task.py [class]" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="70" y="540" width="730" height="830" as="geometry">
<mxRectangle x="-510" y="110" width="340" height="26" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="91" value="<p style="line-height: 130%"><font style="font-size: 12px"><b><i>## Imitation reference motion task</i></b><br><u>// attr / args:</u><br></font></p><div style="line-height: 18px"><div><u>weight</u>: Float. The scaling factor for the reward.</div><div><u> terminal_condition</u>: Callable object or function. Determines if the task is&nbsp;<span>done.</span></div><div><u> ref_motion_filenames</u>: List of files containing reference motion data.</div><div><u> enable_cycle_sync</u>: Boolean indicating if the root of the reference motion&nbsp;<span>should be synchronized with the root of the simulated robot&nbsp; &nbsp;at the start&nbsp;</span><span>of every cycle to mitigate drift.</span></div><div> clip_velocity: if not None, we will clip the velocity with this value.</div><div><u> tar_frame_steps</u>: The number of steps to sample each target frame to&nbsp;<span>include in the target observations.</span></div><div><u> clip_time_min</u>: Minimum amount of time a reference motion clip is active&nbsp;<span>before switching to another clip.</span></div><div><u> clip_time_max</u>: Maximum amount of time a reference motion clip is active&nbsp;<span>before switching to another clip.</span></div><div><u> ref_state_init_prob</u>: Probability of initializing the robot to a state from&nbsp;<span>the reference at the start of each episode. When not initializing&nbsp; &nbsp;to a&nbsp;</span><span>reference state, the robot will be initialized to the default state.</span></div><div><u> enable_rand_init_time</u>: Flag for enabling randomly initializing to&nbsp;<span>different points in time alont a reference motion.</span></div><div><u> warmup_time</u>: Amount of time for the robot to move from default pose to&nbsp;<span>reference pose at the start of each episode. This helps for&nbsp; &nbsp;deployment,&nbsp;</span><span>so that the robot doesn't try to move to the reference pose too quickly&nbsp;</span><span>from its default pose.</span></div><div><u> pose_weight</u>: Pose reward weight.</div><div><u> velocity_weight</u>: Velocity reward weight.</div><div><u> end_effector_weight</u>: End effector reward weight.</div><div><u> root_pose_weight</u>: Root position and rotation reward weight.</div><div><u> root_velocity_weight</u>: Root linear and angular velocity reward weight.</div><div><u> pose_err_scale</u>: Pose error scale for calculating pose reward.</div><div><u> velocity_err_scale</u>: Velocity error scale for calculating velocity reward.</div><div><u> end_effector_err_scale</u>: End effector error scale for calculating end&nbsp;<span>effector reward.</span></div><div><u> end_effector_height_err_scale</u>: End effector height error scale for&nbsp;<span>calculating the end effector reward.</span></div><div><u> root_pose_err_scale</u>: Root position and rotation error scale for&nbsp;<span>calculating root position and rotation reward.</span></div><div><u> root_velocity_err_scale</u>: Root linear and angular velocity error scale for&nbsp;<span>calculating root linear and angular velocity reward.</span></div><div><u> perturb_init_state_prob</u>: Probability of applying random pertubations to&nbsp;<span>the initial state.</span></div><div><u> tar_obs_noise</u>: List of the standard deviations of the noise to be applied&nbsp;<span>to the target observations [base rotation std, base position&nbsp; &nbsp; &nbsp; std].</span></div><div><u> draw_ref_model_alpha</u>: Color transparency for drawing the reference model.</div></div><p style="line-height: 130%"><span><font style="font-size: 12px"><br><u>// functions :</u><br>__call__(self, env): returns self.reward(env)<br>reset(self, env) : Resets the internal state of the task<br>update(self, env): Updates the internal state of the task<br>done(self, env) : check id the episode is over<br>get_num_motions(self): Get the number of reference motions to be imitated | Returns : Number of reference motions<br>get_num_tar_frames(self): Get the number of target frames to include in the observations<br>get _ref_model(self): Get the reference simulated model used for the reference motion<br>is_motion_over(self): Checks if the current reference motion is over | Returns boolean indicating if the motion is over<br>get_active_motion(self): Get index of the active reference motion currently being imitated | Returns : Index of the active reference motion</font></span></p><p style="line-height: 130%"><span><font style="font-size: 12px"><b>Big file, lots of important functions : computing reward / termination condition / stuff with reference motion ...</b></font></span></p>" style="text;whiteSpace=wrap;html=1;" parent="90" vertex="1">
<mxGeometry y="26" width="730" height="804" as="geometry"/>
</mxCell>
<mxCell id="93" value="" style="endArrow=classic;html=1;exitX=1.002;exitY=0.475;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.42;entryY=-0.004;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="73" target="90" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="40" y="100" as="sourcePoint"/>
<mxPoint x="90" y="50" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="95" value="motion_imitation/utilities/motion_data.py [class]" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="80" y="1520" width="730" height="500" as="geometry">
<mxRectangle x="-510" y="110" width="340" height="26" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="96" value="<p style="line-height: 130%"><b><i>## Read and process motion reference .txt file. Organizes it into a class and provides methods to modify it.<br></i></b>// Args : motion_file</p><p style="line-height: 130%">// Attrs :</p><p style="line-height: 130%"><span style="font-size: 13.5px"># hardcoded json style reading tokens for pasing the .txt conf file</span></p><p style="line-height: 130%"><span style="font-size: 13.5px">POS_SIZE = 3<br></span><span style="font-size: 13.5px">ROT_SIZE = 4<br></span><span style="font-size: 13.5px">VEL_SIZE = 3<br></span><span style="font-size: 13.5px">ANG_VEL_SIZE = 3</span></p><div style="font-size: 13.5px ; line-height: 18px"><div>_LOOP_MODE_KEY = "LoopMode"</div><div> _FRAME_DURATION_KEY = "FrameDuration"</div><div> _FRAMES_KEY = "Frames"</div><div> _ENABLE_CYCLE_OFFSET_POSITION_KEY = "EnableCycleOffsetPosition"</div><div> _ENABLE_CYCLE_OFFSET_ROTATION_KEY = "EnableCycleOffsetRotation"</div><div><div style="line-height: 18px"><div>self._loop_mode = LoopMode.Clamp</div><div> self._frame_duration = 0</div><div> self._frames = None</div><div> self._frame_vels = None</div><div><div style="line-height: 18px"><div> self._cycle_delta_pos = self._calc_cycle_delta_pos()</div><div> self._cycle_delta_heading = self._calc_cycle_delta_heading()</div><div><br></div><div>// functions :&nbsp;</div><div>mainly function for getting/setting precise information from .txt conf file : frames, positions, rotations, quaternions, differences (delta), computing velocities etc...</div></div></div></div></div></div>" style="text;whiteSpace=wrap;html=1;" parent="95" vertex="1">
<mxGeometry y="26" width="730" height="474" as="geometry"/>
</mxCell>
<mxCell id="97" value="" style="endArrow=classic;html=1;exitX=-0.002;exitY=0.905;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.424;entryY=-0.007;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="91" target="95" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="-20" y="1220" as="sourcePoint"/>
<mxPoint x="30" y="1170" as="targetPoint"/>
<Array as="points">
<mxPoint x="10" y="1294"/>
<mxPoint x="10" y="1470"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="116" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="98" target="102" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="98" value="BaseRLModel : Class" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="799" y="-490" width="371" height="110" as="geometry"/>
</mxCell>
<mxCell id="99" value="<font face="helvetica" style="line-height: 130%">load_parameters() # base function for loading ONLY N.N weights<br></font>" style="text;whiteSpace=wrap;html=1;" parent="98" vertex="1">
<mxGeometry y="26" width="371" height="54" as="geometry"/>
</mxCell>
<mxCell id="100" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="98" vertex="1">
<mxGeometry y="80" width="371" height="8" as="geometry"/>
</mxCell>
<mxCell id="101" value="<p style="line-height: 130%"><br></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" parent="98" vertex="1">
<mxGeometry y="88" width="371" height="22" as="geometry"/>
</mxCell>
<mxCell id="117" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="102" target="106" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="102" value="ActorCriticRLModel : Class" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="800" y="-330" width="370" height="110" as="geometry"/>
</mxCell>
<mxCell id="103" value="<font face="helvetica" style="line-height: 130%">load() # load N.N weights and optimizer's hyperparameters<br></font>" style="text;whiteSpace=wrap;html=1;" parent="102" vertex="1">
<mxGeometry y="26" width="370" height="54" as="geometry"/>
</mxCell>
<mxCell id="104" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="102" vertex="1">
<mxGeometry y="80" width="370" height="8" as="geometry"/>
</mxCell>
<mxCell id="105" value="<p style="line-height: 130%"><br></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" parent="102" vertex="1">
<mxGeometry y="88" width="370" height="22" as="geometry"/>
</mxCell>
<mxCell id="118" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="106" target="110" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="106" value="pposgd_simple.PPO1 : Class" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="800" y="-170" width="370" height="110" as="geometry"/>
</mxCell>
<mxCell id="107" value="<font face="helvetica" style="line-height: 130%">save() # save N.N weights and optimizer's hyperparameters in a .zip file<br></font>" style="text;whiteSpace=wrap;html=1;" parent="106" vertex="1">
<mxGeometry y="26" width="370" height="54" as="geometry"/>
</mxCell>
<mxCell id="108" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="106" vertex="1">
<mxGeometry y="80" width="370" height="8" as="geometry"/>
</mxCell>
<mxCell id="109" value="<p style="line-height: 130%"><br></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" parent="106" vertex="1">
<mxGeometry y="88" width="370" height="22" as="geometry"/>
</mxCell>
<mxCell id="110" value="PPOImitation : Class" style="swimlane;fontStyle=1;align=center;verticalAlign=top;childLayout=stackLayout;horizontal=1;startSize=26;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" parent="1" vertex="1">
<mxGeometry x="800" y="-10" width="370" height="110" as="geometry"/>
</mxCell>
<mxCell id="111" value="<font face="helvetica" style="line-height: 130%">setup_model() # self explanatory, sets up the model when creating a&nbsp; brand new model or creating a model from a .zip model save<br></font>" style="text;whiteSpace=wrap;html=1;" parent="110" vertex="1">
<mxGeometry y="26" width="370" height="54" as="geometry"/>
</mxCell>
<mxCell id="112" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;html=1;" parent="110" vertex="1">
<mxGeometry y="80" width="370" height="8" as="geometry"/>
</mxCell>
<mxCell id="113" value="<p style="line-height: 130%"><br></p>" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;html=1;" parent="110" vertex="1">
<mxGeometry y="88" width="370" height="22" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>