in bisk/tasks/goalwall.py [0:0]
def init_sim(self, root: mjcf.RootElement, frameskip: int = 5):
# Add wall
W = 3
WH = 1
WD = 4 + self.init_distance
root.asset.add('material',
name='mat_wall',
reflectance=0.5,
shininess=1,
emission=0.5,
specular=1)
root.worldbody.add('geom',
type='plane',
name='wall',
material='mat_wall',
xyaxes=[0, -1, 0, 0, 0, 1],
size=[W, WH, 1],
pos=[WD, 0, WH],
rgba=[0, 0.5, 0.1, 1])
# Add a visual marker
root.asset.add('texture',
name='tex_dnc',
builtin='checker',
width=50,
height=50,
rgb1=[0, 0, 0],
rgb2=[1, 0.8, 0],
type='2d')
root.asset.add('material',
name='mat_dnc',
reflectance=0.5,
shininess=1,
specular=1,
texrepeat=[1, 10],
texuniform=False,
texture='tex_dnc')
root.worldbody.add('site',
type='box',
name='line',
size=[
0.1,
W,
0.01,
],
pos=[1.5 + self.init_distance, 0, 0.02],
material='mat_dnc')
#rgba=[1, 0, 0, 0.3])
# Add goals on wall
if self.is_2d:
GP = WH
root.worldbody.add('site',
type='ellipsoid',
name='goal',
material='mat_wall',
size=[
0.01,
0.4,
0.4,
],
pos=[WD, 0, GP],
rgba=[1, 1, 1, 1])
root.worldbody.add('site',
type='ellipsoid',
name='goalb',
material='mat_wall',
size=[
0.005,
0.45,
0.45,
],
pos=[WD, 0, GP],
rgba=[1, 0, 0, 1])
else:
root.worldbody.add('site',
type='ellipsoid',
name='goal1',
material='mat_wall',
size=[
0.01,
0.4,
0.4,
],
pos=[WD, -1, WH - 0.35],
rgba=[1, 1, 1, 1])
root.worldbody.add('site',
type='ellipsoid',
name='goal1b',
material='mat_wall',
size=[
0.005,
0.45,
0.45,
],
pos=[WD, -1, WH - 0.35],
rgba=[1, 0, 0, 1])
root.worldbody.add('site',
type='ellipsoid',
name='goal2',
material='mat_wall',
size=[
0.01,
0.4,
0.4,
],
pos=[WD, 1, WH + 0.35],
rgba=[1, 1, 1, 1])
root.worldbody.add('site',
type='ellipsoid',
name='goal2b',
material='mat_wall',
size=[
0.005,
0.45,
0.45,
],
pos=[WD, 1, WH + 0.35],
rgba=[1, 0, 0, 1])
# This is the camera we'll use by default
euler = [80, -5, 0]
if root.compiler.angle == 'radian':
euler = [np.deg2rad(e) for e in euler]
root.worldbody.add('camera',
name='sideline',
mode='fixed',
pos=[WD / 3, -9, 2],
euler=euler)
super().init_sim(root, frameskip)