def add_ocean_floor(self, depth=100): id = PybulletAPI.loadURDF(resource_filename("lobster_simulator", "data/plane1000.urdf"), base_position=Vec3((0, 0, depth))) texture = PybulletAPI.loadTexture( resource_filename("lobster_simulator", "data/checker_blue.png")) PybulletAPI.changeVisualShape(id, texture, rgbaColor=[1, 1, 1, 1])
def __init__(self, time: SimulationTime): water_id = PybulletAPI.loadURDF( resource_filename("lobster_simulator", "data/water_surface.urdf"), Vec3([0, 0, 0])) self.water_texture = PybulletAPI.loadTexture( resource_filename("lobster_simulator", "data/water_texture.png")) PybulletAPI.changeVisualShape(water_id, textureUniqueId=self.water_texture, rgbaColor=[0, 0.3, 1, 0.5])
def __init__(self, time: SimulationTime, config, start_position: Optional[Vec3] = None, start_orientation: Optional[Quaternion] = None): if config is None: raise ArgumentNoneError("config parameter should not be None") if start_position is None: start_position = Vec3([0, 0, 0]) if start_orientation is None: start_orientation = Quaternion([0, 0, 0, 1]) self._center_of_volume = Vec3(config['center_of_volume']) self.damping_matrix: np.ndarray = np.diag( config['damping_matrix_diag']) object_id = p.loadURDF( resource_filename("lobster_simulator", "data/scout-alpha.urdf"), start_position, start_orientation) super().__init__(object_id) if config.get('visualize_buoyancy', False): # Make sure the robot is slightly see through so that the buoyancy dots are visible PybulletAPI.changeVisualShape(object_id, rgbaColor=[1, 1, 1, 0.7], textureUniqueId=-1) self._buoyancy = buoyancy.Buoyancy( self, 0.10, 2, resolution=config.get('buoyancy_resolution'), visualize=config.get('visualize_buoyancy', False)) config_thrusters = config['thrusters'] self.thrusters: Dict[str, Thruster] = dict() for i in range(len(config_thrusters)): self.thrusters[config_thrusters[i]['name']] = Thruster.new_T200( self, config_thrusters[i]['name'], Vec3(config_thrusters[i]['position']), Vec3(config_thrusters[i]['direction'])) # Set damping to zero, because default is not zero p.changeDynamics(self._object_id, linearDamping=0.0, angularDamping=0.0) self._motor_debug_lines = list() self._motor_count = len(config_thrusters) self._rpm_motors = list() self._desired_rpm_motors: List[float] = list() self._pressure_sensor = PressureSensor(self, Vec3([1, 0, 0]), SimulationTime(4000), time=time) self._accelerometer = Accelerometer(self, Vec3([1, 0, 0]), SimulationTime(4000), time=time) self._gyroscope = Gyroscope(self, Vec3([1, 0, 0]), SimulationTime(4000), time=time) self._magnetometer = Magnetometer(self, Vec3([1, 0, 0]), SimulationTime(4000), time=time) self._dvl = DVL(self, Vec3([-.5, 0, 0.10]), time_step=SimulationTime(4000), time=time) self._max_thrust = 100