Procedural Generation

ASVSim supports procedural generation of port environments through a custom blueprint system in Unreal Engine 5. The procedural generation system allows users to create diverse and realistic port layouts at runtime using configurable parameters. Below are some examples of the procedural generation system.

PCG Image 1 PCG Image 2 PCG Image 3


To use PCG, you need to enable it in the .uproject file of your environment. This is done by adding the following lines to Plugins in the .uproject file:

"Plugins": [
{
    "Name": "PCG",
    "Enabled": true
},
{
    "Name": "PCGGeometryScriptInterop", 
    "Enabled": true
}
]

You also need to activate the procedural generation system by calling the activateGeneration() function before generating terrain. This function creates the necessary PCG components including a PCGVolume, PCGWorldActor, and generation manager. You can optionally specify whether to generate a new landscape (default is False if a landscape already exists):

The procedural generation can be controlled through the Python API using the generatePortTerrain() function. The parameters are as follows:

  • type (str): The terrain type to generate. Leave empty for default cube-based terrain, or specify a custom terrain type (port)
  • seed (int): Random seed value that determines the generated layout. Using the same seed will produce identical results
  • length (int): Number of terrain sections to generate. Higher values create longer port environments
  • mina (float): Minimum angle in degrees between consecutive terrain segments. Controls how sharply the port can turn left/right
  • maxa (float): Maximum angle in degrees between consecutive terrain segments. Limits the maximum turning angle
  • mind (float): Minimum distance in centimeters between terrain points. Controls the minimum spacing between segments
  • maxd (float): Maximum distance in centimeters between terrain points. Controls the maximum spacing between segments
generatePortTerrain(
    port_name="port",
    seed=12345,
    length=10,
    mina=-45.0,
    maxa=45.0,
    mind=3000.0,
    maxd=6000.0,
)

When generating a port environment, automatically a goal location is also generated. This goal location can be used to train a vessel to navigate to a specific location and can be retrieved using the getGoal() function.

getGoal()

Retrieves the goal location and border points for navigation, relative to a starting position. This function is useful for setting up navigation tasks and training scenarios. - initial_location (Vector2r): The absolute starting position of the vessel in meters (x,y) - distance (int): Defines in which section of the generated port the goal is located

The function returns a list of x,y coordinates containing: - goal_location (Vector2r): The relative goal location in meters - border_points (List[Vector2r]): List of border points defining the valid navigation area

getGoal(
    initial_location=Vector2r(x=0.0, y=0.0),
    distance=5
)

getLocation()

Retrieves the absolute and relative location of the agent in meters. This function is useful for getting the current position of the vessel and its relative position to the starting location. - initial_location (Vector2r): The absolute starting position of the vessel in meters (x,y)

The function returns a list of x,y coordinates containing: - absolute_location (Vector2r): The absolute location of the vessel in meters - relative_location (Vector2r): The relative location of the vessel to the starting location in meters

getLocation(
    initial_location=Vector2r(x=0.0, y=0.0)
)