Пример #1
0
 def setUp(self):
     PybulletAPI.initialize(SimulationTime(1000), False)
     PybulletAPI.gui = MagicMock(return_value=True)
     # Use side_effect to spy on a method: Can assert calls but functionality doesn't change.
     PybulletAPI.addUserDebugLine = MagicMock(
         side_effect=PybulletAPI.addUserDebugLine)
     self._debug_line = DebugLine(Vec3([0, 0, 0]), Vec3([0, 0, 0]))
    def test_creating_test_points_scout_alpha(self):
        PybulletAPI.initialize(SimulationTime(1000), False)

        model_config = 'scout-alpha.json'
        with resource_stream('lobster_simulator', f'data/{model_config}') as f:
            self.robot_config = json.load(f)

        # Currently resolution is not existing?
        resolution = self.robot_config.get('buoyancy_resolution')

        robot = auv.AUV(SimulationTime(5000), self.robot_config)
        buoyancy_obj = buoyancy.Buoyancy(robot, 0.10, 2, resolution=resolution)
        self.assertGreater(len(buoyancy_obj.test_points), 0)
Пример #3
0
    def __init__(self, time_step: int, config=None, gui=True):
        """
        Simulator
        :param time_step: duration of a step in microseconds
        :param config: config of the robot.
        :param gui: start the PyBullet gui when true
        """
        with resource_stream('lobster_simulator', 'data/config.json') as f:
            base_config = json.load(f)

        if config is not None:
            base_config.update(config)

        config = base_config

        self.rotate_camera_with_robot = bool(
            config['rotate_camera_with_robot'])

        self._time: SimulationTime = SimulationTime(0)
        self._previous_update_time: SimulationTime = SimulationTime(0)
        self._previous_update_real_time: float = t.perf_counter()  # in seconds
        self._time_step: SimulationTime = SimulationTime(
            initial_microseconds=time_step)

        self._cycle = 0

        PybulletAPI.initialize(self._time_step, gui)

        self.water_surface = WaterSurface(self._time)

        self._simulator_frequency_slider = PybulletAPI.addUserDebugParameter(
            "simulation frequency", 10, 1000, 1 / self._time_step.microseconds)
        self._buoyancy_force_slider = PybulletAPI.addUserDebugParameter(
            "buoyancyForce", 0, 1000, 550)

        self._model = None
        self.robot_config = None

        self._camera_position = Vec3([0, 0, 0])
        self._robot: Optional[AUV] = None