Commands

This module contains the classes used for formatting and sending commands to the HoloOcean backend. Most of these commands are just used internally by HoloOcean, regular users do not need to worry about these.

Classes:

AddSensorCommand(sensor_definition)

Add a sensor to an agent

AirFogCommand(fogDensity[, fogDepth, ...])

Changes the air fog density, depth, and color.

ChangeTimeOfDayCommand(TimeOfDay)

Changes the world's time of day.

ChangeWeatherCommand(weather)

Changes the weather in the world.

Command()

Base class for Command objects.

CommandCenter(client)

Manages pending commands to send to the client (the engine).

CommandsGroup()

Represents a list of commands

CustomCommand(name[, num_params, string_params])

Send a custom command to the currently loaded world.

DebugDrawCommand(draw_type, start, end, ...)

Draw debug geometry in the world.

RGBCameraRateCommand(agent_name, ...)

Set the number of ticks between captures of the RGB camera.

RemoveSensorCommand(agent, sensor)

Remove a sensor from an agent

RenderQualityCommand(render_quality)

Adjust the rendering quality of HoloOcean

RenderViewportCommand(render_viewport)

Enable or disable the viewport.

RotateSensorCommand(agent, sensor, rotation)

Rotate a sensor on the agent.

SendAcousticMessageCommand(from_agent_name, ...)

Set the number of ticks between captures of the RGB camera.

SendOpticalMessageCommand(from_agent_name, ...)

Send information through OpticalModem.

SetFPSCommand(fps)

Set the frames per second of the simulation.

SetRainParametersCommand(vel_x, vel_y, ...)

Changes the rain's velocity and spawn rate.

SetTPSCommand(tps)

Set the ticks per second of the simulation.

SpawnAgentCommand(location, rotation, name, ...)

Spawn an agent in the world.

TeleportCameraCommand(location, rotation)

Move the viewport camera (agent follower)

TideCommand(adjustment, absolute)

Changes the water level in the current world.

TurnOffFlashlightCommand(flashlight_name)

Turns off the vehicle's flashlight.

TurnOnFlashlightCommand(flashlight_name[, ...])

Turns on the vehicle's flashlight and sets its visual parameters.

WaterColorCommand(red, green, blue)

Changes the water color in the current world.

WaterFogCommand(fogDensity[, fogDepth, ...])

Changes the water fog density, depth, and color.

class holoocean.command.AddSensorCommand(sensor_definition)

Add a sensor to an agent

Parameters:

sensor_definition (SensorDefinition) – Sensor to add

class holoocean.command.AirFogCommand(fogDensity, fogDepth=3.0, color_R=0.45, color_G=0.5, color_B=0.6)

Changes the air fog density, depth, and color.

Parameters:
  • fogDensity (float) – The density value for the fog. Range: 0.0 to 10.0.

  • fogDepth (float) – The distance at which the fog begins. Range: 0.0 to 10.0. (Default = 3).

  • color_R (float) – The red component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.45).

  • color_G (float) – The green component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.5).

  • color_B (float) – The blue component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.6).

class holoocean.command.ChangeTimeOfDayCommand(TimeOfDay)

Changes the world’s time of day.

Parameters:

TimeOfDay (float) – time of day desired, a number between 0 and 23 inclusive.

class holoocean.command.ChangeWeatherCommand(weather)

Changes the weather in the world.

Parameters:

weather (int) – The weather wanted (0 - sunny, 1 - cloudy, 2 - rainy).

class holoocean.command.Command

Base class for Command objects.

Commands are used for IPC between the holoocean python bindings and holoocean binaries.

Derived classes must set the _command_type.

The order in which add_number_parameters() and add_number_parameters() are called is significant, they are added to an ordered list. Ensure that you are adding parameters in the order the client expects them.

Methods:

add_number_parameters(number)

Add given number parameters to the internal list.

add_string_parameters(string)

Add given string parameters to the internal list.

set_command_type(command_type)

Set the type of the command.

to_json()

Converts to json.

add_number_parameters(number)

Add given number parameters to the internal list.

Parameters:

number (list of int/float, or singular int/float) – A number or list of numbers to add to the parameters.

add_string_parameters(string)

Add given string parameters to the internal list.

Parameters:

string (list of str or str) – A string or list of strings to add to the parameters.

set_command_type(command_type)

Set the type of the command.

Parameters:

command_type (str) – This is the name of the command that it will be set to.

to_json()

Converts to json.

Returns:

This object as a json string.

Return type:

str

class holoocean.command.CommandCenter(client)

Manages pending commands to send to the client (the engine).

Parameters:

client (HoloOceanClient) – Client to send commands to

Methods:

clear()

Clears pending commands

enqueue_command(command_to_send)

Adds command to outgoing queue.

handle_buffer()

Writes the list of commands into the command buffer, if needed.

Attributes:

queue_size

Returns: int: Size of commands queue

clear()

Clears pending commands

enqueue_command(command_to_send)

Adds command to outgoing queue.

Parameters:

command_to_send (Command) – Command to add to queue

handle_buffer()

Writes the list of commands into the command buffer, if needed.

Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list

property queue_size

Returns: int: Size of commands queue

class holoocean.command.CommandsGroup

Represents a list of commands

Can convert list of commands to json.

Methods:

add_command(command)

Adds a command to the list

clear()

Clear the list of commands.

to_json()

returns:

Json for commands array object and all of the commands inside the array.

Attributes:

size

Returns: int: Size of commands group

add_command(command)

Adds a command to the list

Parameters:

command (Command) – A command to add.

clear()

Clear the list of commands.

property size

Returns: int: Size of commands group

to_json()
Returns:

Json for commands array object and all of the commands inside the array.

Return type:

str

class holoocean.command.CustomCommand(name, num_params=None, string_params=None)

Send a custom command to the currently loaded world.

Parameters:
  • name (str) – The name of the command, ex “OpenDoor”

  • (obj (string_params) – list of int): List of arbitrary number parameters

  • (objlist of int): List of arbitrary string parameters

class holoocean.command.DebugDrawCommand(draw_type, start, end, color, thickness, lifetime)

Draw debug geometry in the world.

Parameters:
  • draw_type (int) –

    The type of object to draw

    • 0: line

    • 1: arrow

    • 2: box

    • 3: point

  • start (list of float) – The start [x, y, z] location in meters of the object. (see Coordinate System)

  • end (list of float) – The end [x, y, z] location in meters of the object (not used for point, and extent for box)

  • color (list of float) – [r, g, b] color value (from 0 to 255).

  • thickness (float) – thickness of the line/object

  • lifetime (float) – Number of simulation seconds the object should persist. If 0, makes persistent

class holoocean.command.RGBCameraRateCommand(agent_name, sensor_name, ticks_per_capture)

Set the number of ticks between captures of the RGB camera.

Parameters:
  • agent_name (str) – name of the agent to modify

  • sensor_name (str) – name of the sensor to modify

  • ticks_per_capture (int) – number of ticks between captures

class holoocean.command.RemoveSensorCommand(agent, sensor)

Remove a sensor from an agent

Parameters:
  • agent (str) – Name of agent to modify

  • sensor (str) – Name of the sensor to remove

class holoocean.command.RenderQualityCommand(render_quality)

Adjust the rendering quality of HoloOcean

Parameters:

render_quality (int) – 0 = low, 1 = medium, 3 = high, 3 = epic

class holoocean.command.RenderViewportCommand(render_viewport)

Enable or disable the viewport. Note that this does not prevent the viewport from being shown, it just prevents it from being updated.

Parameters:

render_viewport (bool) – If viewport should be rendered

class holoocean.command.RotateSensorCommand(agent, sensor, rotation)

Rotate a sensor on the agent. Multiple rotations do not accumulate, but rather sets to the last rotation.

Parameters:
  • agent (str) – Name of agent

  • sensor (str) – Name of the sensor to rotate

  • rotation (list of float) – [roll, pitch, yaw] rotation for sensor.

class holoocean.command.SendAcousticMessageCommand(from_agent_name, from_sensor_name, to_agent_name, to_sensor_name)

Set the number of ticks between captures of the RGB camera.

Parameters:
  • agent_name (str) – name of the agent to modify

  • sensor_name (str) – name of the sensor to modify

  • num (int) – number of ticks between captures

class holoocean.command.SendOpticalMessageCommand(from_agent_name, from_sensor_name, to_agent_name, to_sensor_name)

Send information through OpticalModem.

class holoocean.command.SetFPSCommand(fps)

Set the frames per second of the simulation.

Parameters:

fps (int) – The number of frames per second to set the simulation to.

class holoocean.command.SetRainParametersCommand(vel_x, vel_y, vel_z, spawnRate)

Changes the rain’s velocity and spawn rate. You must first activate weather and set it to 2 - rainy using the Change Weather Command before this will have any visible effect.

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).

class holoocean.command.SetTPSCommand(tps)

Set the ticks per second of the simulation.

Parameters:

tps (int) – The number of ticks per second to set the simulation to.

class holoocean.command.SpawnAgentCommand(location, rotation, name, agent_type, is_main_agent=False)

Spawn an agent in the world.

Parameters:
  • location (list of float) – [x, y, z] location to spawn agent (see Coordinate System)

  • name (str) – The name of the agent.

  • agent_type (str or type) – The type of agent to spawn (UAVAgent, NavAgent, …)

Methods:

set_location(location)

Set where agent will be spawned.

set_name(name)

Set agents name

set_rotation(rotation)

Set where agent will be spawned.

set_type(agent_type)

Set the type of agent.

set_location(location)

Set where agent will be spawned.

Parameters:

location (list of float) – [x, y, z] location to spawn agent (see Coordinate System)

set_name(name)

Set agents name

Parameters:

name (str) – The name to set the agent to.

set_rotation(rotation)

Set where agent will be spawned.

Parameters:

rotation (list of float) – [roll, pitch, yaw] rotation for agent. (see Rotations)

set_type(agent_type)

Set the type of agent.

Parameters:

agent_type (str or type) – The type of agent to spawn.

class holoocean.command.TeleportCameraCommand(location, rotation)

Move the viewport camera (agent follower)

Parameters:
  • location (list of float) – The [x, y, z] location to give the camera (see Coordinate System)

  • rotation (list of float) – The [roll, pitch, yaw] rotation to give the camera (see Rotations)

class holoocean.command.TideCommand(adjustment, absolute)

Changes the water level in the current world.

Parameters:
  • adjustment (float) – The amount in meters you want to adjust the water level by or the level you want to set the water at.

  • absolute (bool) – True if you want to set a new surface level and False if you want to adjust the tides by an offset.

class holoocean.command.TurnOffFlashlightCommand(flashlight_name)

Turns off the vehicle’s flashlight.

Parameters:

flashlight_name (str) – The name of the flashlight to turn off. Vehicles have 4 flashlights (flashlight1-flashlight4)

class holoocean.command.TurnOnFlashlightCommand(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:
  • 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)

class holoocean.command.WaterColorCommand(red, green, blue)

Changes the water color in the current world.

Parameters:
  • red (float) – The red intensity value of the new water, between 0 and 1.

  • green (float) – The green intensity value of the new water, between 0 and 1.

  • blue (float) – The blue intensity value of the new water, between 0 and 1.

class holoocean.command.WaterFogCommand(fogDensity, fogDepth=3.0, color_R=0.4, color_G=0.6, color_B=1.0)

Changes the water fog density, depth, and color.

Parameters:
  • fogDensity (float) – The density value for the fog. Range: 0.0 to 10.0.

  • fogDepth (float) – The distance at which the fog begins. Range: 0.0 to 10.0. (Default = 3).

  • color_R (float) – The red component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.4).

  • color_G (float) – The green component of the fog’s color. Range: 0.0 to 1.0. (Default = 0.6).

  • color_B (float) – The blue component of the fog’s color. Range: 0.0 to 1.0. (Default = 1.0).