<jupyter_start><jupyter_text>Using the random pose engineThe random pose engine will use input policies linked to a list of models to randomly place objects within a defined workspace.<jupyter_code>import os
import numpy as np

from pcg_gazebo.generators import WorldGenerator
from pcg_gazebo.visualization import plot_workspace

world_gen = WorldGenerator()
world_gen.add_asset(
    tag='box',
    description=dict(
        type='box',
        args=dict(
            size="5 * __import__('pcg_gazebo').random.rand(3)",
            name='cuboid',
            color='xkcd'
        )
    )
)
try:
    mesh_filename = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        '..',
        'examples',
        'meshes',
        'monkey.stl')
except:    
    mesh_filename = os.path.abspath('../examples/meshes/monkey.stl')
print('Mesh filename = ', mesh_filename, os.path.exists(mesh_filename))
world_gen.add_asset(
    tag='monkey',
    description=dict(
        type='mesh',
        args=dict(
            visual_mesh=mesh_filename,
            name='monkey',
            color='xkcd'
        )
    )
)
world_gen.add_constraint(
    name='tangent_to_ground_plane',
    type='tangent',
    frame='world',
    reference=dict(
        type='plane',
        args=dict(
            origin=[0, 0, 0],
            normal=[0, 0, 1]
        )
    )
)
world_gen.add_constraint(
    name='ws',
    type='workspace',
    frame='world',
    geometry_type='circle',        
    center=[0, 0, 0],
    radius=8,
    holes=[
        dict(
            type='circle',
            center=[0, 0, 0],
            radius=2
        )
    ]
)

print('List of constraints=', list(world_gen.constraints.tags))

plot_workspace(workspace=world_gen.constraints.get('ws'))
NUM_BOXES = 10
NUM_MONKEYS = 4

placement_policy = dict(
    models=['box', 'monkey'],
    config=[
        dict(
            dofs=['x', 'y'],            
            tag='workspace',
            workspace='ws'
        ),
        dict(
            dofs=['roll', 'pitch', 'yaw'],            
            tag='uniform',                            
            min=-3.141592653589793,
            max=3.141592653589793               
        )
    ]
)

world_gen.add_engine(
    tag='random_engine',
    engine_name='random_pose',
    models=['box', 'monkey'],
    max_num=dict(
        box=NUM_BOXES,
        monkey=NUM_MONKEYS),
    model_picker='random',
    no_collision=True,
    policies=[placement_policy],
    constraints=[
        dict(
            model='box',
            constraint='tangent_to_ground_plane'),
        dict(
            model='monkey',
            constraint='tangent_to_ground_plane')
    ]
)
world_gen.run_engines()
print(world_gen.world.models.keys())
world_gen.world.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13051272857655075, 'fraction_numerical': 0.01828612405880244, 'mean_word_length': 2.1313131313131315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '253182', 'license': 'ECL-2.0', 'n_tokens_mistral': 932, 'n_tokens_neox': 901, 'n_words': 148, 'path': 'examples/gen_random_pose_engine.ipynb', 'repo_name': 'argenos/pcg_gazebo', 'size': '2789'}