Robowflex  v0.1
Making MoveIt Easy
robowflex_visualization.scene.Scene Class Reference

Container for MoveIt planning scenes in Blender. More...

Public Member Functions

def __init__ (self, name, scene_file)
 Constructor. More...
 
def load_scene (self, scene_file)
 Loads a YAML moveit_msgs::PlanningScene into Blender. More...
 
def add_collision_object (self, co)
 Adds a collision object (moveit_msgs::CollisionObject) to the scene. More...
 
def add_shape (self, name, shape, pose)
 Adds a shape (either shape_msgs::SolidPrimitive or shape_msgs::Mesh) to the scene. More...
 
def get_object (self, name)
 Retrieve a named object in the scene. More...
 

Public Attributes

 name
 
 shapes
 
 collection
 
 filepath
 
 yaml
 

Detailed Description

Container for MoveIt planning scenes in Blender.

This class loads mesh and primitive resources described in a planning scene and stores them in a Blender collection.

Definition at line 11 of file scene.py.

Constructor & Destructor Documentation

◆ __init__()

def robowflex_visualization.scene.Scene.__init__ (   self,
  name,
  scene_file 
)

Constructor.

Loads scene and creates a collection.

Parameters
nameName of Blender collection to put scene geometry in.
scene_fileScene file YAML package resource URI to load.

Definition at line 18 of file scene.py.

18  def __init__(self, name, scene_file):
19  self.name = name
20  self.shapes = {}
21 
22  self.collection = rv.utils.get_collection(name)
23 
24  if not self.collection:
25  # Create scene
26  self.collection = rv.utils.make_collection(name)
27  self.load_scene(scene_file)
28 
29  else:
30  # Populate based on existing scene
31  for item in self.collection.objects:
32  self.shapes[item.name] = item
33 

Member Function Documentation

◆ add_collision_object()

def robowflex_visualization.scene.Scene.add_collision_object (   self,
  co 
)

Adds a collision object (moveit_msgs::CollisionObject) to the scene.

Parameters
coCollision object.

Definition at line 55 of file scene.py.

55  def add_collision_object(self, co):
56  if 'primitives' in co:
57  shapes = co['primitives']
58  poses = co['primitive_poses']
59  elif 'meshes' in co:
60  shapes = co['meshes']
61  poses = co['mesh_poses']
62 
63  for shape, pose in zip(shapes, poses):
64  self.add_shape(co["id"], shape, pose)
65 

◆ add_shape()

def robowflex_visualization.scene.Scene.add_shape (   self,
  name,
  shape,
  pose 
)

Adds a shape (either shape_msgs::SolidPrimitive or shape_msgs::Mesh) to the scene.

Parameters
nameName of the object.
shapeShape to add.
posePose relative to world of the object.

Definition at line 72 of file scene.py.

72  def add_shape(self, name, shape, pose):
73  if not 'color' in shape:
74  shape['color'] = (0.0, 0.9, 0.2) # MoveIt Green.
75 
76  obj = rv.primitives.add_shape(shape)
77  obj.name = name
78 
79  self.shapes[name] = obj
80 
81  rv.utils.deselect_all()
82  rv.utils.set_pose(obj, pose)
83  rv.utils.select_all_children(obj)
84  rv.utils.move_selected_to_collection(self.name)
85  rv.utils.deselect_all()
86 

◆ get_object()

def robowflex_visualization.scene.Scene.get_object (   self,
  name 
)

Retrieve a named object in the scene.

Parameters
nameName of object to retrieve.

Definition at line 90 of file scene.py.

90  def get_object(self, name):
91  return self.shapes[name]

◆ load_scene()

def robowflex_visualization.scene.Scene.load_scene (   self,
  scene_file 
)

Loads a YAML moveit_msgs::PlanningScene into Blender.

Parameters
scene_fileYAML package URI to load.

Definition at line 38 of file scene.py.

38  def load_scene(self, scene_file):
39  self.filepath = resolved = rv.utils.resolve_path(scene_file)
40  self.yaml = rv.utils.read_YAML_data(scene_file)
41 
42  if "world" in self.yaml and self.yaml["world"]["collision_objects"]:
43  for co in self.yaml["world"]["collision_objects"]:
44  self.add_collision_object(co)
45 
46  if "robot_state" in self.yaml:
47  if "attached_collision_objects" in self.yaml["robot_state"].keys():
48  for cao in self.yaml["robot_state"]["attached_collision_objects"]:
49  self.add_collision_object(cao["object"])
50 

Member Data Documentation

◆ collection

robowflex_visualization.scene.Scene.collection

Definition at line 22 of file scene.py.

◆ filepath

robowflex_visualization.scene.Scene.filepath

Definition at line 39 of file scene.py.

◆ name

robowflex_visualization.scene.Scene.name

Definition at line 19 of file scene.py.

◆ shapes

robowflex_visualization.scene.Scene.shapes

Definition at line 20 of file scene.py.

◆ yaml

robowflex_visualization.scene.Scene.yaml

Definition at line 40 of file scene.py.


The documentation for this class was generated from the following file: