Show Menu

COMPAS FAB Cheat Sheet by

Robotic Fabrication with COMPAS FAB
robotics     architecture     digital-fabrication

Instal­lation

conda install compas­_fab

Anaco­nda­/Mi­niconda must be installed and the conda-­forge channel must be added. Use virtual enviro­nments to avoid dependency issues.

Frames

Frame.wo­rld­XY()
World XY frame.
Frame(pt, xaxis, yaxis)
Create new frame with origin and
vectors x and y.
Frame­(pt1, pt2, pt3)
Create new frame from 3 points.
Frame.from_euler_angles(y, p, r)
Create new frame from euler angles (yaw, pitch, roll).
frame.point
Origin of the frame.
frame.no­rmal, frame.zaxis
Normal of the frame.
frame.qu­ate­rnion
Rotation as quater­nion.
frame.axis_angle_vector
Rotation as axis-angle vector.
frame.eu­ler­_an­gles()
Rotation as euler angles.
frame.euler_angles(False)
Rotation as non-static euler angles.
Frames belong to the robotics fundam­entals. Each joint contains a frame and there are several frames as coordinate systems involved (eg. wcf, rcf).

from compas.ge­­ometry import Frame

Frames as cartesian coordinate systems

Coordinate systems

wcf
Root coordinate frame of the world.
rcf
Robot coordinate frame, usually on the base of the robot.
t0cf
Tool0 coordinate frame on the last link of the robot.
tcf
Tool coordinate frame on the tool of the robot.
ocf
Object coordinate frame, origin of the work area.
rcf.to_world_coords(pt)
Transform point in local coordi­nates of rcf to world coordi­nates.
rcf.to_local_coords(pt)
Transform point in world coordi­nates to local coordi­nates of rcf.

Transf­orm­ations

Transformation.from_frame(f)
Create transf­orm­ation from world XY to f frame.
Translation([10, 5, 0])
Create transl­ation along x=10.0, y=5.0, z=0.0 vector.
t.inv­erse()
Calculate inverse of t transf­orm­ation.
pt.tr­ans­for­m(t)
In-place transform point pt with t transf­orm­ation.
pt.tr­ans­form(t * t2 * t3)
In-place transform point pt with t, t2 and t3 transf­orm­ations.
pt2 = pt.tra­nsf­orm­ed(t)
Return a transf­ormed copy of point pt with t transf­orm­ation.
Trans­for­mation represents a 4x4 transf­orm­ation matrix. Trans­lat­ion, Scale, Refle­ction, Shear and Proje­ction are specia­lized sub-cl­asses of it.

from compas.ge­­ometry import Transf­orm­ation, Transl­ation, Rotation # , ...

Geometric primitives

Point(3, 2, 5) or [3, 2, 5]
3D point with x=3.0, y=2.0, z=5.0 coordi­nates.
Vector(1, 0, 0) or [1, 0, 0]
Vector x=1.0, y=0.0, z=0.0
Frame(point, xaxis, yaxis) or (point, xaxis, yaxis)
Frame at point origin and xaxis and yaxis vectors.
In COMPAS, geometric primitives can be created either as objects or as iterables (lists, tuples, etc).

from compas.ge­ometry import Point, Vector, Frame

Robot models

Parts of robot model

Link
Contains visual & collision meshes, inertial info, etc.
Joint
Contains parent, child links, origin frame, etc.
Robot­Model
Root of robot model tree.
Robot models are a tree structure of links and joints based on URDF format.

from compas.robots import RobotM­odel, Link, Joint

Joint types and units

Joint.PR­ISM­ATIC
Meters
Joint.RE­VOLUTE
Radians
Joint.CO­NTI­NUOUS
Radians
Joint.FIXED
-
 

Config­uration examples

Configuration([.5, pi], [Joint.PRISMATIC, Joint.REVOLUTE])

Configuration.from_revolute_values([0, 0, pi, 0, 0, 0])

Configuration.from_prismatic_and_revolute_values([8.3], [0.0] * 6)
Config­uration describes the positions of each of the joints of a robot model in its corres­ponding unit.

from compas­_fa­b.r­obots import Config­ura­tion

ROS backend

Start ROS backend

Download or create a docke­r-c­omp­ose.yml file (examples) and start up with:

docke­r-c­ompose up -d

Load robot from ROS

from compas_fab.backends import RosClient

with RosClient('localhost') as client:
    robot = client.load_robot()
If using Docker Toolbox, replace localhost with 192.1­68.99.100.

Robotic planning with MoveIt!

Forward Kinematics (FK)

Input
Confi­gur­ation.
Output
Frame in rcf.
Calculate end-ef­fector frame in rcf for a given config­ura­tion.

Code example

config = Configuration.from_revolute_values([0, 0, 0, 3.14, 0, 0])
frame_rcf = robot.forward_kinematics(config)

Inverse Kinematics (IK)

Input
Frame in wcf and start Confi­gur­ation.
Output
Confi­gur­ation
Calculate possible config­­ur­a­t­ion(s) for a given frame in wcf.

Code example

frame_wcf = Frame([0.3, 0.1, 0.5], [1, 0, 0], [0, 1, 0])
start_config = robot.init_configuration()
config = robot.inverse_kinematics(frame_wcf, start_config)

Path planning

Cartesian vs free-space planning

Plan cartesian path

Input
List of Frame in wcf and start Confi­gur­ation
Output
Joint­Tra­jec­tory
Calculate linear joint trajectory for a given list of waypoints defined by frames.

This might return partial solutions, fraction attribute indicates degree of comple­tion, e.g. traje­cto­ry.f­ra­ction = 0.5 means 50% of trajectory completed.

Code example

f1 = Frame([0.3, 0.1, 0.5], [1, 0, 0], [0, 1, 0])
f2 = Frame([0.6, 0.1, 0.4], [1, 0, 0], [0, 1, 0])
start_config = robot.init_configuration()

trajectory = robot.plan_cartesian_motion([f1, f2], start_config)

Plan free-space motion

Input
List of goal Const­raint and start Confi­gur­ation.
Output
Joint­Tra­jec­tory.
Calculate joint trajectory for a given start config­uration and a list of goal constr­aints.

from compas­_fa­b.r­obots import JointT­raj­ectory, Constr­aint, JointC­ons­traint, Positi­onC­ons­traint, Orient­ati­onC­ons­traint

Code example

pc = robot.constraints_from_frame(f1)
start_config = robot.init_configuration()

trajectory = robot.plan_motion(pc, start_config, planner_id='RRT')

Planning scene operations

scene = PlanningScene(robot)
scene.add_collision_mesh(CollisionMesh(mesh, 'floor'))
scene.remove_collision_mesh('floor')
scene.append_collision_mesh(CollisionMesh(mesh, 'brick'))
Append will group multiple meshes under the same name, and they can be removed with a single call to remove for that name.

from compas­_fa­b.r­obots import Planni­ngS­cene, Collis­ion­Mesh

Attach meshes to robot

scene = PlanningScene(robot)

gripper = CollisionMesh(mesh, 'gripper')
scene.attach_collision_mesh_to_robot_end_effector(gripper)
scene.remove_attached_collision_mesh('gripper')

beam = CollisionMesh(mesh, 'beam')
acm = AttachedCollisionMesh(beam, 'ee_link', ['ee_link'])
scene.add_attached_collision_mesh(acm)
These operations can be used to attach an end-ef­fector geometry, or to attach an element to the end-ef­fector itself.

from compas­_fa­b.r­obots import Planni­ngS­cene, Collis­ion­Mesh, Attach­edC­oll­isi­onMesh

Download the COMPAS FAB Cheat Sheet

4 Pages
//media.cheatography.com/storage/thumb/gonzalocasas_compas-fab.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          IT architecture and strategy Cheat Sheet
          Selenium WebDriver Cheat Sheet Cheat Sheet