foldable_robotics package¶
Subpackages¶
Submodules¶
foldable_robotics.class_algebra module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
foldable_robotics.dxf module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- foldable_robotics.dxf.calc_circle(p1, p2, bulge, arc_approx=0)[source]¶
Approximates an arc betweem two points using a “bulge value”.
- Parameters
p1 (tuple of floats) – the starting point.
p2 (tuple of floats) – the ending point.
bulge (int) – the bulge value. Positive bulge is right of the segment, negative is left.
arc_approx (int) – number of interior points to approximate an arc with
- Return type
List of two-coordinate tuples.
- foldable_robotics.dxf.get_types(filename, model_type)[source]¶
return all of the dxf items of type “type”
- Parameters
filename (string) – path to the dxf.
model_type (string) – model type you are looking for. ex: ‘LWPOLYLINE’
- foldable_robotics.dxf.list_attrib(filename, attrib)[source]¶
list the attributes of all the items in the dxf. use a string like ‘color’ or ‘layer’
- Parameters
filename (string) – path to the dxf.
attrib (string) – attribute you wish to search.
- foldable_robotics.dxf.read_circles(filename, color=None, layer=None)[source]¶
Reads a dxf file searching for circle objects, approximating arc elements in an lwpolyline with an n-segement set of lines
- Parameters
filename (string) – the file path of the source dxf
color – optional. if included, this function filters for objects of only this color
layer – optional. if included, this function filters for objects of only this layer
- Return type
List of tuples consisting (center and radius) representing each circle.
- foldable_robotics.dxf.read_lines(filename, color=None, layer=None)[source]¶
Reads a dxf file searching for line objects,
- Parameters
filename (string) – the file path of the source dxf
color – optional. if included, this function filters for objects of only this color
layer – optional. if included, this function filters for objects of only this layer
- Return type
List of lines consisting of two two-coordinate tuples each.
- foldable_robotics.dxf.read_lwpolylines(filename, color=None, layer=None, arc_approx=0)[source]¶
Reads a dxf file searching for lwpolyline objects, approximating arc elements in an lwpolyline with an n-segement set of lines
- Parameters
filename (string) – the file path of the source dxf
color – optional. if included, this function filters for objects of only this color
layer – optional. if included, this function filters for objects of only this layer
arc_approx (int) – number of interior points to approximate an arc with
- Return type
List of lines consisting of two two-coordinate tuples each.
- foldable_robotics.dxf.read_text(filename, color=None, layer=None)[source]¶
Reads a dxf file searching for text objects,
- Parameters
filename (string) – the file path of the source dxf
color – optional. if included, this function filters for objects of only this color
layer – optional. if included, this function filters for objects of only this layer
- Return type
List of tuples consisting ((x,y),text,height, and rotation) representing each text element.
foldable_robotics.dynamics_info module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- class foldable_robotics.dynamics_info.DynamicsInfo(connected_items, connections, newtonian_ids, material_properties)[source]¶
Bases:
object
catchall container for holding information about rigid bodies and their connections
- class foldable_robotics.dynamics_info.JointProps(stiffness, damping, preload, limit_neg, limit_pos, z_pos)[source]¶
Bases:
object
The JointProps class holds all the information about each joint’s dynamic properties.
- class foldable_robotics.dynamics_info.MaterialProperty(name, color, thickness, E1, E2, density, poisson, is_adhesive, is_rigid, is_conductive, is_flexible)[source]¶
Bases:
object
The MaterialProperty class holds all the information about each layer’s material information. The geometry and material prop information can be passed seaprately, permitting more complex representations.
- classmethod make_n_blank(n, thickness=1, E1=1, E2=1, density=1, poisson=1, is_adhesive=False, is_rigid=False, is_conductive=False, is_flexible=False)[source]¶
Creates several instances with slightly different colors for differentiation
- Parameters
n (int) – number of instances
thickness (float) – the thickness of the layer
E1 (float) – Young’s modulus along the primary direction
E2 (float) – Young’s modulus along the secondary direction
density (float) – density of the material
poisson (float) – poisson’s ratio of the material
is_adhesive (bool) – indicates whether the material is an adhesive
is_rigid (bool) – indicates whether the material is rigid
is_conductive (bool) – indicates whether the material is conductive
is_flexible (bool) – indicates whether the material is flexible
- Return type
foldable_robotics.general module¶
Created on Tue Oct 2 14:39:00 2018
@author: daukes
foldable_robotics.geometry module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- foldable_robotics.geometry.colinear_segment_interior_points(segA, segB, tolerance=1e-05)[source]¶
requires that you check slope and intercept first
- (pA1,pA2)TYPE
DESCRIPTION.
- (pB1,pB2)TYPE
DESCRIPTION.
- interiorTYPE
DESCRIPTION.
- foldable_robotics.geometry.inner_angle(v1, v2)[source]¶
finds the interior angle between two vectors
- Parameters
v1 (tuple or list of floats) – the first vector
v2 (tuple or list of floats) – the second vector
- Return type
float
foldable_robotics.gmsh_support module¶
Created on Thu Feb 14 15:03:43 2019
@author: danaukes
- class foldable_robotics.gmsh_support.GeoFile(characteristic_len_min=None, characteristic_len_max=None)[source]¶
Bases:
object
- template = '\n SetFactory("OpenCASCADE");\n Geometry.LineNumbers = 0;\n Geometry.SurfaceNumbers = 0;\n'¶
foldable_robotics.jupyter_support module¶
Created on Fri Dec 29 13:06:11 2017
@author: danaukes
foldable_robotics.laminate module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- class foldable_robotics.laminate.Laminate(*layers)[source]¶
Bases:
idealab_tools.iterable.Iterable
,foldable_robotics.class_algebra.ClassAlgebra
The Laminate class holds a list of layers and can be operated upon with CSG-style functions.
- affine_transform(*args, **kwargs)[source]¶
affine transform the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- binary_operation(function_name, other, *args, **kwargs)[source]¶
performs a binary operation between self and other.
- bounding_box_coords()[source]¶
compute the lower left hand and upper right coordinates for computing a bounding box of the layer
- buffer(*args, **kwargs)[source]¶
dilate or erode the laminate based on the arguments sent. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- copy(identical=True)[source]¶
creates a copy of the instance
- Parameters
identical (boolean) – whether to use the same id or not.
- Return type
- difference(other)[source]¶
takes the difference of self - other.
:param other:the other laminate :type other: Laminate :rtype: Laminate
- dilate(*args, **kwargs)[source]¶
dilate the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- erode(*args, **kwargs)[source]¶
erode the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- export_dxf(name)[source]¶
export the laminate to a .dxf file see the corresponding layer function for arguments and keyword-arguments
- Parameters
name (string) – filename to export
- classmethod import_dict(d)[source]¶
converts a dict to a Laminate class
- Parameters
d (dict) – the laminate in dict form
- Return type
- property list¶
converts the laminate to a list.
- map_line_place(*args, **kwargs)[source]¶
transform the laminate based on two lines. see foldable_robotics.manufacturing.map_line_stretch for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- map_line_scale(*args, **kwargs)[source]¶
transform the laminate based on two lines. see foldable_robotics.manufacturing.map_line_stretch for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- map_line_stretch(*args, **kwargs)[source]¶
transform the laminate based on two lines. see foldable_robotics.manufacturing.map_line_stretch for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- mass_properties(material_properties)[source]¶
calculate mass properties
- Parameters
material_properties (foldable_robotics.dynamics_info.MaterialProperty) – tuple of arguments passed to subfunction
- Return type
tuple of mass properties
- mesh_items(material_properties)[source]¶
create a mesh for 3d rendering using pyqtgraph
- Parameters
material_properties (foldable_robotics.dynamics_info.MaterialProperty) – tuple of arguments passed to subfunction
- Return type
GLMeshItem
- plot(new=False)[source]¶
plots the laminate using matplotlib.
- Parameters
new (boolean) – whether to create a new figure
- rotate(*args, **kwargs)[source]¶
rotate the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- scale(*args, **kwargs)[source]¶
scale the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- simplify(*args, **kwargs)[source]¶
simplify the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- to_mesh(layer_thickness, characteristic_len_min=None, characteristic_len_max=None)[source]¶
create a mesh object with gmsh
- translate(*args, **kwargs)[source]¶
translate the laminate. see the corresponding layer function for arguments and keyword-arguments
- Parameters
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
- unary_operation(function_name, *args, **kwargs)[source]¶
performs a unary operation on the laminate.
- Parameters
function_name (string) – the layer-based function to be performed
args (tuple) – tuple of arguments passed to subfunction
kwargs (dict) – keyword arguments passed to subfunction
- Return type
foldable_robotics.layer module¶
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- class foldable_robotics.layer.Layer(*geoms)[source]¶
Bases:
foldable_robotics.class_algebra.ClassAlgebra
The Layer class is essentially a list of 2d polygons which all exist on the same plane.
- binary_operation(other, function_name, *args, **kwargs)[source]¶
performs a binary operation between self and other.
- bounding_box_coords()[source]¶
compute the lower left hand and upper right coordinates for computing a bounding box of the layer
- buffer(value, resolution=None)[source]¶
dilate (or erode) the geometries in the layer
- Parameters
value (float) – the positive (or negative) radius of the dilation (or erosion)
resolution (int) – the number of interpolanting vertices to use
- Return type
- copy(identical=True)[source]¶
creates a copy of the instance
- Parameters
identical (boolean) – whether to use the same id or not.
- Return type
- dilate(value, resolution=None)[source]¶
dilate the geometries in the layer
- Parameters
value (float) – the radius of the dilation
resolution (int) – the number of interpolanting vertices to use
- Return type
- erode(value, resolution=None)[source]¶
erode the geometries in the layer
- Parameters
value (float) – the radius of the erotion
resolution (int) – the number of interpolanting vertices to use
- Return type
- export_dxf(name)[source]¶
export the layer to a dxf
- Parameters
name (string) – the filename to write
- extrude(z_lower, material_property)[source]¶
create tetrahedra from the layer and return as a set of points and tetrahedra indeces
- get_paths()[source]¶
get the inner and outer paths of a layer’s geometry
- Parameters
self (foldable_robotics.layer.Layer) – the geometry
- Return type
list of list of coordinate tuples
- get_segments()[source]¶
get the line segments of a layer or linestring
- Parameters
poly (shapely.geometry.Polygon or shapely.geometry.LineString) – the geometry
- Return type
list of two-coordinate segments
- classmethod import_dict(d)[source]¶
converts a dict to a Layer instance
- Parameters
d (dict) – the laminate in dict form
- Return type
- map_line_stretch(p1, p2, p3, p4)[source]¶
Transforms a layer or laminate by using the translation and rotation between two lines to compute the stretch, scale, and rotation.
- mesh_items(z_offset=0, color=(1, 0, 0, 1))[source]¶
Return a pyqtgraph.opengl.GLMeshItem for the layer
- classmethod new(*geoms)[source]¶
create a new class instance
- Parameters
geoms (list of shapely.geometry classes) – a list of shapely geometries contained by the layer
- Return type
- plot(*args, **kwargs)[source]¶
plots the layer using matplotlib.
- Parameters
new (boolean) – whether to create a new figure
- rotate(angle, origin=(0, 0), use_radians=False)[source]¶
rotate the layer
- Parameters
angle (float) – the amount of rotation
origin (string or tuple) – the origin to use in calculating the rotation
use_radians (boolean) – whether to use radians or degrees
- Return type
- scale(xfact=1.0, yfact=1.0, zfact=1.0, origin=(0, 0))[source]¶
scale the layer
- Parameters
xfact (float) – the amount of x scaling
yfact (float) – the amount of y scaling
zfact (float) – the amount of z scaling
- Return type
- simplify(tolerance)[source]¶
simplify the layer by reducing the number of coordinates. uses shapely’s simplify function.
- Parameters
tolerance (float) – the length scale by which to simplify
- Return type
- to_laminate(value)[source]¶
convert a layer to a laminate of “value” layers
- Parameters
self (integer) – the layer itself
value – the number of layers in the laminate
- Rtype self
a layer
- foldable_robotics.layer.check_loop(loop)[source]¶
remove the last element of loop if it is the same as the first
- Parameters
loop (iterable of tuples) – list of coordinates
- Return type
iterable of tuples
- foldable_robotics.layer.extract_r(item, list_in=None)[source]¶
recursively extracts geometries from collections of geometries
- Parameters
item (class from shapely.geometry) – the shapely geometry
list_in (list) – a list to add to
- Return type
boolean
- foldable_robotics.layer.extrude(points, tris, z_lower, z_upper)[source]¶
create 3d tetrahedra from 2d triangles
- Parameters
points (numpy.array) – array of 3d points
tris (numpy.array) – the triangle coordinates
z_lower (float) – the lower z value
z_upper (float) – the upper z value
- Return type
list of Tetrahedron
- foldable_robotics.layer.flatten(geoms)[source]¶
eliminate any collections of geometries by flattening all into a single list.
- Parameters
geoms (list or iterable) – the shapely geometries
- Return type
list
- foldable_robotics.layer.from_layer_to_shapely(layer)[source]¶
convert from Layer class to shapely geometry
- Parameters
layer (Layer) – the layer instance
- Return type
class from shapely.geometry
- foldable_robotics.layer.from_shapely_to_layer(new_geoms)[source]¶
convert from shapely geometry to Layer class
- Parameters
new_geoms (list or iterable) – the shapely geometries
- Return type
- foldable_robotics.layer.inertia_tensor(about_point, density, z_lower, z_upper, points, tris)[source]¶
create 3d inertia tensor from a 2d list of triangles
- Parameters
about_point (3d coordinate) – the point about which to compute the inertia
density (float) – the density of the material
z_lower (float) – the lower z value
z_upper (float) – the upper z value
points (numpy.array) – array of 3d points
tris (numpy.array) – the triangle coordinates
- Return type
list of Tetrahedron
- foldable_robotics.layer.is_collection(item)[source]¶
determines whether the geometry defined by item contains multiple geometries
- Parameters
item (class from shapely.geometry) – the shapely geometry
- Return type
boolean
- foldable_robotics.layer.layer_constructor(loader, node)[source]¶
function for constructing layer from a dictionary for use by yaml
- foldable_robotics.layer.layer_representer(dumper, v)[source]¶
function for representing layer as a dictionary for use by yaml
- foldable_robotics.layer.plot_poly(poly, color=None, edgecolor=None, facecolor=None, linewidth=0.25)[source]¶
plot a shapely geometry
- Parameters
poly (class from shapely.geometry) – the layer instance
edgecolor (tuple) – tuple of r,g,b,a scalars from 0 to 1
facecolor (tuple) – tuple of r,g,b,a scalars from 0 to 1
linewidth (scalar or None for default) – width of the line
foldable_robotics.manufacturing module¶
A collection of tools used to compute manufacturing geometry useful for laminates and layers.
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.
- foldable_robotics.manufacturing.bounding_box(laminate)[source]¶
This function computes a bounding box aligned with the x and y axes for the given laminate.
- foldable_robotics.manufacturing.calc_hole(hinge_lines, width, resolution=None)[source]¶
From a list of lines computes the hole needed at a node, based on hinge gaps.
- Parameters
hinge_lines (list of tuples) – input shape
width (float) – width of the hinge
- Return type
- foldable_robotics.manufacturing.calc_projection_down(laminate)[source]¶
find the projection of the laminate up
- foldable_robotics.manufacturing.calc_projection_up(laminate)[source]¶
find the projection of the laminate up
- foldable_robotics.manufacturing.cleanup(input1, value, resolution=None)[source]¶
Cleans up the layer or laminate by using successive dilate and erode functions to remove small objects. Results in rounded edges
- foldable_robotics.manufacturing.cleanup2(a, radius, resolution=None)[source]¶
Cleans up the layer or laminate by using successive dilate and erode functions to remove small objects. Attempts to address rounded corners with additional CSG logic, at the cost of computation and non-intuitive results.
- foldable_robotics.manufacturing.find_connected(laminate, adhesive)[source]¶
Creates a list of laminates which are topologically connected above or below and across multiple layers.
- foldable_robotics.manufacturing.keepout_laser(laminate)[source]¶
This function computes the keepout laminate for a laser cut operation..
- foldable_robotics.manufacturing.keepout_mill_down(laminate)[source]¶
This function computes the keepout laminate for a milling operation with the mill below the bottom layer.
- foldable_robotics.manufacturing.keepout_mill_flip(laminate)[source]¶
This function computes the keepout laminate for a milling operation with the mill cutting from above and below.
- foldable_robotics.manufacturing.keepout_mill_up(laminate)[source]¶
This function computes the keepout laminate for a milling operation with the mill above the top layer.
- foldable_robotics.manufacturing.lines_to_shapely(hinge_lines)[source]¶
From a list of two-coordinate tuples, creates shapely lines.
- Parameters
hinge_lines (list of tuples) – input shape
- Return type
- foldable_robotics.manufacturing.map_line_place(self, p1, p2, p3, p4)[source]¶
Transforms a layer or laminate by using the translation and rotation between two lines to compute the stretch, scale, and rotation.
- foldable_robotics.manufacturing.map_line_scale(self, p1, p2, p3, p4)[source]¶
Transforms a layer or laminate by using the translation and rotation between two lines to compute the stretch, scale, and rotation.
- foldable_robotics.manufacturing.map_line_stretch(self, p1, p2, p3, p4)[source]¶
Transforms a layer or laminate by using the translation and rotation between two lines to compute the stretch, scale, and rotation.
- foldable_robotics.manufacturing.modify_device(device, custom_support_line, support_width, support_gap, hole_buffer)[source]¶
From a list of two-coordinate tuples, creates shapely lines.
- Parameters
- Return type
- foldable_robotics.manufacturing.modify_keepout(laminate, is_adhesive)[source]¶
is this better than other algorithms
- foldable_robotics.manufacturing.not_removable_both(laminate)[source]¶
This function computes the non-removable material in the either direction for a given laminate.
- foldable_robotics.manufacturing.not_removable_down(laminate, is_adhesive)[source]¶
This function computes the non-removable material in the down direction for a given laminate.
- foldable_robotics.manufacturing.not_removable_up(laminate, is_adhesive)[source]¶
This function computes the non-removable material in the up direction for a given laminate.
- foldable_robotics.manufacturing.split_laminate_by_geoms(laminate)[source]¶
This function splits a laminate into n respective geometries and returns one laminate for each geom.
- Parameters
laminate (Laminate) – input shape
- Return type
list of Laminates
- foldable_robotics.manufacturing.support(laminate, keepout_method, width, invalid_width, small_dim=0.001)[source]¶
This function computes support for a laminate.
- Parameters
laminate (Laminate) – input shape
keepout_method (python function ref) – the keepout method selected for the computation
width (float) – gap away from the original laminate
invalid_width (float) – value to keep support away from non-cuttable regions.
small_dim (float) – relatively small dimension for eliminating numerical precision problems.
- Return type
foldable_robotics.parts-old module¶
foldable_robotics.pdf module¶
Created on Wed Feb 7 20:34:27 2018
@author: danaukes
- class foldable_robotics.pdf.Page(filename='output.pdf', width=40, height=28)[source]¶
Bases:
object
This class defines a pdf page, which can hold vector geometry.
- draw_linestring(geom, line_color=(0, 0, 0, 1), line_width=0.01, fill_color=(0, 0, 0, 1))[source]¶
Draw an open linestring.
- Parameters
poly (list of tuples) – describes each vertex of the linestring.
line_color (tuple of floats) – line color in (r,g,b,a) format.
line_width (tuple of floats) – width of the line
fill_color – color of the linestring interior, in (r,g,b,a) format
- Return type
None
- draw_poly(poly, line_color=(0, 0, 0, 1), line_width=0.01, fill_color=(0, 0, 0, 1))[source]¶
Draw a closed polygon.
- Parameters
poly (list of tuples) – describes each vertex of the polygon.
line_color (tuple of floats) – line color in (r,g,b,a) format.
line_width (tuple of floats) – width of the line
fill_color – color of the polygon interior, in (r,g,b,a) format
- Return type
None
foldable_robotics.plotter_support module¶
Created on Wed Feb 7 20:34:27 2018
@author: danaukes
foldable_robotics.solidworks_support module¶
Created on Thu Jan 3 14:23:36 2019
@author: daukes
Module contents¶
The foldable_robotics package is useful for designing and computing layer-based geometries for cutting out robots from sheet-based materials using a laser or other CNC tool. This collection of modules makes it easy to create foldable robotic devices and to automate the calculation of the manufacturing files.
Written by Daniel M. Aukes and CONTRIBUTORS Email: danaukes<at>asu.edu. Please see LICENSE for full license.