Installation
conda install compas_fab
Anaconda/Miniconda must be installed and the conda-forge channel must be added. Use virtual environments to avoid dependency issues. |
Frames
|
World XY frame. |
|
Create new frame with origin and vectors x
and y
. |
|
Create new frame from 3 points. |
Frame.from_euler_angles(y, p, r)
|
Create new frame from euler angles (yaw, pitch, roll). |
|
Origin of the frame. |
frame.normal
, frame.zaxis
|
Normal of the frame. |
|
Rotation as quaternion. |
|
Rotation as axis-angle vector. |
|
Rotation as euler angles. |
frame.euler_angles(False)
|
Rotation as non-static euler angles. |
Frames belong to the robotics fundamentals. Each joint contains a frame and there are several frames as coordinate systems involved (eg. wcf
, rcf
).
from compas.geometry import Frame
Frames as cartesian coordinate systems
Coordinate systems
|
Root coordinate frame of the world. |
|
Robot coordinate frame, usually on the base of the robot. |
|
Tool0 coordinate frame on the last link of the robot. |
|
Tool coordinate frame on the tool of the robot. |
|
Object coordinate frame, origin of the work area. |
|
Transform point in local coordinates of rcf
to world coordinates. |
|
Transform point in world coordinates to local coordinates of rcf
. |
Transformations
Transformation.from_frame(f)
|
Create transformation from world XY to f
frame. |
|
Create translation along x=10.0, y=5.0, z=0.0
vector. |
|
Calculate inverse of t
transformation. |
|
In-place transform point pt
with t
transformation. |
pt.transform(t * t2 * t3)
|
In-place transform point pt
with t
, t2
and t3
transformations. |
pt2 = pt.transformed(t)
|
Return a transformed copy of point pt
with t
transformation. |
Transformation
represents a 4x4 transformation matrix. Translation
, Scale
, Reflection
, Shear
and Projection
are specialized sub-classes of it.
from compas.geometry import Transformation, Translation, Rotation # , ...
Geometric primitives
Point(3, 2, 5)
or [3, 2, 5]
|
3D point with x=3.0, y=2.0, z=5.0
coordinates. |
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.geometry import Point, Vector, Frame
Parts of robot model
|
Contains visual & collision meshes, inertial info, etc. |
|
Contains parent, child links, origin frame, etc. |
|
Root of robot model tree. |
Robot models are a tree structure of links and joints based on URDF
format.
from compas.robots import RobotModel, Link, Joint
|
|
Configuration 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)
|
Configuration describes the positions of each of the joints of a robot model in its corresponding unit.
from compas_fab.robots import Configuration
Start ROS backend
Download or create a docker-compose.yml
file ( examples) and start up with:
docker-compose 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.168.99.100.
Robotic planning with MoveIt!
Forward Kinematics (FK)
Calculate end-effector frame in rcf
for a given configuration.
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 Configuration
. |
Output |
|
Calculate possible configuration(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 Configuration
|
Output |
|
Calculate linear joint trajectory for a given list of waypoints defined by frames.
This might return partial solutions, fraction
attribute indicates degree of completion, e.g. trajectory.fraction = 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 Configuration
. |
Output |
|
Calculate joint trajectory for a given start configuration and a list of goal constraints.
from compas_fab.robots import JointTrajectory, Constraint, JointConstraint, PositionConstraint, OrientationConstraint
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_fab.robots import PlanningScene, CollisionMesh
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-effector geometry, or to attach an element to the end-effector itself.
from compas_fab.robots import PlanningScene, CollisionMesh, AttachedCollisionMesh
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets