Skip to content

Commit 2ef11bb

Browse files
committed
cartpole task
1 parent c80cf60 commit 2ef11bb

File tree

4 files changed

+46
-36
lines changed

4 files changed

+46
-36
lines changed

mjpc/tasks/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ add_custom_target(
2525
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/acrobot/acrobot_modified.xml
2626
${CMAKE_CURRENT_BINARY_DIR}/acrobot/acrobot.xml
2727
<${CMAKE_CURRENT_SOURCE_DIR}/acrobot/acrobot.xml.patch
28-
28+
# cartpole
29+
COMMAND ${CMAKE_COMMAND} -E copy
30+
${dm_control_SOURCE_DIR}/dm_control/suite/cartpole.xml
31+
${CMAKE_CURRENT_BINARY_DIR}/cartpole/cartpole.xml
32+
COMMAND patch -o ${CMAKE_CURRENT_BINARY_DIR}/cartpole/cartpole_modified.xml
33+
${CMAKE_CURRENT_BINARY_DIR}/cartpole/cartpole.xml
34+
<${CMAKE_CURRENT_SOURCE_DIR}/cartpole/cartpole.xml.patch
2935
COMMAND ${CMAKE_COMMAND} -E copy
3036
${menagerie_SOURCE_DIR}/shadow_hand/right_hand.xml
3137
${CMAKE_CURRENT_BINARY_DIR}/hand/right_hand.xml

mjpc/tasks/cartpole/cartpole.xml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/cartpole_modified.xml b/cartpole_modified.xml
2+
--- a/cartpole_modified.xml
3+
+++ b/cartpole_modified.xml
4+
@@ -1,10 +1,6 @@
5+
-<mujoco model="cart-pole">
6+
- <include file="./common/skybox.xml"/>
7+
- <include file="./common/visual.xml"/>
8+
- <include file="./common/materials.xml"/>
9+
-
10+
- <option timestep="0.01" integrator="RK4">
11+
- <flag contact="disable" energy="enable"/>
12+
+<mujoco model="Cartpole">
13+
+ <option timestep="0.001">
14+
+ <flag contact="disable"/>
15+
</option>
16+
17+
<default>
18+
@@ -18,15 +14,16 @@
19+
<light name="light" pos="0 0 6"/>
20+
<camera name="fixed" pos="0 -4 1" zaxis="0 -1 0"/>
21+
<camera name="lookatcart" mode="targetbody" target="cart" pos="0 -2 2"/>
22+
- <geom name="floor" pos="0 0 -.05" size="4 4 .2" type="plane" material="grid"/>
23+
+ <geom name="floor" pos="0 0 -.05" size="4 4 .2" type="plane" material="blue_grid"/>
24+
<geom name="rail1" type="capsule" pos="0 .07 1" zaxis="1 0 0" size="0.02 2" material="decoration" />
25+
<geom name="rail2" type="capsule" pos="0 -.07 1" zaxis="1 0 0" size="0.02 2" material="decoration" />
26+
<body name="cart" pos="0 0 1">
27+
- <joint name="slider" type="slide" limited="true" axis="1 0 0" range="-1.8 1.8" solreflimit=".08 1" damping="5e-4"/>
28+
+ <joint name="slider" type="slide" limited="true" axis="1 0 0" range="-1.8 1.8" solreflimit=".08 1" damping="1.0e-4"/>
29+
<geom name="cart" type="box" size="0.2 0.15 0.1" material="self" mass="1"/>
30+
<body name="pole_1" childclass="pole">
31+
- <joint name="hinge_1"/>
32+
+ <joint name="hinge_1" damping="1.0e-4"/>
33+
<geom name="pole_1"/>
34+
+ <site name="tip" pos="0 0 1"/>
35+
</body>
36+
</body>
37+
</worldbody>

mjpc/tasks/cartpole/task.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<mujoco model="Cart-Pole Swing-Up">
22
<include file="../common.xml"/>
3-
<include file="cartpole.xml" />
3+
<!-- modified from: https://github.com/google-deepmind/dm_control/blob/main/dm_control/suite/cartpole.xml -->
4+
<include file="cartpole_modified.xml" />
45

56
<size memory="4K"/>
67

0 commit comments

Comments
 (0)