pcg_gazebo.generators
pcg_gazebo.generators¶
The tools in this modules allow the generation of models and worlds using policy rules for object placement and constraints.
AssetsManager¶
AssetsManager(self)
pcg_gazebo.simulation.SimulationModel: Description for a modelpcg_gazebo.simulation.Light: Description for light sourcespcg_gazebo.simulation.ModelGroup: Group of models and light sourcespcg_gazebo.generators.ModelGroupGenerator: Dynamic model group generatordict: Input configuration of thecreatorsfactory methods forbox,sphere,cylinderandmeshmodels, for an instance ofpcg_gazebo.simulation.Light, or an instance ofpcg_gazebo.generators.ModelGroupGeneratorstr: Name of an existing Gazebo model that can be found in the Gazebo resources path
ground_planes¶
list: List of strings with tags of ground plane models
tags¶
list: List of strings with all asset tags
get_instance¶
AssetsManager.get_instance()
AssetsMananger
is_model¶
AssetsManager.is_model(tag)
tag is an instance of
pcg_gazebo.simulation.SimulationModel.
Input arguments
tag(type:str): Tag of the asset.
is_light¶
AssetsManager.is_light(tag)
tag is an instance of
pcg_gazebo.simulation.Light.
Input arguments
tag(type:str): Tag of the asset.
is_model_group¶
AssetsManager.is_model_group(tag)
tag is an instance of
pcg_gazebo.simulation.ModelGroup.
Input arguments
tag(type:str): Tag of the asset.
is_gazebo_model¶
AssetsManager.is_gazebo_model(tag)
tag is a Gazebo model
found in Gazebo's resources path.
Input arguments
tag(type:str): Tag of the asset.
is_model_group_generator¶
AssetsManager.is_model_group_generator(tag)
tag is an instance of
pcg_gazebo.generators.ModelGroupGenerator.
Input arguments
tag(type:str): Tag of the asset.
is_ground_plane¶
AssetsManager.is_ground_plane(tag)
tag is flagged as a ground
plane model.
Input arguments
tag(type:str): Tag of the asset.
is_factory_input¶
AssetsManager.is_factory_input(tag)
tag is a dict containing
the inputs for a pcg_gazebo.generators.creators factory method
to create a box, sphere, cylinder or mesh model.
Input arguments
tag(type:str): Tag of the asset.
add¶
AssetsManager.add(description,
tag=None,
type=None,
parameters=None,
include_dir=None,
overwrite=True)
Input arguments
description(type:str,dict,pcg_gazebo.simulation.SimulationModel,pcg_gazebo.simulation.Light,pcg_gazebo.simulation.ModelGrouporpcg_gazebo.generators.ModelGroupGenerator): Model description.tag(type:str, default:None): Asset's tag. IfNoneis provided, the inputdescriptionmust have an attributenamewhich will be used as a tag, otherwise the function returnsFalse.type(type:str, default:None): When the provided description isdict, the type of asset that must be generated with thedictinput must be then provided as eitherfactory,model_generatororlight.
Returns
True, if asset could be added to the collection.
get¶
AssetsManager.get(tag, *args, **kwargs)
tag.
Input arguments
tag(type:str): Tag of the asset. In casetagis referencing apcg_gazebo.generators.ModelGroupGenerator, additional inputs to run the engines can be provided using*argsand**kwargs.
Returns
pcg_gazebo.simulation.SimulationModel or
pcg_gazebo.simulation.ModelGroup. None, if tag is invalid.
set_asset_as_ground_plane¶
AssetsManager.set_asset_as_ground_plane(tag)
Input arguments
tag(type:str): Name of the model asset
from_dict¶
AssetsManager.from_dict(config)
dict. The dictionary should have a list of
asset descriptions under the tag assets and, if necessary, a list of
strings referring to models that must be flagged as ground plane under
the tag ground_plane.
Input arguments
config(type:data_type, default:data): Parameter description
Returns
Description of return values
from_yaml¶
AssetsManager.from_yaml(filename)
Input arguments
filename(type:str): YAML filename.
has_element¶
AssetsManager.has_element(tag)
True if an element for tag exists.
Input arguments
tag(type:str): Tag of the element.
CollisionChecker¶
CollisionChecker(self, ignore_ground_plane=True)
Input arguments
ignore_ground_plane(type:bool, value:True): Ignores the meshes flagged as ground plane when performing collision checks.
scene¶
trimesh.scene.Scene: Collision check scenario
reset_scenario¶
CollisionChecker.reset_scenario()
reset_to_fixed_model_scenario¶
CollisionChecker.reset_to_fixed_model_scenario()
add_fixed_model¶
CollisionChecker.add_fixed_model(model)
Input arguments
model(type:pcg_gazebo.simulation.SimulationModel): Simulation model structure
add_model¶
CollisionChecker.add_model(model)
Input arguments
model(type:pcg_gazebo.simulation.SimulationModel): Simulation model structure
show¶
CollisionChecker.show()
pyglet.
check_collision_with_current_scene¶
CollisionChecker.check_collision_with_current_scene(
model, min_distance=0.0)
model and
the meshes in the scene.
Input arguments
model(type:pcg_gazebo.simulation.SimulationModel): Simulation model structure
Returns
True, if any collision is detected. False, otherwise.
check_for_collisions¶
CollisionChecker.check_for_collisions()
Returns
True, if any collision is detected. False, otherwise.
ConstraintsManager¶
ConstraintsManager(self)
add¶
ConstraintsManager.add(name, type=None, constraint_obj=None, **kwargs)
Input arguments
name(type:str): ID name for the constraint class instancetype(type:str): Name of the constraints class to be createdkwargs(type:dict): Input arguments for the constraint class to be created
EngineManager¶
EngineManager(self)
add¶
EngineManager.add(tag,
engine_name=None,
models=None,
engine_obj=None,
**kwargs)
Input arguments
engine_name(type:str): Name of the engine class to be createdmodels(type: list ofstr): Name of the models that will be assets to the created enginekwargs(type:dict): Input arguments to the created engine.
from_yaml¶
EngineManager.from_yaml(filename)
Input arguments
filename(type:str): YAML filename.
ModelGroupGenerator¶
ModelGroupGenerator(self, name='generator', **kwargs)
SingletonCollisionChecker¶
SingletonCollisionChecker(self, ignore_ground_plane=True)
Attributes
INSTANCE(type:SingletonCollisionChecker, value:None): Instance of the singleton collision checker that is initialized by the first call ofget_instance().
Input arguments
ignore_ground_plane(type:bool, value:True): Ignores the meshes flagged as ground plane when performing collision checks.
get_instance¶
SingletonCollisionChecker.get_instance(**kwargs)
Input arguments
kwargs(type:dict): Input arguments for theSingletonCollisionCheckerinstance.
Returns
A SingletonCollisionChecker instance
WorldGenerator¶
WorldGenerator(self,
name='default',
gazebo_proxy=None,
output_world_dir=None,
output_model_dir='/tmp/gazebo_models',
**kwargs)
Input arguments
gazebo_proxy(type:pcg_gazebo.task_manager.GazeboProxy, default:None): AGazeboProxyobject to enable spawning of models and configuration of the simulation in runtime.
gazebo_proxy¶
pcg_gazebo.task_manager.GazeboProxy: Internal instance
of the GazeboProxy
world¶
pcg_gazebo.simulation.World: World abstraction
instance
init_gazebo_proxy¶
WorldGenerator.init_gazebo_proxy(ros_host='localhost',
ros_port=11311,
gazebo_host='localhost',
gazebo_port=11345,
timeout=30,
ignore_services=None)
GazeboProxy instance to interface with a running
instance of Gazebo. If a GazeboProxy already exists, it will be
deleted before a new one is created.
Input arguments
ros_host(type:str, default:localhost): Address of the ROS host machine runningroscore.ros_port(type:int, default:11311): Port number forroscoregazebo_host(type:str, default:localhost): Address of the Gazebo servergazebo_port(type:int, default:11345): Port number of the Gazebo server
delete_model¶
WorldGenerator.delete_model(model_name)
Input arguments
model_name(type:str): Name of the model
Returns
True if the model could be deleted from the simulation.
from_dict¶
WorldGenerator.from_dict(config)
dict with all
information on the list of model assets, engines,
constraints and lights and instantiate the
necessary objects.
An example of a YAML file that can hold this kind of information can be seen below:
name: world_name
assets:
- model_1 # This list holds only Gazebo models
- model_2
- model_3
ground_plane: # Optional input
- model_1 # If model_1 is part of the ground_plane,
# it should be flagged for collision checking
constraints:
- name: kitchen # Name identifier
type: workspace # Name of the constraint class
frame: world
geometry:
type: area
description:
points:
- [-6.54833, -4.17127, 0]
- [-3.24447, -4.17127, 0]
- [-3.24447, 0.12423, 0]
- [-6.54833, 0.12423, 0]
- name: tangent_to_ground_plane # Name identifier
type: tangent # Name of the constraint class
frame: world
reference:
type: plane
args:
origin: [0, 0, 0]
normal: [0, 0, 1]
engines:
- engine_name: fixed_pose
models:
- sll_room_empty
poses:
- [0, 0, 0, 0, 0, 0]
- engine_name: random_pose
models:
- sll_table_group_futura_seat
- sll_table_group_futura
model_picker: size
max_area: 0.9
no_collision: false
max_num:
sll_table_group_futura_seat: 6
sll_table_group_futura: 1
policies:
- models:
- sll_table_group_futura_seat
- sll_table_group_futura
config:
- dofs:
- x
- y
policy:
name: workspace
args: dining_room
- dofs:
- z
- roll
- pitch
policy:
name: value
args: 0
- dofs:
- yaw
policy:
name: uniform
args:
mean: 0
min: -3.141592653589793
max: 3.141592653589793
constraints:
- model: sll_table_group_futura
constraint: tangent_to_ground_plane
- model: sll_table_group_futura_seat
constraint: tangent_to_ground_plane
lights:
- name: sun # Name of the Gazebo model with the light data
Input arguments
config(type:dict): Configuration settings for the world generator
Returns
Description of return values
spawn_model¶
WorldGenerator.spawn_model(model,
robot_namespace,
pos=[0, 0, 0],
rot=[0, 0, 0],
reference_frame='world',
timeout=30,
replace=False)
pcg_gazebo.simulation.SimulationModel in
a running instance of Gazebo. A GazeboProxy is required
for this method to finish successfully.
Input arguments
model(type:pcg_gazebo.simulation.SimulationModel): Simulation model to be spawnedrobot_namespace(type:str): Name under which the robot should be spawned in Gazebopos(type:list, default:[0, 0, 0]): Spawning position wrt reference framerot(type:list, default:[0, 0, 0]): Roll-Pitch-Yaw angles in radians or a (w, i, j, k) quaternion vector.reference_frame(type:str, default:world): Reference frame for the spawning posetimeout(type:float): Timeout in seconds to wait for Gazebo to startreplace(type:bool, default:False): Replace the model in the simulation in case a model with the same name already exists.
Returns
True if the model could be spawned.
get_physics_engine¶
WorldGenerator.get_physics_engine(engine='ode')
pcg_gazebo.simulation.physics.Physics object.
Input arguments
engine(type:str): ID name of the physics engine, options areode,bulletandsimbody.
Returns
An pcg_gazebo.simulation.physics.Physics object.
reset_world¶
WorldGenerator.reset_world(name, engine='ode', gravity=[0, 0, -9.8])
Input arguments
name(type:str): Name of the worldengine(type:str, default:ode): Name of the physics engine to be used. Options areode,bulletorsimbody.gravity(type:list, default:[0, 0, -9.8]): Gravitational acceleration vector
export_world¶
WorldGenerator.export_world(output_dir=None,
filename=None,
with_default_ground_plane=True,
with_default_sun=True,
models_output_dir=None,
overwrite=True,
sdf_version='1.6')
Input arguments
output_dir(type:str, default:None): Path to output directory to store the world file.filename(type:str, default:None): Name of the SDF world filewith_default_ground_plane(type:bool, default:True): Add the default ground plane model to the world before exporting itwith_default_sun(type:bool, default:True): Add the default sun model to the world before exporting it
Returns
Full name of the exported SDF world file as a str
plot_results¶
WorldGenerator.plot_results(fig=None,
fig_width=1000,
fig_height=800,
footprint_geometry='collision',
engine='bokeh')
Input arguments
fig(type: abokehor amatplotlibfigure, default:None): A figure object. IffigisNone, a new figure will be createdfig_width(type:int, default:1000): Width of the figureparam(type:data_type, default:data): Parameter description
Returns
Description of return values