Exemple #1
0
    def RunScript(self, robot, visual_mesh, collision_mesh, tcf_plane):
        if robot and robot.client and robot.client.is_connected and visual_mesh:
            if not collision_mesh:
                collision_mesh = visual_mesh

            c_visual_mesh = RhinoMesh.from_geometry(visual_mesh).to_compas()
            c_collision_mesh = RhinoMesh.from_geometry(collision_mesh).to_compas()

            if not tcf_plane:
                frame = Frame.worldXY()
            else:
                frame = plane_to_compas_frame(tcf_plane)
            tool = Tool(c_visual_mesh, frame, c_collision_mesh)

            scene = PlanningScene(robot)
            robot.attach_tool(tool)
            scene.add_attached_tool()

        return robot
Exemple #2
0
def fixed_waam_setup():
    HERE = os.path.dirname(__file__)
    package_path = os.path.abspath(
        os.path.join(HERE, "..", "..", "data", "robots", "abb_fixed_waam"))
    urdf_filename = os.path.join(package_path, "urdf", "abb_fixed_waam.urdf")
    srdf_filename = os.path.join(package_path, "srdf", "abb_fixed_waam.srdf")

    model = RobotModel.from_urdf_file(urdf_filename)
    semantics = RobotSemantics.from_srdf_file(srdf_filename, model)

    tool_frame_robotA = Frame.from_euler_angles(
        [0.591366, -0.000922, 1.570177],
        static=True,
        axes='xyz',
        point=[-0.002241, -0.000202, 0.505922])
    tool_mesh_robotA = Mesh.from_obj(
        os.path.join(package_path, "meshes", "collision", "waam_tool.obj"))
    robotA_tool = Tool(tool_mesh_robotA,
                       tool_frame_robotA,
                       collision=tool_mesh_robotA)
    return urdf_filename, semantics, robotA_tool
import os
import time

from compas_fab.backends import RosClient
from compas_fab.robots import PlanningScene
from compas_fab.robots import Tool

HERE = os.path.dirname(__file__)
DATA = os.path.abspath(os.path.join(HERE, "..", "data"))
tool = Tool.from_json(os.path.join(DATA, "vacuum_gripper.json"))

with RosClient('localhost') as client:
    robot = client.load_robot()
    scene = PlanningScene(robot)

    # Attach the tool
    robot.attach_tool(tool)
    scene.add_attached_tool()

    time.sleep(3)

    # Remove the tool
    scene.remove_attached_tool()
    scene.remove_collision_mesh(tool.name)
    robot.detach_tool()
    time.sleep(1)
import os
from compas.geometry import Frame
from compas_fab.backends import RosClient
from compas_fab.robots import Configuration
from compas_fab.robots import Tool

HERE = os.path.dirname(__file__)
DATA = os.path.abspath(os.path.join(HERE, "..", "data"))

# create tool from json
filepath = os.path.join(DATA, "vacuum_gripper.json")
tool = Tool.from_json(filepath)

element_height = 0.014
safelevel_height = 0.05

with RosClient('localhost') as client:
    robot = client.load_robot()

    # 1. Set tool
    robot.attach_tool(tool)

    # 2. Define start configuration
    start_configuration = Configuration.from_revolute_values(
        [-5.961, 4.407, -2.265, 5.712, 1.571, -2.820])

    # 3. Define frames
    picking_frame = Frame([-0.43, 0, element_height], [1, 0, 0], [0, 1, 0])
    safelevel_picking_frame = Frame(
        [-0.43, 0, element_height + safelevel_height], [1, 0, 0], [0, 1, 0])
    frames = [picking_frame, safelevel_picking_frame]
import time

from compas_fab.backends import RosClient
from compas_fab.robots import PlanningScene
from compas_fab.robots import Tool

from compas.datastructures import Mesh
from compas.geometry import Frame

HERE = os.path.dirname(__file__)
DATA = os.path.abspath(os.path.join(HERE, "..", "data"))

# create tool from mesh and frame
mesh = Mesh.from_stl(os.path.join(DATA, "vacuum_gripper.stl"))
frame = Frame([0.07, 0, 0], [0, 0, 1], [0, 1, 0])
tool = Tool(mesh, frame)
tool.to_json(os.path.join(DATA, "vacuum_gripper.json"))

with RosClient('localhost') as client:
    robot = client.load_robot()
    scene = PlanningScene(robot)
    robot.attach_tool(tool)

    # add attached tool to planning scene
    scene.add_attached_tool()

    # now we can convert frames at robot's tool tip and flange
    frames_tcf = [
        Frame((-0.309, -0.046, -0.266), (0.276, 0.926, -0.256),
              (0.879, -0.136, 0.456))
    ]
from compas.geometry import Frame

import compas_fab
from compas_fab.backends import RosClient
from compas_fab.robots import PlanningScene
from compas_fab.robots import Tool

with RosClient() as client:
    robot = client.load_robot()
    scene = PlanningScene(robot)
    assert robot.name == 'ur5_robot'

    # create collision object
    mesh = Mesh.from_stl(compas_fab.get('planning_scene/cone.stl'))
    t1cf = Frame([0.14, 0, 0], [0, 0, 1], [0, 1, 0])          # TODO: check this frame!
    tool = Tool(mesh, t1cf, name='tip')
    scene.add_attached_tool(tool)

    # sleep a bit before removing the tip
    time.sleep(1)

    # check if it's really there
    planning_scene = robot.client.get_planning_scene()
    acm = planning_scene.robot_state.attached_collision_objects
    assert acm[0].object['id'].startswith('tip_')

    scene.remove_attached_tool()

    planning_scene = robot.client.get_planning_scene()
    assert acm[0].object['id'] not in [c.object['id'] for c in planning_scene.robot_state.attached_collision_objects]