Skip to content
Permalink
Browse files

Add tracking cameras to the soccer ball.

PiperOrigin-RevId: 234987072
  • Loading branch information...
liusiqi43 authored and alimuldal committed Feb 21, 2019
1 parent 0803f37 commit 9dd5867d1b4c7db6c8f5c93195cfa1caeb91bcaf
Showing with 22 additions and 0 deletions.
  1. +16 −0 dm_control/locomotion/soccer/soccer_ball.py
  2. +6 −0 dm_control/locomotion/soccer/soccer_ball_test.py
@@ -69,6 +69,22 @@ def _build(self, radius=0.35, mass=0.045, name='soccer_ball'):
mass=mass,
material=material)

# Add some tracking cameras for visualization and logging.
self._mjcf_root.worldbody.add(
'camera',
name='ball_cam',
pos=[0, -7, 7],
zaxis=[0, -1, 1],
fovy=70,
mode='trackcom')
self._mjcf_root.worldbody.add(
'camera',
name='ball_cam_far',
pos=[0, -10, 10],
zaxis=[0, -1, 1],
fovy=70,
mode='trackcom')

# Keep track of entities to team mapping.
self._players = []

@@ -62,6 +62,12 @@ def test_detect_hit(self):
# Only one hit registered.
self.assertIsNone(ball.dist_between_last_hits)

def test_has_tracking_cameras(self):
ball = soccer_ball.SoccerBall(radius=0.35, mass=0.045, name='test_ball')
expected_camera_names = ['ball_cam', 'ball_cam_far']
camera_names = [cam.name for cam in ball.mjcf_model.find_all('camera')]
self.assertCountEqual(expected_camera_names, camera_names)


if __name__ == '__main__':
absltest.main()

0 comments on commit 9dd5867

Please sign in to comment.
You can’t perform that action at this time.