Show Menu
Cheatography

Robotic Fabrication with COMPAS FAB

Instal­lation

conda install compas_fab


Anacon­da/­Min­iconda must be installed and the conda-­forge channel must be added. Use virtual enviro­nments to avoid dependency issues.

Frames

Frame.w­or­ldXY()
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.p­oint
Origin of the frame.
frame.n­ormal
,
frame.z­axis
Normal of the frame.
frame.q­ua­ternion
Rotation as quater­nion.
frame.axis_angle_vector
Rotation as axis-angle vector.
frame.e­ul­er_­ang­les()
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.inve­rse()
Calculate inverse of
t
transf­orm­ation.
pt.tra­nsf­orm(t)
In-place transform point
pt
with
t
transf­orm­ation.
pt.tra­nsf­orm(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.
Transf­orm­ation
represents a 4x4 transf­orm­ation matrix.
Transl­ation
,
Scale
,
Reflection
,
Shear
and
Projection
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.
RobotModel
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.P­RI­SMATIC
Meters
Joint.R­EV­OLUTE
Radians
Joint.C­ON­TINUOUS
Radians
Joint.F­IXED
-
 

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­uration

ROS backend

Start ROS backend

Download or create a
docker­-co­mpo­se.yml
file (examples) and start up with:

docker­-co­mpose 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.16­8.9­9.100.

Robotic planning with MoveIt!

Forward Kinematics (FK)

Input
Config­uration
.
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
Config­uration
.
Output
Config­uration
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
Config­uration
Output
JointT­raj­ectory
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.
trajec­tor­y.f­raction = 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
Constraint
and start
Config­uration
.
Output
JointT­raj­ectory
.
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­ionMesh

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
 

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

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Anki Vector Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet