Example #1
0
  def test_init(self):
    config = configs.Solo8BaseConfig()
    gui = False

    with mock.patch('pybullet_utils.bullet_client.BulletClient') as mock_cls:
      mock_client = mock.MagicMock()
      mock_cls.return_value = mock_client
      env = SimpleSoloEnv(config, gui)

    with self.subTest('config'):
      self.assertEqual(env.config, config)
    
    with self.subTest('client init'):
      mock_client.setAdditionalSearchPath.assert_called_once()
      mock_client.setGravity.assert_called_once()
      mock_client.setPhysicsEngineParameter.assert_called_once()
      mock_client.loadURDF.assert_called_once()

    with self.subTest('factories'):
      self.assertIsInstance(env.obs_factory, obs.ObservationFactory)
      self.assertIsInstance(env.reward_factory, rewards.RewardFactory)
      self.assertIsInstance(env.termination_factory, terms.TerminationFactory)

    with self.subTest('abc methods'):
      self.assertTrue(env.load_bodies_call)
      self.assertTrue(env.reset_call)
Example #2
0
  def test_realtime_simulation(self, mock_cls):
    mock_client = mock.MagicMock()
    mock_cls.return_value = mock_client

    dt = None
    config = configs.Solo8BaseConfig(dt=dt)
    self.assertIsNone(config.dt)

    _ = SimpleSoloEnv(config, False)
    mock_client.setRealTimeSimulation.assert_called_once_with(1)
Example #3
0
  def test_fixed_timestep(self, mock_cls):
    mock_client = mock.MagicMock()
    mock_cls.return_value = mock_client
    
    dt = 20
    config = configs.Solo8BaseConfig(dt=dt)
    self.assertIsNotNone(config.dt)
 
    _ = SimpleSoloEnv(config, False)
    mock_client.setPhysicsEngineParameter.assert_called_once_with(
      fixedTimeStep=dt, numSubSteps=1)
Example #4
0
  def test_GUI(self, name, use_gui, expected_ui, mock_client):
    env = SimpleSoloEnv(configs.Solo8BaseConfig(), use_gui)

    mock_client.assert_called_with(connection_mode=expected_ui)
    self.assertTrue(env.load_bodies_call)
    self.assertTrue(env.reset_call)
Example #5
0
 def setUp(self):
   with mock.patch('pybullet_utils.bullet_client.BulletClient') as self.mock_client:
     self.env = SimpleSoloEnv(configs.Solo8BaseConfig(), False)
Example #6
0
 def test_client_configuration(self):
   env = SimpleSoloEnv(configs.Solo8BaseConfig(), False)
   self.assertEquals(env.client_call, 1)