From 297771dc67c80088d49f3d871b65f457653f4b0a Mon Sep 17 00:00:00 2001 From: tetov Date: Tue, 25 Feb 2020 21:30:46 +0100 Subject: [PATCH] Pick frame from grid --- CHANGELOG.md | 13 ++++++ src/compas_rcf/fabrication/abb_runner.py | 41 +++++++++++-------- src/compas_rcf/fabrication/conf.py | 12 ++++++ .../fabrication/config_default.yaml | 10 +++++ 4 files changed, 60 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b9bf6ba..bd77bcd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## \[0.1.20\] \[2020-20-25\] + +### Added + +- Settings regarding picking grid added to `compas_rcf.fabrication.conf`. + +### Changed + +- Function `get_picking_frame` in `compas_rcf.fabrication.abb_runner` reworked into `pick_frame_from_grid` which reads settings from conf to return frames from a grid of picking points. +- JSON dump after end of `abb_runner` now dumps original list (`clay_bullets`) instead of a new. + +## \[0.1.18\] \[2020-02-20\] + ## \[0.1.19\] \[2020-20-22\] ### Changed diff --git a/src/compas_rcf/fabrication/abb_runner.py b/src/compas_rcf/fabrication/abb_runner.py index 8c503f51..a49e13c2 100644 --- a/src/compas_rcf/fabrication/abb_runner.py +++ b/src/compas_rcf/fabrication/abb_runner.py @@ -78,13 +78,12 @@ def initial_setup(client): ---------- client : :class:`compas_rrc.AbbClient` """ - send_grip_release(client, CONF.tool.release_state) client.send(SetTool(CONF.tool.tool_name)) logging.debug("Tool {} set.".format(CONF.tool.tool_name)) client.send(SetWorkObject(CONF.wobjs.placing_wobj_name)) - logging.debug("Work object {} set.") + logging.debug("Work object {} set.".format(CONF.wobjs.placing_wobj_name)) # Set Acceleration client.send(SetAcceleration(CONF.speed_values.accel, CONF.speed_values.accel_ramp)) @@ -334,23 +333,33 @@ def get_settings(): sys.exit() -def get_picking_frame(bullet_height): +def pick_frame_from_grid(index, bullet_height): """Get next picking frame. Parameters ---------- + index : int + Counter to iterate through picking positions. bullet_height : float - Height of bullet to pick up + Height of bullet to pick up. Returns ------- - `class`:compas.geometry.Frame + list of `class`:compas.geometry.Frame """ - # TODO: Set up a grid to pick from - picking_frame = Frame(Point(0, 0, 0), Vector(0, 1, 0), Vector(1, 0, 0)) + # If index is larger than amount on picking plate, start from zero again + index = index % (CONF.pick.xnum * CONF.pick.ynum) + + xpos = index % CONF.pick.xnum + ypos = index // CONF.pick.xnum + + x = CONF.pick.origin_grid.x + xpos * CONF.pick.grid_spacing + y = CONF.pick.origin_grid.y + ypos * CONF.pick.grid_spacing + z = bullet_height * CONF.pick.compression_height_factor - # TODO: Make the pressing at picking more configurable - return get_offset_frame(picking_frame, bullet_height * 0.95) + frame = Frame(Point(x, y, z), Vector(*CONF.pick.xaxis), Vector(*CONF.pick.yaxis)) + logging.debug("Picking frame {:03d}: {}".format(index, frame)) + return frame ################################################################################ @@ -450,15 +459,16 @@ def abb_run(cmd_line_args): ############################################################################ # Fabrication loop # ############################################################################ - placed_bullets = [] + for i, bullet in enumerate(clay_bullets): - logging.info("Bullet {}/{} with id {}".format(i, len(clay_bullets), bullet.id)) + logging.info( + "Bullet {:03d}/{:03d} with id {}".format(i, len(clay_bullets), bullet.id) + ) - picking_frame = get_picking_frame(bullet.height) - logging.debug("Picking frame: {}".format(picking_frame)) + pick_frame = pick_frame_from_grid(i, bullet.height) # Pick bullet - pick_future = send_picking(abb, picking_frame) + pick_future = send_picking(abb, pick_frame) # Place bullet place_future = send_placing(abb, bullet) @@ -469,7 +479,6 @@ def abb_run(cmd_line_args): logging.debug("Cycle time was {}".format(bullet.cycle_time)) bullet.placed = time.time() logging.debug("Time placed was {}".format(bullet.placed)) - placed_bullets.append(bullet) ############################################################################ # Shutdown procedure # @@ -478,7 +487,7 @@ def abb_run(cmd_line_args): done_json = DEFAULT_JSON_DIR / "00_done" / json_path.name with done_json.open(mode="w") as fp: - json.dump(placed_bullets, fp, cls=ClayBulletEncoder) + json.dump(clay_bullets, fp, cls=ClayBulletEncoder) logging.debug("Saved placed bullets.") diff --git a/src/compas_rcf/fabrication/conf.py b/src/compas_rcf/fabrication/conf.py index eb05f718..ab5a2860 100644 --- a/src/compas_rcf/fabrication/conf.py +++ b/src/compas_rcf/fabrication/conf.py @@ -60,6 +60,18 @@ def convert(self, value, view): "zone_pick": ZoneDataTemplate(), "zone_place": ZoneDataTemplate(), }, + "pick": { + "origin_grid": { + "x": confuse.Number(default=100), + "y": confuse.Number(default=100), + }, + "xnum": int, + "ynum": int, + "grid_spacing": float, + "compression_height_factor": confuse.Number(default=0.95), + "xaxis": confuse.Sequence([float] * 3), + "yaxis": confuse.Sequence([float] * 3), + }, } fabrication_conf = confuse.LazyConfig("FabricationRunner", __name__) diff --git a/src/compas_rcf/fabrication/config_default.yaml b/src/compas_rcf/fabrication/config_default.yaml index 27a835af..400eba45 100644 --- a/src/compas_rcf/fabrication/config_default.yaml +++ b/src/compas_rcf/fabrication/config_default.yaml @@ -33,3 +33,13 @@ wobjs: # name of work objects as defined in controller picking_wobj_name: ob_A057_WobjPicking01 placing_wobj_name: ob_A057_WobjPlacing01 +pick: + origin_grid: # grid offset from wobj in mm + x: 125 + y: 125 + xnum: 6 # number of bullets in x direction + ynum: 3 # number of bullets in y direction + grid_spacing: 125 # distance between grid crossings + compression_height_factor: 0.95 # controls compression before lifting + xaxis: [0, 1, 0] # x axis as a list + yaxis: [1, 0, 0] # y axis as a list