Skip to content

Commit

Permalink
Pick frame from grid
Browse files Browse the repository at this point in the history
  • Loading branch information
tetov committed Feb 25, 2020
1 parent 49749ec commit 297771d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 25 additions & 16 deletions src/compas_rcf/fabrication/abb_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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


################################################################################
Expand Down Expand Up @@ -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)
Expand All @@ -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 #
Expand All @@ -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.")

Expand Down
12 changes: 12 additions & 0 deletions src/compas_rcf/fabrication/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
10 changes: 10 additions & 0 deletions src/compas_rcf/fabrication/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 297771d

Please sign in to comment.