Environments
Module containing the environment interface for HoloOcean. An environment contains all elements required to communicate with a world binary or HoloOceanCore editor.
It specifies an environment, which contains a number of agents, and the interface for communicating with the agents.
Classes:
|
Proxy for communicating with a HoloOcean world |
- class holoocean.environments.HoloOceanEnvironment(agent_definitions=None, binary_path=None, window_size=None, start_world=True, uuid='', gl_version=4, verbose=False, pre_start_steps=2, show_viewport=True, ticks_per_sec=None, frames_per_sec=None, copy_state=True, scenario=None, set_fps=None, set_tps=None)
Proxy for communicating with a HoloOcean world
Instantiate this object using
holoocean.holoocean.make().- Parameters:
agent_definitions (
listofAgentDefinition) – Which agents are already in the environmentbinary_path (
str, optional) – The path to the binary to load the world from. Defaults to None.window_size ((
int,:obj:int)) – height, width of the window to openstart_world (
bool, optional) – Whether to load a binary or not. Defaults to True.uuid (
str) – A unique identifier, used when running multiple instances of holoocean. Defaults to “”.gl_version (
int, optional) – The version of OpenGL to use for Linux. Defaults to 4.verbose (
bool) – If engine log output should be printed to stdoutpre_start_steps (
int) – Number of ticks to call after initializing the world, allows the level to load and settle.show_viewport (
bool, optional) – If the viewport should be shown (Linux only) Defaults to True.ticks_per_sec (
int, optional) – The number of frame ticks per unreal seconds. This will override whatever is in the configuration json. Defaults to 30.frames_per_sec (
intorbool, optional) – The max number of frames ticks per real seconds. This will override whatever is in the configuration json. If True, will match ticks_per_sec. If False, will not be turned on. If an integer, will set to that value. Defaults to true.copy_state (
bool, optional) – If the state should be copied or returned as a reference. Defaults to True.scenario (
dict) – The scenario that is to be loaded. See Scenario File Format for the schema.
Methods:
act(agent_name, action)Supplies an action to a particular agent, but doesn't tick the environment.
add_agent(agent_def[, is_main_agent])Add an agent in the world.
air_fog(fogDensity[, fogDepth, color_R, ...])Changes the air fog density, depth, and color.
centered_range(num_points[, spacing])Creates a symmetric range around 0, such that 0 is exactly included, even if num_points is even.
change_buoyancy(buoyancy_selection)Changes the buoyancy type applied to agents
change_time_of_day(TimeOfDay)Changes the world's time of day.
change_weather(weather)Changes the weather in the world.
debug_lines(param_name)Shows various pre-set debug lines.
draw_arrow(start, end[, color, thickness, ...])Draws a debug arrow in the world
draw_box(center, extent[, color, thickness, ...])Draws a debug box in the world
draw_debug_vector_field(currents_function, ...)Create a temporary vector field by drawing vectors at points within a 3D matrix to help demonstrate flow of ocean currents
draw_line(start, end[, color, thickness, ...])Draws a debug line in the world
draw_point(loc[, color, thickness, lifetime])Draws a debug point in the world
enable_world_collisions(enable_collision)Enable or disable world collisions.
get_joint_constraints(agent_name, joint_name)Returns the corresponding swing1, swing2 and twist limit values for the
Returns the reward and terminal state
info()Returns a string with specific information about the environment.
initialize_bst_graphs(**kwargs)Initialize the bst heat maps for visualization and return BST visualizer instance.
move_viewport(location, rotation)Teleport the camera to the given location
reset()Resets the environment, and returns the state.
send_acoustic_message(id_from, id_to, ...)Send a message from one beacon to another.
send_optical_message(id_from, id_to, msg_data)Sends data between various instances of OpticalModemSensor
send_world_command(name[, num_params, ...])Send a world command.
set_biomass_function(agent_name, new_fx)Change the default biomass function to your own custom function :param agent_name: The name of the agent that you want to change biomass function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument "location" :type new_fx:callableset_control_scheme(agent_name, control_scheme)Set the control scheme for a specific agent.
set_fps(fps)Sets the frames per second of the environment.
set_ocean_currents(agent_name, velocity)Send the ocean current velocity at the location of the vehicle to the server to be transformed into a force vector and applied to the vehicle.
set_rain_parameters(vel_x, vel_y, vel_z, ...)Changes the rain's velocity and spawn rate.
set_render_quality(render_quality[, ...])Adjusts the rendering quality of HoloOcean.
set_salinity_function(agent_name, new_fx)Change the default salinity function to your own custom function :param agent_name: The name of the agent that you want to change salinity function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument "location" :type new_fx:callableset_sensor_rate(agent_name, sensor_name, hz)Sets how often a sensor is sampled, in Hz.
set_show_vector_field_name(state)Set whether to show the vector field name in the viewport.
set_temperature_function(agent_name, new_fx)Change the default temperature function to your own custom function :param agent_name: The name of the agent that you want to change temperature function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument "location" :type new_fx:callableset_ticks_per_sec(ticks_per_sec)Sets the ticks per second of the environment.
should_render_viewport(render_viewport)Controls whether the viewport is rendered or not
spawn_prop(prop_type[, location, rotation, ...])Spawns a basic prop object in the world like a box or sphere.
step(action[, ticks, publish])Supplies an action to the main agent and tells the environment to tick once.
tick([num_ticks, publish, tick_clock])Ticks the environment once.
tide(adjustment[, absolute, choice, instant])Deprecated, use
env.ocean.tide.set_parameters()instead.turn_off_flashlight(agent_tag, flashlight_name)Turns off the vehicle's flashlight.
turn_on_flashlight(agent_tag, flashlight_name)Turns on the vehicle's flashlight and sets its visual parameters.
water_color(red, green, blue)Changes the color of the water.
water_fog(fogDensity[, fogDepth, color_R, ...])Changes the water fog density, depth, and color.
Attributes:
Gives the action space for the main agent.
Gets all instances of AcousticBeaconSensor in the environment.
Gets all ids of AcousticBeaconSensor in the environment.
Gets all status of AcousticBeaconSensor in the environment.
Deprecated, use
env.ocean.wavesinstead.Gets all instances of OpticalModemSensor in the environment.
Gets all ids of OpticalModemSensor in the environment.
Deprecated, use
env.ocean.tideinstead.Deprecated, use
env.ocean.tideinstead.- act(agent_name, action)
- Supplies an action to a particular agent, but doesn’t tick the environment.
Primary mode of interaction for multi-agent environments. After all agent commands are supplied, they can be applied with a call to tick.
- Parameters:
agent_name (
str) – The name of the agent to supply an action for.action (
np.ndarrayorlist) – The action to apply to the agent. This action will be applied every time tick is called, until a new action is supplied with another call to act.
- property action_space
Gives the action space for the main agent.
- Returns:
The action space for the main agent.
- Return type:
- add_agent(agent_def, is_main_agent=False)
Add an agent in the world.
It will be spawn when
tick()orstep()is called next.The agent won’t be able to be used until the next frame.
- Parameters:
agent_def (
AgentDefinition) – The definition of the agent tospawn.
- air_fog(fogDensity, fogDepth=3.0, color_R=0.45, color_G=0.5, color_B=0.6)
Changes the air fog density, depth, and color. :param fogDensity: The density value for the fog. Range: 0.0 to 10.0. :type fogDensity:
float:param fogDepth: The distance at which the fog begins. Range: 0.0 to 10.0. (Default = 3) :type fogDepth:float:param color_R: The red component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.45) :type color_R:float:param color_G: The green component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.5) :type color_G:float:param color_B: The blue component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.6) :type color_B:float
- property beacons
Gets all instances of AcousticBeaconSensor in the environment.
- Returns:
List of all AcousticBeaconSensor in environment
- Return type:
(
listofAcousticBeaconSensor)
- property beacons_id
Gets all ids of AcousticBeaconSensor in the environment.
- Returns:
List of all AcousticBeaconSensor ids in environment
- Return type:
(
listofint)
- property beacons_status
Gets all status of AcousticBeaconSensor in the environment.
- Returns:
List of all AcousticBeaconSensor status in environment
- Return type:
(
listofstr)
- centered_range(num_points, spacing=1.0)
Creates a symmetric range around 0, such that 0 is exactly included, even if num_points is even.
- change_buoyancy(buoyancy_selection)
Changes the buoyancy type applied to agents
- Parameters:
buoyancy_selection (
int) – 0 for bounding box buoyancy - incompatible with waves, 1 for mesh based buoyancy - compatible with waves
- change_time_of_day(TimeOfDay)
Changes the world’s time of day.
- Parameters:
TimeOfDay (
float) – Time of day desired, a number between 0 and 23 inclusive.
- change_weather(weather)
Changes the weather in the world.
- Parameters:
weather (
int) – The weather wanted (0 - sunny, 1 - cloudy, 2 - rainy).
- debug_lines(param_name)
Shows various pre-set debug lines.
- Parameters:
param_name (
float) – Any of the following: DebugMesh, DebugWaterPatch, DebugWaterNormals, DebugForceVectors.
- draw_arrow(start, end, color=None, thickness=10.0, lifetime=1.0)
Draws a debug arrow in the world
- Parameters:
start (
listoffloat) – The start[x, y, z]location in meters of the line. (see Coordinate System)end (
listoffloat) – The end[x, y, z]location in meters of the arrowcolor (
list) –[r, g, b]color value (from 0 to 255). Defaults to [255, 0, 0] (red).thickness (
float) – Thickness of the arrow. Defaults to 10.lifetime (
float) – Number of simulation seconds the object should persist. If 0, makes persistent. Defaults to 1.
- draw_box(center, extent, color=None, thickness=10.0, lifetime=1.0)
Draws a debug box in the world
- Parameters:
center (
listoffloat) – The start[x, y, z]location in meters of the box. (see Coordinate System)extent (
listoffloat) – The[x, y, z]extent of the boxcolor (
list) –[r, g, b]color value (from 0 to 255). Defaults to [255, 0, 0] (red).thickness (
float) – Thickness of the lines. Defaults to 10.lifetime (
float) – Number of simulation seconds the object should persist. If 0, makes persistent. Defaults to 1.
- draw_debug_vector_field(currents_function, location, vector_field_dimensions=[30, 30, 30], spacing=20, arrow_thickness=10, arrow_size=1, lifetime=40)
Create a temporary vector field by drawing vectors at points within a 3D matrix to help demonstrate flow of ocean currents
- Parameters:
currents_function (
Callable) – A vector field function that takes in a 3 element location vector [x,y,z] and outputs a 3D currents velocity vector [x,y,z]location (
list) – A 3D vector [x,y,z] that represents where you want to draw the center of the vector fieldvector_field_dimensions (
list) – A 3 element vector that represents the dimensions [x,y,z] of the vector field generatedspacing (
int) – How much space is in between each vector in meters (defaults to 20)arrow_thickness (
int) – A measure of how thick each of the debug vectors are (defaults to 10)arrow_size (
int) – A scalar that affects length of each debug arrow at different strengths (defaults to 1)lifetime (
int) – A scalar to determine the length of time that the arrows persist in the simulation (defaults to 40)
- draw_line(start, end, color=None, thickness=10.0, lifetime=1.0)
Draws a debug line in the world
- Parameters:
start (
listoffloat) – The start[x, y, z]location in meters of the line. (see Coordinate System)end (
listoffloat) – The end[x, y, z]location in meters of the linecolor (
list`) –[r, g, b]color value (from 0 to 255). Defaults to [255, 0, 0] (red).thickness (
float) – Thickness of the line. Defaults to 10.lifetime (
float) – Number of simulation seconds the object should persist. If 0, makes persistent. Defaults to 1.
- draw_point(loc, color=None, thickness=10.0, lifetime=1.0)
Draws a debug point in the world
- Parameters:
loc (
listoffloat) – The[x, y, z]start of the box. (see Coordinate System)color (
listoffloat) –[r, g, b]color value (from 0 to 255). Defaults to [255, 0, 0] (red).thickness (
float) – Thickness of the point. Defaults to 10.lifetime (
float) – Number of simulation seconds the object should persist. If 0, makes persistent. Defaults to 1.
- enable_world_collisions(enable_collision)
Enable or disable world collisions.
- Parameters:
enable_collision (
boolean) – If world collisions should be enabled (All worlds are true by default)
- property fftwaves
Deprecated, use
env.ocean.wavesinstead. The FFT wave model,FFTWaveModel.
- get_joint_constraints(agent_name, joint_name)
- Returns the corresponding swing1, swing2 and twist limit values for the
specified agent and joint. Will return None if the joint does not exist for the agent.
- Returns:
np.ndarray
- get_reward_terminal()
Returns the reward and terminal state
- Returns:
A 2tuple:
Reward (
float): Reward returned by the environment.Terminal: The bool terminal signal returned by the environment.
- Return type:
(
float,bool)
- info()
Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have.
- Returns:
Information in a string format.
- Return type:
str
- static initialize_bst_graphs(**kwargs)
Initialize the bst heat maps for visualization and return BST visualizer instance. Make sure to call graph_instance.update_position(x, y, z) to update the graph periodically.
- Parameters:
biomass_func (
Callable()) – An optional, custom biomass function parameter that takes in a 3D array called “location” and outputs the biomass metric at that location.salinity_func (
Callable()) – An optional, custom salinity function parameter that takes in a 3D array called “location” and outputs the salinity metric at that location.temperature_func (
Callable()) – An optional, custom temperature function parameter that takes in a 3D array called “location” and outputs the temperature metric at that location.NOTE – when designing these custom functions, you must name the location parameter as “location”
agent (
string) – the name of the agent that you want to sample biomass, salinity, and temperature from (defaults to main agent)biomass_range (
tuple) – the scale range of biomass for the heatmap (defaults to (0, 3))salinity_range (
tuple) – the scale range of salinity for the heatmap (defaults to (32.8, 34))temperature_range (
tuple) – the scale range of temperature for the heatmap (defaults to (4, 25))
- property modems
Gets all instances of OpticalModemSensor in the environment.
- Returns:
List of all OpticalModemSensor in environment
- Return type:
(
listofOpticalModemSensor)
- property modems_id
Gets all ids of OpticalModemSensor in the environment.
- Returns:
List of all OpticalModemSensor ids in environment
- Return type:
(
listofint)
- move_viewport(location, rotation)
Teleport the camera to the given location
By the next tick, the camera’s location and rotation will be updated
- Parameters:
location (
listoffloat) – The[x, y, z]location to give the camera (see Coordinate System)rotation (
listoffloat) – The x-axis that the camera should look down. Other 2 axes are formed by a horizontal y-aixs, and then the corresponding z-axis. (see Rotations)
- reset()
Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state.
- Returns:
Returns the same as tick.
- Return type:
tupleordict
- send_acoustic_message(id_from, id_to, msg_type, msg_data)
Send a message from one beacon to another.
- Parameters:
id_from (
int) – The integer ID of the transmitting modem.id_to (
int) – The integer ID of the receiving modem.msg_type (
str) – The message type. Seeholoocean.sensors.AcousticBeaconSensorfor a list.msg_data – The message to be transmitted. Currently can be any python object.
- send_optical_message(id_from, id_to, msg_data)
Sends data between various instances of OpticalModemSensor
- Parameters:
id_from (
int) – The integer ID of the transmitting modem.id_to (
int) – The integer ID of the receiving modem.msg_data – The message to be transmitted. Currently can be any python object.
- send_world_command(name, num_params=None, string_params=None)
Send a world command.
A world command sends an abitrary command that may only exist in a specific world or package. It is given a name and any amount of string and number parameters that allow it to alter the state of the world.
If a command is sent that does not exist in the world, the environment will exit.
- Parameters:
name (
str) – The name of the command, ex “OpenDoor”(obj (string_params) – list of
int): List of arbitrary number parameters(obj – list of
string): List of arbitrary string parameters
- set_biomass_function(agent_name, new_fx)
Change the default biomass function to your own custom function :param agent_name: The name of the agent that you want to change biomass function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument “location” :type new_fx:callable
- set_control_scheme(agent_name, control_scheme)
Set the control scheme for a specific agent.
- Parameters:
agent_name (
str) – The name of the agent to set the control scheme for.control_scheme (
int) – A control scheme value (seeControlSchemes)
- set_fps(fps: int)
Sets the frames per second of the environment.
- Parameters:
fps (
int) – The desired frames per second. If set to 0, will max what it can do.
- set_ocean_currents(agent_name, velocity)
Send the ocean current velocity at the location of the vehicle to the server to be transformed into a force vector and applied to the vehicle. Note that if the following config parameter is set, three debugging lines will be graphed at the location of all vehicles that current is applied to. Of the debugging lines, blue will be the buoyancy force, green will be the gravity force, and red will be the ocean currents velocity applied to the center of mass of the vehicle.
- Parameters:
agent_name (
string) – The name of the vehicle you want the current to affect (ex: “auv0”)velocity (
list) – A 3 element vector [x, y, z] that represents the velocity of the current to be applied to the vehicle
- set_rain_parameters(vel_x, vel_y, vel_z, spawnRate)
Changes the rain’s velocity and spawn rate.
- Parameters:
vel_x (
float) – Rain velocity on the x axis.vel_y (
float) – VRain velocity on the y axis.vel_z (
float) – Rain velocity on the z axis. Should be a negative value.spawnRate (
float) – Rain’s spawn rate (number of particles).
- set_render_quality(render_quality, should_keep_fps=False)
Adjusts the rendering quality of HoloOcean.
- Parameters:
render_quality (
int,boolean) – An integer between 0 = Low Quality and 3 = Epic quality.second (The boolean is a)
rate. (optional parameter that determines whether or not to maintain the FPS limit at the previously defined)
true (If false the FPS max rate will be removed. Default behavior is to remove the FPS cap. If)
maintained. (the previous FPS limit will be)
- set_salinity_function(agent_name, new_fx)
Change the default salinity function to your own custom function :param agent_name: The name of the agent that you want to change salinity function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument “location” :type new_fx:callable
- set_sensor_rate(agent_name, sensor_name, hz)
Sets how often a sensor is sampled, in Hz.
This is the runtime equivalent of the
Hzkey in the scenario configuration, and is subject to the same limits: the rate must not exceedticks_per_sec, and is rounded down to a divisor of it.Sensors that are rate limited in the engine (see
_engine_rated_sensors) are changed on both sides.This will not persist after a call to reset().
- Parameters:
agent_name (
str) – Name of the agent the sensor is on.sensor_name (
str) – Name of the sensor to change.hz (
int) – The desired rate in Hz.
- set_show_vector_field_name(state)
Set whether to show the vector field name in the viewport. :param state: Whether to show the vector field name in the viewport. :type state:
bool
- set_temperature_function(agent_name, new_fx)
Change the default temperature function to your own custom function :param agent_name: The name of the agent that you want to change temperature function for :type agent_name:
string:param new_fx: The new function that takes in atleast the argument “location” :type new_fx:callable
- set_ticks_per_sec(ticks_per_sec)
Sets the ticks per second of the environment.
- Parameters:
ticks_per_sec (
int) – The desired ticks per second.
- should_render_viewport(render_viewport)
Controls whether the viewport is rendered or not
- Parameters:
render_viewport (
boolean) – If the viewport should be rendered
- spawn_prop(prop_type, location=None, rotation=None, scale=1, sim_physics=False, material='', tag='')
Spawns a basic prop object in the world like a box or sphere.
Prop will not persist after environment reset.
The spawned prop object will only show up on raycast and gpu sonars.
- Parameters:
prop_type (
string) – The type of prop to spawn. Can bebox,sphere,cylinder, orcone.location (
listoffloat) – The[x, y, z]location of the prop.rotation (
listoffloat) – The[roll, pitch, yaw]rotation of the prop.scale (
listoffloat) or (float) – The[x, y, z]scalars to the prop size, where the default size is 1 meter. If given a single float value, then every dimension will be scaled to that value.sim_physics (
boolean) – Whether the object is mobile and is affected by gravity.material (
string) – The type of material (texture) to apply to the prop. Can bewhite,gold,cobblestone,brick,wood,grass,steel, orblack. If left empty, the prop will have the a simple checkered gray material.tag (
string) – The tag to apply to the prop. Useful for task references.
- step(action, ticks=1, publish=True)
Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments.
- Parameters:
action (
np.ndarray) – An action for the main agent to carry out on the next tick.ticks (
int) – Number of times to step the environment with this action. If ticks > 1, this function returns the last state generated.publish (
bool) – Whether or not to publish as defined by scenario. Defaults to True.
- Returns:
A dictionary from agent name to its full state. The full state is another dictionary from
holoocean.sensors.Sensorsenum to np.ndarray, containing the sensors information for each sensor. The sensors always include the reward and terminal sensors. Reward and terminals can also be gotten throughget_reward_terminal().Will return the state from the last tick executed.
- Return type:
dict
- tick(num_ticks=1, publish=True, tick_clock=True)
Ticks the environment once. Normally used for multi-agent environments.
- Parameters:
num_ticks (
int) – Number of ticks to perform. Defaults to 1.publish (
bool) – Whether or not to publish as defined by scenario. Defaults to True.
- Returns:
A dictionary from agent name to its full state. The full state is another dictionary from
holoocean.sensors.Sensorsenum to np.ndarray, containing the sensors information for each sensor. The sensors always include the reward and terminal sensors. Reward and terminals can also be gotten throughget_reward_terminal().Will return the state from the last tick executed.
- Return type:
dict
- tide(adjustment, absolute=1, choice=None, instant=False)
Deprecated, use
env.ocean.tide.set_parameters()instead.Changes the water level or configures dynamic tide cycling.
- Parameters:
adjustment (
floatordictorlist) – Water level or offset in meters, or dictionary of tide configuration (static level, dynamic cycle and/ormax_rate).absolute (
intorbool) – 1 (True) to set absolute water level, 0 (False) to set offset from current level.choice (
intorbool) – Deprecated alias forabsolute, kept for backwards compatibility.instant (
bool) – If True, jump to the new level in one tick even if a tidemax_rateis set. This is a reset of the water: simulations that keep their own water state discard it and restart calm at the new level.
- property tide_cycle
Deprecated, use
env.ocean.tideinstead. The tide controller, under the name the pre-revamp tide system used.
- property tides
Deprecated, use
env.ocean.tideinstead. The tide controller,TideController.
- turn_off_flashlight(agent_tag, flashlight_name)
Turns off the vehicle’s flashlight.
- Parameters:
agent_tag (
str) – The tag of the agent to turn off the flashlight for. (e.g., auv0)flashlight_name (
str) – The name of the flashlight to turn off. Vehicles have 4 flashlights (flashlight1-flashlight4)
- turn_on_flashlight(agent_tag, flashlight_name, intensity=5000, beam_width=45, location_x_offset=0, location_y_offset=0, location_z_offset=0, angle_pitch=-30, angle_yaw=0, color_R=1, color_G=1, color_B=1)
Turns on the vehicle’s flashlight and sets its visual parameters.
- Parameters:
agent_tag (
str) – The tag of the agent to turn on the flashlight for. (e.g., auv0)flashlight_name (
str) – The name of the flashlight to turn on. (e.g., flashlight1)intensity (
float) – The brightness of the flashlight. Recommended range: 0 to 100000. (Default = 5000)beam_width (
float) – The beam’s spread angle in degrees. Recommended range: 1 to 80. (Default = 45)location_x_offset (
float) – x component of the flashlight location offset. (Default = 0)location_y_offset (
float) – y component of the flashlight location offset. (Default = 0)location_z_offset (
float) – z component of the flashlight location offset. (Default = 0)angle_pitch (
float) – The pitch angle (in degrees) for flashlight direction. Range: -70 to 70. (Default = -30)angle_yaw (
float) – The yaw angle (in degrees) for flashlight direction. Range: -70 to 70. (Default = 0)color_R (
float) – Red component of the flashlight color. Range: 0.0 to 1.0. (Default = 1)color_G (
float) – Green component of the flashlight color. Range: 0.0 to 1.0. (Default = 1)color_B (
float) – Blue component of the flashlight color. Range: 0.0 to 1.0. (Default = 1)
- water_color(red, green, blue)
Changes the color of the water.
- Parameters:
red (
float) – A number between 0 and 1 to set the intensity of the red value.green (
float) – A number between 0 and 1 to set the intensity of the green value.blue (
float) – A number between 0 and 1 to set the intensity of the blue value.
- water_fog(fogDensity, fogDepth=3.0, color_R=0.4, color_G=0.6, color_B=1.0)
Changes the water fog density, depth, and color. :param fogDensity: The density value for the fog. Range: 0.0 to 10.0. :type fogDensity:
float:param fogDepth: The distance at which the fog begins. Range: 0.0 to 10.0. (Default = 3) :type fogDepth:float:param color_R: The red component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.4) :type color_R:float:param color_G: The green component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.6) :type color_G:float:param color_B: The blue component of the fog’s color. Range: 0.0 to 1.0. (Default = 1.0)tt :type color_B:float
Ocean Control Methods
The ocean’s controllers are on env.ocean. See the ocean block for the
scenario’s ocean block.
- class holoocean.ocean.ocean_controller.OceanController(client)
Holds one controller per ocean phenomenon and routes the scenario’s
oceanblock to them. It doesn’t read the settings itself: each controller checks its own part of the block and maps its own deprecated top-level scenario keys."ocean": { "tide": {"height": 1.0}, "waves": {"fft": {"sea_state": 3}}, }
A phenomenon whose key is absent keeps the level’s default: the level’s water level and calm water.
- Parameters:
client – The HoloOcean client the controllers send commands through.
- tide
The water level.
- Type:
- waves
The waves.
- Type:
Methods:
load_config(scenario)Applies the scenario's
oceanblock, and the deprecated top-level keys that set the same phenomena.- load_config(scenario)
Applies the scenario’s
oceanblock, and the deprecated top-level keys that set the same phenomena.- Parameters:
scenario (
dict) – The whole scenario. Itsoceankey is optional.- Raises:
HoloOceanException – For an unknown key in
ocean, a phenomenon set both inoceanand with a deprecated top-level key, or an invalid setting.
- class holoocean.ocean.wave_controller.WaveController(client)
Picks the scenario’s wave model and passes wave settings to it.
The scenario’s waves are keyed by the model’s name, with that model’s settings as the value:
{"fft": {"sea_state": 3}}or{"calm": {}}. Exactly one model is chosen; no waves, or an empty dictionary, means calm water.Models:
calm: A flat surface at the water level. Takes no settings.fft: The FFT ocean,FFTWaveModel; see it for the settings.
The engine starts with calm water.
Each model has
commands, which checks settings and returns the commands that apply them, andreset. The controller spawns the FFT ocean itself when FFT waves are chosen.- Parameters:
client – The HoloOcean client to send commands through.
Attributes:
The FFT wave model,
FFTWaveModel.The name of the active wave model.
Methods:
load_config(config)Chooses the scenario's wave model and applies its settings.
set_parameters(parameters)Changes the active wave model's settings.
- property fft
The FFT wave model,
FFTWaveModel.
- load_config(config)
Chooses the scenario’s wave model and applies its settings.
- Parameters:
config (
dict) – The scenario’s waves: one model name with that model’s settings as the value. An empty dictionary means calm water.- Raises:
HoloOceanException – If
configdoesn’t name exactly one known model, or for an invalid setting of that model.
- property model
The name of the active wave model.
- set_parameters(parameters)
Changes the active wave model’s settings.
- Parameters:
parameters (
dict) – Settings of the active model.- Raises:
HoloOceanException – For a setting the active model doesn’t take, or an invalid value. Nothing is sent if any setting is invalid.
FFT Wave Model
The FFT wave model’s settings, which env.ocean.waves.set_parameters() passes on when the
scenario’s waves are FFT waves. See FFT Waves for usage and scenario
configuration.
- class holoocean.ocean.fft_wave_model.FFTWaveModel(client, is_active=None)
The FFT wave model: deep-water ocean waves generated a la Tessendorf.
WaveControllerspawns it when the scenario chooses FFT waves, and the waves are changed while the simulation runs withset_parameters(). Both take a dictionary of the settings below. Default ValuesOne value each:
sea_state: An integer from 0 to 9 that sets the wind speed from the WMO sea state code. Awind_speedgiven with it replaces its wind speed.wind_speed: Controls how large the waves are, good values are 0 - 30.wind_direction: Which direction the waves travel in, in degrees; 0 is the positive Y direction.wave_speed: Controls the speed of the waves, which also affects their height; default 9.8.foam_threshold: When the wave becomes foamy while moving, good values are -0.5 - 0.0.foam_blur: How fast the foam is blurred, good values are 0.1 - 2.0.foam_fade: How fast foam is removed, good values are 0.01 - 0.5.foam_injection: Foam density; leave at 1, or 0.8 - 1.0 for a less dense foam.repeat_period: Time in seconds for the simulation to make a full loop; default 1000.roughness_power: How smooth the waves look; default 0.5.num_roughness_samples: How fast the waves smoothen visually; default 128 (an integer).boat_buoyancy: 1 to move floatables that aren’t agents with the waves, 0 to not.wave_force: The sideways force waves impart on a vehicle; default 1.max_influence_depth: The depth below the surface, in meters, to which vehicles feel the waves; default 10.generate_new_mesh: 1 to write the vehicle’s mesh to a text file, so a new agent can be used with wave buoyancy.
One value per cascade (the waves are made from four FFT cascades). Give a list of four values, or one number to use for all four:
wind_directionality: How many waves travel against the wind: 1 is none, 0 is as many as with it.wind_tighten: How many waves travel perpendicular to the wind: 0 is more, increasing reduces them.long_wave_cutoff: Removes long waves, so each cascade covers different wavelengths.short_wave_cutoff: Damps short waves, so each cascade covers different wavelengths.choppiness: How much the wave crests overlap; most realistic at 0.7 - 1.5.amplitude: Displacement scaling factor.patch_length: Length of each cascade in meters.
Note
The older methods still work but are deprecated: the single-setting setters (
set_wind_speed()and so on) andfft_sea_state(),fft_wave_scalars()andfft_wave_cascades().- Parameters:
client – The HoloOcean client to send commands through.
is_active (callable) – Returns whether FFT waves are the active wave model, so
set_parameters()only sends while they are. None, the default, for a model used on its own, which is always active.
Methods:
fft_sea_state(state)Deprecated, use
set_parameters({"sea_state": ...})instead.fft_wave_cascades(wave_config)Deprecated, use
set_parameters()instead, with the settings' snake_case names ({"wind_tighten": [0, 0, 0, 0]}for{"WindTighten": [0, 0, 0, 0]}).fft_wave_scalars(wave_config)Deprecated, use
set_parameters()instead, with the settings' snake_case names ({"wind_speed": 4}for{"WindSpeed": 4}).set_boat_buoyancy(boat_buoyancy)Deprecated, use
set_parameters({"boat_buoyancy": ...})instead.set_foam_threshold(foam_threshold)Deprecated, use
set_parameters({"foam_threshold": ...})instead.set_generate_new_mesh(generate_new_mesh)Deprecated, use
set_parameters({"generate_new_mesh": ...})instead.set_gravity(gravity)Deprecated, use
set_parameters({"wave_speed": ...})instead.set_max_influence_depth(max_influence_depth)Deprecated, use
set_parameters({"max_influence_depth": ...})instead.set_parameters(parameters)Changes the FFT wave settings while FFT waves are the active wave model.
set_wave_force(wave_force)Deprecated, use
set_parameters({"wave_force": ...})instead.set_wind_direction(wind_direction)Deprecated, use
set_parameters({"wind_direction": ...})instead.set_wind_directionality(wind_directionality)Deprecated, use
set_parameters({"wind_directionality": ...})instead.set_wind_speed(wind_speed)Deprecated, use
set_parameters({"wind_speed": ...})instead.set_wind_tighten(wind_tighten)Deprecated, use
set_parameters({"wind_tighten": ...})instead.- fft_sea_state(state)
Deprecated, use
set_parameters({"sea_state": ...})instead.- Parameters:
state (
int) – 0-9 to set the sea state.
- fft_wave_cascades(wave_config)
Deprecated, use
set_parameters()instead, with the settings’ snake_case names ({"wind_tighten": [0, 0, 0, 0]}for{"WindTighten": [0, 0, 0, 0]}).- Parameters:
wave_config (
dict) – Engine parameter names (WindDirectionality,Choppinessand so on) and a list of four values each.
- fft_wave_scalars(wave_config)
Deprecated, use
set_parameters()instead, with the settings’ snake_case names ({"wind_speed": 4}for{"WindSpeed": 4}).- Parameters:
wave_config (
dict) – Engine parameter names (WindSpeed,WaveSpeed,FoamBlurand so on) and one value each.
- set_boat_buoyancy(boat_buoyancy)
Deprecated, use
set_parameters({"boat_buoyancy": ...})instead.
- set_foam_threshold(foam_threshold)
Deprecated, use
set_parameters({"foam_threshold": ...})instead.
- set_generate_new_mesh(generate_new_mesh)
Deprecated, use
set_parameters({"generate_new_mesh": ...})instead.
- set_gravity(gravity)
Deprecated, use
set_parameters({"wave_speed": ...})instead.
- set_max_influence_depth(max_influence_depth)
Deprecated, use
set_parameters({"max_influence_depth": ...})instead.
- set_parameters(parameters)
Changes the FFT wave settings while FFT waves are the active wave model. Settings left out keep their values.
- Parameters:
parameters (
dict) – Any of the settings listed in the class description.- Raises:
HoloOceanException – If FFT waves aren’t the active wave model, if
parametersisn’t a dictionary, or for an unknown setting or an invalid value. Nothing is sent if so.
- set_wave_force(wave_force)
Deprecated, use
set_parameters({"wave_force": ...})instead.
- set_wind_direction(wind_direction)
Deprecated, use
set_parameters({"wind_direction": ...})instead.
- set_wind_directionality(wind_directionality)
Deprecated, use
set_parameters({"wind_directionality": ...})instead.
- set_wind_speed(wind_speed)
Deprecated, use
set_parameters({"wind_speed": ...})instead.
- set_wind_tighten(wind_tighten)
Deprecated, use
set_parameters({"wind_tighten": ...})instead.
Tide Control Methods
For these methods you will call them using env.ocean.tide.”Command”. See Tide Controller for usage and scenario configuration.
- class holoocean.ocean.tide_controller.TideController(client)
Controls the water level in a HoloOcean world: a static level, a sinusoidal tide cycle, or both.
All tide measurements (height, amplitude) are in meters and the cycle period is in seconds of simulation time. The scenario’s
tideblock is applied withload_config(), and the tide is changed while the simulation runs withset_parameters(). Both take a dictionary of the settings below.height: The water level in meters. A tide cycle oscillates around it.absolute: True (the default) ifheightis the water level, False if it is a change in meters to add to the currentheight, such as 1.0 to raise the water a meter.active: Whether the tide cycle runs.amplitude: The tide cycle’s amplitude in meters.period_sec: The time for one full tide cycle, in seconds of simulation time. It stays fixed in seconds if the ticks per second change.max_rate: The fastest the water level may change, in meters per second, or None for no limit (changes are applied in one tick).
The controller keeps a target water level (
heightplus the cycle) and the level it last sent to the engine. Each tick it moves the sent level toward the target, by at mostmax_ratemeters per second if a maximum rate is set.Note
The older ways to set the tide still work but are deprecated:
set_tide(),set_tide_cycle()and the single-setting setters (set_amplitude(),set_period()and so on); assigningamplitude,activeormax_rate; readingbase_water_leveloroffset; a scenariotidegiven as a number or a list; and theperiod(in ticks),frequencyandtide_typesettings.Attributes:
Whether the tide cycle runs.
The tide cycle's amplitude in meters.
Deprecated, use
heightinstead.the water level the tide cycle oscillates around, with relative changes added.
The fastest the water level may change, in meters per second, or None for no limit.
Deprecated, use
heightinstead.height,active,amplitude,max_rate, andperiod_sec, orperiod(in ticks) if the period was set in ticks.The tide cycle period in ticks.
The tide cycle period in seconds of simulation time, or None if it was set in ticks and the ticks per second aren't known.
Methods:
Calculates the current cycle height in meters.
The water level the controller is moving toward, in meters.
The water level last sent to the engine, in meters.
load_config(config)Applies the scenario's tide.
set_active(active)Deprecated, use
set_parameters({"active": ...})instead.set_amplitude(amplitude)Deprecated, use
set_parameters({"amplitude": ...})instead.set_frequency(frequency)Deprecated, use
set_parameters({"period_sec": ...})instead.set_max_rate(max_rate)Deprecated, use
set_parameters({"max_rate": ...})instead.set_parameters(parameters[, instant])Changes the tide while the simulation runs.
set_period(period)Deprecated, use
set_parameters({"period_sec": ...})instead.set_period_sec(period_sec)Deprecated, use
set_parameters({"period_sec": ...})instead.set_tide(tide_val[, absolute, choice, instant])Deprecated, use
set_parameters()instead.set_tide_cycle(tide_cycle_val)Deprecated, use
set_parameters()instead.set_tide_type(tide_type)Deprecated.
- property active
Whether the tide cycle runs.
- property amplitude
The tide cycle’s amplitude in meters.
- get_cycle_height()
Calculates the current cycle height in meters.
- get_target_level()
The water level the controller is moving toward, in meters.
- get_water_level()
The water level last sent to the engine, in meters. Differs from
get_target_level()while a change is being limited bymax_rate.
- property height
the water level the tide cycle oscillates around, with relative changes added. This is the setting, not the water level right now, which moves toward it over time while a cycle runs or
max_ratelimits a change.- Type:
The height last set, in meters
- load_config(config)
Applies the scenario’s tide. The scenario’s tide is the starting water level, so it is applied at once, regardless of
max_rate.- Parameters:
config (
dict) – The scenario’socean.tideblock. Takes the settings listed in the class description.- Raises:
HoloOceanException – For an unknown setting or an invalid value.
- property max_rate
The fastest the water level may change, in meters per second, or None for no limit.
- property offset
Deprecated, use
heightinstead. How farheightis from the starting water level, in meters.
- property parameters
height,active,amplitude,max_rate, andperiod_sec, orperiod(in ticks) if the period was set in ticks. Passing it toset_parameters()restores these settings (with a deprecation warning if it holdsperiod).- Type:
The tide’s current settings, as a new dictionary
- property period
The tide cycle period in ticks. If the period was set in seconds, it is converted with the current ticks per second.
- property period_sec
The tide cycle period in seconds of simulation time, or None if it was set in ticks and the ticks per second aren’t known.
- set_active(active)
Deprecated, use
set_parameters({"active": ...})instead.
- set_amplitude(amplitude)
Deprecated, use
set_parameters({"amplitude": ...})instead.
- set_frequency(frequency)
Deprecated, use
set_parameters({"period_sec": ...})instead.
- set_max_rate(max_rate)
Deprecated, use
set_parameters({"max_rate": ...})instead.
- set_parameters(parameters, instant=False)
Changes the tide while the simulation runs. Settings left out keep their values.
- Parameters:
parameters (
dict) – Any of the settings listed in the class description.instant (
bool) – If True, jump to the new level in one tick regardless ofmax_rate. This is a reset of the water: simulations that keep their own water state discard it and restart calm at the new level.
- Raises:
HoloOceanException – If
parametersisn’t a dictionary, or for an unknown setting or an invalid value. Nothing changes if any setting is invalid.
- set_period(period)
Deprecated, use
set_parameters({"period_sec": ...})instead.
- set_period_sec(period_sec)
Deprecated, use
set_parameters({"period_sec": ...})instead.
- set_tide(tide_val, absolute=1, choice=None, instant=False)
Deprecated, use
set_parameters()instead.Sets or offsets the water level, or configures the tide cycle.
- Parameters:
tide_val – float (meters), list [height, absolute], or dict of settings.
absolute – 1 for absolute level (default), 0 for relative offset.
choice – Deprecated alias for
absolute.instant (
bool) – As inset_parameters().
- set_tide_cycle(tide_cycle_val)
Deprecated, use
set_parameters()instead.Configures the tide cycle without moving the water this tick; the next tick moves it.
- Parameters:
tide_cycle_val (
dict) – Tide cycle settings.
- set_tide_type(tide_type)
Deprecated. Only sinusoidal tides exist, so this does nothing.