pcg_gazebo.generators.engines

pcg_gazebo.generators.engines

Pose generator engine definitions that compute the pose of the models according to pre-defined rules.

create_engine

create_engine(tag, **kwargs)
Engine factory that returns the engine according to its LABEL definition. It returns None if the engine name is invalid.

Input parameters

  • tag (type: str): Name of the engine class
  • kwargs: Inputs for the engine class constructor

Engine

Engine(self,
       assets_manager=None,
       constraints_manager=None,
       models=None,
       constraints=None,
       collision_checker=None,
       model_picker=None,
       as_model_group=False,
       **kwargs)
Base class for model factory engines. The engines are responsible of computing poses for models in the world and performing collision checks within the scenario before the final world is generated. This class includes methods common to all derived engine classes.

label

str: Engine name identifier

models

List of str: List of model name tags regarding the engine's model assets

poses

dict: List of fixed poses associated with model names.

add_local_constraint

Engine.add_local_constraint(model_name, constraint_name)
Add an association of a constraint definitions with an specific model tag to be taken into account when running the placement engine.

Input arguments

  • model_name (type: str): Name of the model
  • constraint_name (type: str): Name of the constraint definition
get_local_constraints_for_model

Engine.get_local_constraints_for_model(model_name)
Return the name of the local constraint definitions for a model.

Input arguments

  • model_name (type: str): Name of the model

Returns

List of str: List of constraint definition names associated with the model. If the model has no constraints, am empty list is returned.

apply_local_constraints

Engine.apply_local_constraints(model)
Apply spatial constraints to model. This will modify the pose of the model if it violates the constraint.

Input arguments

  • model (type: pcg_gazebo.simulation.SimulationModel): Model instance

Returns

pcg_gazebo.simulation.SimulationModel: Model with modified pose.

add_model

Engine.add_model(model)
Add a model name to the list of model assets for this engine.

Input arguments

  • model (type: str): Name of the model
set_fixed_pose_model

Engine.set_fixed_pose_model(model)
Set a model as a fixed model in the world to populate the collision checker.

Input arguments

  • model (type: simulation.SimulationModel or simulation.ModelGroup): Simulation asset.

Returns

True, if model could be added to list of fixed models.

run

Engine.run()
This function should be implemented by the derived classes.

FixedPoseEngine

FixedPoseEngine(self,
                assets_manager,
                constraints_manager=None,
                models=None,
                poses=None,
                constraints=None,
                collision_checker=None)
Engine that just places models on pre-configured fixed poses. This engine only accepts one model asset.

  • callback_fcn_get_constraint (type: callable, default: None): Handle to a function or a lambda function that returns a pcg_gazebo.constraints.Constraint associated with a tag name.
  • models (type: list, default: None): List of models names as str relative to the models that the engine will have as assets.
  • constraints (type: list, default: None): List of local constraint configurations that will be applied on to the engine's model assets.
  • poses (type: list): List of 6- (position and Euler angles) or 7 element (position and quaternion) poses.
add_pose

FixedPoseEngine.add_pose(pose)
Add pose to the list of fixed-poses.

Input arguments

  • pose (type: list): 6- (position and Euler angles) or 7 element (position and quaternion) poses.
run

FixedPoseEngine.run()
Generate instances of the model asset for all the poses provided. If any local constraints were also provided, they will be applied to the model after its placement.

Returns

List of pcg_gazebo.simulation.SimulationModel: Model instances.

PatternEngine

PatternEngine(self,
              assets_manager,
              constraints_manager=None,
              models=None,
              constraints=None,
              pose=[0, 0, 0, 0, 0, 0],
              pattern=None,
              collision_checker=None,
              **kwargs)

RandomPoseEngine

RandomPoseEngine(self,
                 assets_manager=None,
                 constraints_manager=None,
                 is_ground_plane=False,
                 models=None,
                 max_num=None,
                 no_collision=True,
                 max_area=1,
                 constraints=None,
                 policies=None,
                 model_picker='random',
                 collision_checker=None,
                 min_distance=0.0)
Placement engine that generates a random pose for its model assets respecting input local constraints, if any is provided, such as workspace constraint. This engine performs also a collision check with all models already placed in the scene (except for models flagged as ground plane) to ensure no models are overlapping each other.

Input arguments

  • assets_manager (type: pcg_gazebo.generators.AssetsManager)
  • callback_fcn_get_constraint (type: callable, default: None): Handle to a function or a lambda function that returns a pcg_gazebo.constraints.Constraint associated with a tag name.
  • models (type: list, default: None): List of models names as str relative to the models that the engine will have as assets.
  • constraints (type: list, default: None): List of local constraint configurations that will be applied on to the engine's model assets.
  • max_num (type: dict, default: None): Maximum number of instances of the model assets, the key being the model asset's name, and the value the maximum number.
  • no_collision (type: bool, default: True): If True, the model instances are only added to the world if there are no collisions with the already existing models (except for models flagged as ground plane).
  • max_area (type: float, default: 1): Percentage of the allowed area to fill with the models.
  • model_picker (type: str, default: random): Strategy for picking a model from the list of assets for the next placement in the world. Options are random (selecting a random model from the list of assets) or area (selecting the models for the biggest to the smallest).
  • policies (type: dict, default: None): The rules for model generation associated with each degree of freedom.
policies:
    - models:
     - model_1
     - model_2
     - model_3
     config:
     - dofs:
       - x
       - y
       policy:
         name: workspace
         args: area_1     # For more information on
                          # workspaces, check the
                          # class definition for
                          # `pcg_gazebo.constraints.WorkspaceConstraint`
     - dofs:
       - z
       - roll
       - pitch
       policy:
         name: value
         args: 0
     - dofs:
       - yaw
       policy:
         name: uniform
         args:
            min: -3.141592653589793
            max: 3.141592653589793
reset_counter

RandomPoseEngine.reset_counter()
Reset all model counters.

increase_counter

RandomPoseEngine.increase_counter(name)
Increase the counter for a model.

Input arguments

  • name (type: str): Model name
get_num_models

RandomPoseEngine.get_num_models(name)
Return the current value for the model counter.

Input arguments

  • name (type: str): Model name

Returns

int: Number of models

is_model_in_workspace

RandomPoseEngine.is_model_in_workspace(model)
Verify if the model is in the allowed workspace

Input arguments

  • footprint (type: dict or shapely.geometries.Polygon): A shapely polygon or a dictionary with the values being the footprints for different submodels.

Returns

bool: True if the polygon is entirely contained inside the workspace

get_list_of_footprint_polygons

RandomPoseEngine.get_list_of_footprint_polygons(footprint)
Return the list of polygons contained in the footprint input.

Input arguments

  • footprint (type: dict or shapely.geometries.Polygon): A shapely polygon or a dictionary with the values being the footprints for different submodels.

Returns

List of shapely.geometry.Polygon: List of footprint polygons

has_collision

RandomPoseEngine.has_collision(model)
Run the collision checker of the input model against the current scene of the simulation.

Input arguments

  • model (type: pcg_gazebo.simulation.SimulationModel):

Returns

bool: True, if any collision is detected

run

RandomPoseEngine.run()
Run the placement engine and generate a list of models placed according to the input policies and respecting spatial constraints.

Returns

List of pcg_gazebo.simulation.SimulationModel