Skip to content

Commit a802c14

Browse files
authored
Merge pull request #2 from addy1997/slider
slider xml script added with test
2 parents 74cb8d9 + 2c14840 commit a802c14

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

examples/slider.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!-- Author: [email protected]-->
2+
<mujoco model='slider-v1.5'>
3+
<compiler inertiafromgeom='true' angle='radian'/>
4+
5+
<default>
6+
<joint limited='true' damping='0.01' armature='0' frictionloss='0.1' />
7+
<geom contype='1' conaffinity='1' condim='3' rgba='0.8 0.6 .4 1'
8+
margin="0.001" solref=".02 1" solimp=".8 .8 .01" material="geom" density="50"/>
9+
<motor ctrlrange='-1 1' ctrllimited='true'/>
10+
</default>
11+
12+
<option timestep='0.002' iterations="50" solver="PGS">
13+
<flag energy="enable"/>
14+
</option>
15+
16+
<visual>
17+
<map fogstart="3" fogend="5" force="0.1" znear="0.1"/>
18+
<quality shadowsize="2048"/>
19+
<global offwidth="800" offheight="800"/>
20+
</visual>
21+
22+
<asset>
23+
<texture type="skybox" builtin="gradient" width="128" height="128" rgb1=".4 .6 .8"
24+
rgb2="0 0 0"/>
25+
<texture name="texgeom" type="cube" builtin="flat" mark="cross" width="127" height="1278" markrgb="1 1 1" random="0.01"/>
26+
<texture name="texplane" type="2d" builtin="checker" rgb1=".2 .3 .4" rgb2=".1 0.15 0.2"
27+
width="512" height="512"/>
28+
29+
<material name='MatPlane' reflectance='0.5' texture="texplane" texrepeat="1 1" texuniform="true"/>
30+
<material name='geom' texture="texgeom" texuniform="true"/>
31+
</asset>
32+
33+
34+
35+
<worldbody>
36+
<light directional='true' diffuse='.8 .8 .8' specular='0.3 0.3 0.3' pos='0 -.15 1.0' dir='0 -.15 -1'/>
37+
<geom name='floor' pos='4 0 0' size='7 2 .125' conaffinity='0' contype='0' type='plane' material="MatPlane" condim='3'/>
38+
<geom name="track_boss" type="capsule" pos='0 0 .15' conaffinity='0' contype='0' size=".055 1" euler='0 1.57 0'/>
39+
<geom name="track_worker" type="capsule" pos='4 0 .15' conaffinity='0' contype='0' size=".05 5" euler='0 1.57 0' rgba='.3 .8 .7 1'/>
40+
<geom name="target" type="box" pos='6 0 .15' conaffinity='0' contype='0' size=".16 .16 .16" rgba='0 1 0 .4'/>
41+
42+
43+
<body name='boss' pos='-.5 0 .15'>
44+
<geom name='ball' type='sphere' size='.15'/>
45+
<joint name='ballx' type='slide' axis='1 0 0' range='-.5 1.5'/>
46+
</body>
47+
48+
<body name='worker' pos='0 0 .15'>
49+
<geom type='box' size='.15 .15 .15' rgba='.3 .8 .7 1'/>
50+
<joint name='workerx' type='slide' axis='1 0 0' limited='true' range='-1 9' frictionloss="2"/>
51+
</body>
52+
</worldbody>
53+
54+
<actuator>
55+
<motor name='bossx' gear='50' joint='ballx'/>
56+
</actuator>
57+
58+
<sensor>
59+
<jointpos name="ballx" joint="ballx"/>
60+
</sensor>
61+
62+
</mujoco>

examples/test_slider.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pymujoco import *
2+
r = mjv_create_renderer()
3+
4+
#help(p)
5+
m = mj_loadXML("slider.xml")
6+
#print(m.qpos0)
7+
#print(m.nq)
8+
#print(m.nv)
9+
d = mj_makeData(m)
10+
11+
exit_requested=False
12+
while not exit_requested:
13+
mj_step(m,d)
14+
15+
print(d.qpos)
16+
exit_requested = r.render(m,d)
17+
18+
names = ''.join([row.tostring().decode('UTF-8') for row in m.names]).split('\x00')
19+
print("names=",names)
20+
mj_printModel(m, "slider.txt")
21+
mj_deleteData(d)
22+
mj_deleteModel(m)
23+
24+
mjv_delete_renderer(r)

0 commit comments

Comments
 (0)