Skip to content

Commit ed9e635

Browse files
authored
Merge branch 'main' into ce
2 parents 6aa2db8 + 4384ef0 commit ed9e635

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
.vs/
1717
# Exclude temporary folders
1818
*.egg-info/
19+
.eggs/
1920
build/
2021
build_cmake/
2122
# Exclude macOS folder attributes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ We provide a simple Python API for MJPC. This API is still experimental and expe
110110
- [direct.py](python/mujoco_mpc/direct.py) for available methods for direct optimization.
111111

112112
## Installing via Pip
113-
The MJPC Python module can be installed with:
113+
First, build MJPC (see above), then the MJPC Python module can be installed with:
114114
```sh
115115
python "${MUJOCO_MPC_ROOT}/python/${API}.py" install
116116
```

python/mujoco_mpc/agent_test.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AgentTest(parameterized.TestCase):
4646
def test_set_task_parameters(self):
4747
model_path = (
4848
pathlib.Path(__file__).parent.parent.parent
49-
/ "mjpc/tasks/cartpole/task.xml"
49+
/ "build/mjpc/tasks/cartpole/task.xml"
5050
)
5151
model = mujoco.MjModel.from_xml_path(str(model_path))
5252
with agent_lib.Agent(task_id="Cartpole", model=model) as agent:
@@ -56,7 +56,7 @@ def test_set_task_parameters(self):
5656
def test_set_subprocess_working_dir(self):
5757
model_path = (
5858
pathlib.Path(__file__).parent.parent.parent
59-
/ "mjpc/tasks/cartpole/task.xml"
59+
/ "build/mjpc/tasks/cartpole/task.xml"
6060
)
6161
model = mujoco.MjModel.from_xml_path(str(model_path))
6262

@@ -76,7 +76,7 @@ def test_set_subprocess_working_dir(self):
7676
def test_step_env_with_planner(self):
7777
model_path = (
7878
pathlib.Path(__file__).parent.parent.parent
79-
/ "mjpc/tasks/particle/task_timevarying.xml"
79+
/ "build/mjpc/tasks/particle/task_timevarying.xml"
8080
)
8181
model = mujoco.MjModel.from_xml_path(str(model_path))
8282
data = mujoco.MjData(model)
@@ -109,7 +109,7 @@ def test_step_env_with_planner(self):
109109
def test_env_initialized_to_home_keyframe(self):
110110
model_path = (
111111
pathlib.Path(__file__).parent.parent.parent
112-
/ "mjpc/tasks/quadruped/task_flat.xml"
112+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
113113
)
114114
model = mujoco.MjModel.from_xml_path(str(model_path))
115115

@@ -126,7 +126,7 @@ def test_action_averaging_doesnt_change_state(self, nominal):
126126
# out physics, but the API should be implemented not to mutate the state
127127
model_path = (
128128
pathlib.Path(__file__).parent.parent.parent
129-
/ "mjpc/tasks/cartpole/task.xml"
129+
/ "build/mjpc/tasks/cartpole/task.xml"
130130
)
131131
model = mujoco.MjModel.from_xml_path(str(model_path))
132132
data = mujoco.MjData(model)
@@ -161,7 +161,7 @@ def test_action_averaging_improves_control(self):
161161
# expect action averaging to be a bit better
162162
model_path = (
163163
pathlib.Path(__file__).parent.parent.parent
164-
/ "mjpc/tasks/cartpole/task.xml"
164+
/ "build/mjpc/tasks/cartpole/task.xml"
165165
)
166166
model = mujoco.MjModel.from_xml_path(str(model_path))
167167
data = mujoco.MjData(model)
@@ -213,7 +213,7 @@ def test_stepping_on_agent_side(self):
213213
"""Test an alternative way of stepping the physics, on the agent side."""
214214
model_path = (
215215
pathlib.Path(__file__).parent.parent.parent
216-
/ "mjpc/tasks/cartpole/task.xml"
216+
/ "build/mjpc/tasks/cartpole/task.xml"
217217
)
218218
model = mujoco.MjModel.from_xml_path(str(model_path))
219219
data = mujoco.MjData(model)
@@ -246,7 +246,7 @@ def test_stepping_on_agent_side(self):
246246
def test_set_cost_weights(self):
247247
model_path = (
248248
pathlib.Path(__file__).parent.parent.parent
249-
/ "mjpc/tasks/cartpole/task.xml"
249+
/ "build/mjpc/tasks/cartpole/task.xml"
250250
)
251251
model = mujoco.MjModel.from_xml_path(str(model_path))
252252

@@ -271,7 +271,7 @@ def test_set_cost_weights(self):
271271
def test_get_cost_weights(self):
272272
model_path = (
273273
pathlib.Path(__file__).parent.parent.parent
274-
/ "mjpc/tasks/cartpole/task.xml"
274+
/ "build/mjpc/tasks/cartpole/task.xml"
275275
)
276276
model = mujoco.MjModel.from_xml_path(str(model_path))
277277

@@ -310,7 +310,7 @@ def test_get_cost_weights(self):
310310
def test_set_state_with_lists(self):
311311
model_path = (
312312
pathlib.Path(__file__).parent.parent.parent
313-
/ "mjpc/tasks/particle/task_timevarying.xml"
313+
/ "build/mjpc/tasks/particle/task_timevarying.xml"
314314
)
315315
model = mujoco.MjModel.from_xml_path(str(model_path))
316316
data = mujoco.MjData(model)
@@ -330,7 +330,7 @@ def test_set_state_with_lists(self):
330330
def test_get_set_default_mode(self):
331331
model_path = (
332332
pathlib.Path(__file__).parent.parent.parent
333-
/ "mjpc/tasks/cartpole/task.xml"
333+
/ "build/mjpc/tasks/cartpole/task.xml"
334334
)
335335
model = mujoco.MjModel.from_xml_path(str(model_path))
336336
with agent_lib.Agent(task_id="Cartpole", model=model) as agent:
@@ -341,7 +341,7 @@ def test_get_set_default_mode(self):
341341
def test_get_set_mode(self):
342342
model_path = (
343343
pathlib.Path(__file__).parent.parent.parent
344-
/ "mjpc/tasks/quadruped/task_flat.xml"
344+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
345345
)
346346
model = mujoco.MjModel.from_xml_path(str(model_path))
347347
with agent_lib.Agent(task_id="Quadruped Flat", model=model) as agent:
@@ -352,7 +352,7 @@ def test_get_set_mode(self):
352352
def test_get_all_modes(self):
353353
model_path = (
354354
pathlib.Path(__file__).parent.parent.parent
355-
/ "mjpc/tasks/quadruped/task_flat.xml"
355+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
356356
)
357357
model = mujoco.MjModel.from_xml_path(str(model_path))
358358
with agent_lib.Agent(task_id="Quadruped Flat", model=model) as agent:
@@ -365,7 +365,7 @@ def test_get_all_modes(self):
365365
def test_set_mode_error(self):
366366
model_path = (
367367
pathlib.Path(__file__).parent.parent.parent
368-
/ "mjpc/tasks/quadruped/task_flat.xml"
368+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
369369
)
370370
model = mujoco.MjModel.from_xml_path(str(model_path))
371371
with agent_lib.Agent(task_id="Quadruped Flat", model=model) as agent:
@@ -374,7 +374,7 @@ def test_set_mode_error(self):
374374
def test_set_task_parameters_from_another_agent(self):
375375
model_path = (
376376
pathlib.Path(__file__).parent.parent.parent
377-
/ "mjpc/tasks/cartpole/task.xml"
377+
/ "build/mjpc/tasks/cartpole/task.xml"
378378
)
379379
model = mujoco.MjModel.from_xml_path(str(model_path))
380380
with agent_lib.Agent(task_id="Cartpole", model=model) as agent:
@@ -393,7 +393,7 @@ def test_set_task_parameters_from_another_agent(self):
393393
def test_best_trajectory(self):
394394
model_path = (
395395
pathlib.Path(__file__).parent.parent.parent
396-
/ "mjpc/tasks/particle/task_timevarying.xml"
396+
/ "build/mjpc/tasks/particle/task_timevarying.xml"
397397
)
398398
model = mujoco.MjModel.from_xml_path(str(model_path))
399399
data = mujoco.MjData(model)
@@ -418,7 +418,7 @@ def test_best_trajectory(self):
418418
def test_set_mocap(self):
419419
model_path = (
420420
pathlib.Path(__file__).parent.parent.parent
421-
/ "mjpc/tasks/particle/task_timevarying.xml"
421+
/ "build/mjpc/tasks/particle/task_timevarying.xml"
422422
)
423423
model = mujoco.MjModel.from_xml_path(str(model_path))
424424
with agent_lib.Agent(task_id="ParticleFixed", model=model) as agent:

python/mujoco_mpc/ui_agent_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_stepping_on_agent_side(self):
4848
"""Test an alternative way of stepping the physics, on the agent side."""
4949
model_path = (
5050
pathlib.Path(__file__).parent.parent.parent
51-
/ "mjpc/tasks/cartpole/task.xml"
51+
/ "build/mjpc/tasks/cartpole/task.xml"
5252
)
5353
model = mujoco.MjModel.from_xml_path(str(model_path))
5454
data = mujoco.MjData(model)
@@ -67,7 +67,9 @@ def test_stepping_on_agent_side(self):
6767
data.qvel = state.qvel
6868
data.act = state.act
6969
data.mocap_pos = np.array(state.mocap_pos).reshape(data.mocap_pos.shape)
70-
data.mocap_quat = np.array(state.mocap_quat).reshape(data.mocap_quat.shape)
70+
data.mocap_quat = np.array(state.mocap_quat).reshape(
71+
data.mocap_quat.shape
72+
)
7173
data.userdata = np.array(state.userdata).reshape(data.userdata.shape)
7274
observations.append(get_observation(model, data))
7375

@@ -79,7 +81,7 @@ def test_stepping_on_agent_side(self):
7981
def test_set_cost_weights(self):
8082
model_path = (
8183
pathlib.Path(__file__).parent.parent.parent
82-
/ "mjpc/tasks/cartpole/task.xml"
84+
/ "build/mjpc/tasks/cartpole/task.xml"
8385
)
8486
model = mujoco.MjModel.from_xml_path(str(model_path))
8587

@@ -109,7 +111,7 @@ def test_set_cost_weights(self):
109111
def test_get_cost_weights(self):
110112
model_path = (
111113
pathlib.Path(__file__).parent.parent.parent
112-
/ "mjpc/tasks/cartpole/task.xml"
114+
/ "build/mjpc/tasks/cartpole/task.xml"
113115
)
114116
model = mujoco.MjModel.from_xml_path(str(model_path))
115117

@@ -141,7 +143,7 @@ def test_get_cost_weights(self):
141143
def test_set_state_with_lists(self):
142144
model_path = (
143145
pathlib.Path(__file__).parent.parent.parent
144-
/ "mjpc/tasks/particle/task_timevarying.xml"
146+
/ "build/mjpc/tasks/particle/task_timevarying.xml"
145147
)
146148
model = mujoco.MjModel.from_xml_path(str(model_path))
147149
data = mujoco.MjData(model)
@@ -161,7 +163,7 @@ def test_set_state_with_lists(self):
161163
def test_set_get_mode(self):
162164
model_path = (
163165
pathlib.Path(__file__).parent.parent.parent
164-
/ "mjpc/tasks/cartpole/task.xml"
166+
/ "build/mjpc/tasks/cartpole/task.xml"
165167
)
166168
model = mujoco.MjModel.from_xml_path(str(model_path))
167169
with self.get_agent(task_id="Cartpole", model=model) as agent:
@@ -184,7 +186,7 @@ def test_get_all_modes(self):
184186
def test_get_set_mode(self):
185187
model_path = (
186188
pathlib.Path(__file__).parent.parent.parent
187-
/ "mjpc/tasks/quadruped/task_flat.xml"
189+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
188190
)
189191
model = mujoco.MjModel.from_xml_path(str(model_path))
190192
with self.get_agent(task_id="Quadruped Flat", model=model) as agent:
@@ -195,7 +197,7 @@ def test_get_set_mode(self):
195197
def test_set_mode_error(self):
196198
model_path = (
197199
pathlib.Path(__file__).parent.parent.parent
198-
/ "mjpc/tasks/quadruped/task_flat.xml"
200+
/ "build/mjpc/tasks/quadruped/task_flat.xml"
199201
)
200202
model = mujoco.MjModel.from_xml_path(str(model_path))
201203
with self.get_agent(task_id="Quadruped Flat", model=model) as agent:

python/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def finalize_options(self):
149149
self.set_undefined_options("build_ext", ("build_lib", "build_lib"))
150150

151151
def run(self):
152-
mjpc_tasks_path = Path(__file__).parent.parent / "mjpc" / "tasks"
152+
mjpc_tasks_path = Path(__file__).parent.parent / "build" / "mjpc" / "tasks"
153+
assert mjpc_tasks_path.exists(), "Build MJPC before installing Python API"
153154
source_paths = (
154155
tuple(mjpc_tasks_path.rglob("*.xml"))
155156
+ tuple(mjpc_tasks_path.rglob("*.png"))

0 commit comments

Comments
 (0)