def add_ball()

in bisk/helpers.py [0:0]


def add_ball(root: mjcf.RootElement,
             name: str,
             size: float,
             mass: float,
             twod: bool = False,
             **kwargs) -> mjcf.Element:
    root.asset.add('texture',
                   name='ball',
                   builtin='checker',
                   mark='cross',
                   width=151,
                   height=151,
                   rgb1=[0.1, 0.1, 0.1],
                   rgb2=[0.9, 0.9, 0.9],
                   markrgb=[1, 1, 1])
    root.asset.add('material', name='ball', texture='ball')
    ball = root.worldbody.add('body', name=name, pos=[0, 0, 0])
    if twod:
        ball.add('joint',
                 name='ball-x',
                 type='slide',
                 damping=0,
                 axis=[1, 0, 0],
                 pos=[0, 0, 0],
                 range=[-1000, 1000])
        ball.add('joint',
                 name='ball-z',
                 type='slide',
                 damping=0,
                 axis=[0, 0, 1],
                 pos=[0, 0, 0],
                 range=[-1000, 1000])
        ball.add('joint',
                 name='ball-ry',
                 type='hinge',
                 damping=0,
                 axis=[0, 1, 0],
                 pos=[0, 0, 0],
                 range=[-np.pi, np.pi])
    else:
        ball.add('freejoint', name=name)
    ball.add('geom',
             type='sphere',
             name=name,
             size=[size],
             mass=mass,
             condim=6,
             friction=[0.7, 0.005, 0.005],
             solref=[-10000, -30],
             material='ball',
             priority=1)
    return ball