from assembly import Element

HERE = os.path.dirname(__file__)
DATA = os.path.abspath(os.path.join(HERE, "..", "data"))

# The name of the json file to save the assembly into
PATH_TO = os.path.join(
    DATA,
    os.path.splitext(os.path.basename(__file__))[0] + ".json")

# Load assembly settings
settings_file = os.path.join(DATA, "settings.json")
with open(settings_file, 'r') as f:
    data = json.load(f)

brick = Element.from_data(data['brick'])
halfbrick = Element.from_data(data['halfbrick'])
width, length, height = data['brick_dimensions']

# Create assembly
assembly = Assembly()

# ==============================================================================
# Your code goes here.
# HINT: Use the examples to see how to re-use the brick/halfbrick elements
# defined above, and get a transformed instance of each of them as you
# build up your brick wall.
# Your code comes here

# ==============================================================================
Exemple #2
0
tool = Tool.from_json(filepath)

# define brick dimensions
width, length, height = data['brick_dimensions']

# little tolerance to not 'crash' into collision objects
tolerance_vector = Vector.from_data(data['tolerance_vector'])

savelevel_vector = Vector.from_data(data['savelevel_vector'])

# define target frame
target_frame = Frame([-0.26, -0.28, height], [1, 0, 0], [0, 1, 0])
target_frame.point += tolerance_vector

# create Element and move it to target frame
element = Element.from_data(data['brick'])

# create Assembly with element at target_frame
assembly = Assembly()
T = Transformation.from_frame_to_frame(element.frame, target_frame)
assembly.add_element(element.transformed(T))

# Bring the element's mesh into the robot's tool0 frame
element_tool0 = element.copy()
T = Transformation.from_frame_to_frame(element_tool0.gripping_frame,
                                       tool.frame)
element_tool0.transform(T)

# define picking_configuration
picking_configuration = Configuration.from_data(data['picking_configuration'])