Exemplo n.º 1
0
def pick_bullet(client, picking_frame):
    """Send movement and IO instructions to pick up a clay bullet.

    Uses ``fab_conf`` set up using
    :func:`compas_rcf.fab_data.interactive_conf_setup` for fabrication settings.

    Parameters
    ----------
    client : :class:`compas_rrc.AbbClient`
    picking_frame : :class:`compas.geometry.Frame`
        Target frame to pick up bullet

    Returns
    -------
    :class:`compas_rrc.FutureResult`
        Object which blocks while waiting for feedback from robot. Calling result on
        this object will return the time the procedure took.
    """
    # change work object before picking
    client.send(SetWorkObject(fab_conf["wobjs"]["picking_wobj_name"].get()))

    # pick bullet
    offset_picking = get_offset_frame(
        picking_frame, fab_conf["movement"]["offset_distance"].get())

    # start watch
    client.send(StartWatch())

    client.send(
        MoveToFrame(
            offset_picking,
            fab_conf["movement"]["speed_travel"].as_number(),
            fab_conf["movement"]["zone_travel"].get(ZoneDataTemplate()),
        ))

    client.send(
        MoveToFrame(
            picking_frame,
            fab_conf["movement"]["speed_travel"].as_number(),
            fab_conf["movement"]["zone_pick"].get(ZoneDataTemplate()),
        ))

    grip_and_release(
        client,
        fab_conf["tool"]["io_needles_pin"].get(),
        fab_conf["tool"]["grip_state"].get(),
        wait_before=fab_conf["tool"]["wait_before_io"].get(),
        wait_after=fab_conf["tool"]["wait_after_io"].get(),
    )

    client.send(
        MoveToFrame(
            offset_picking,
            fab_conf["movement"]["speed_picking"].as_number(),
            fab_conf["movement"]["zone_pick"].get(ZoneDataTemplate()),
        ))

    client.send(StopWatch())

    return client.send(ReadWatch())
    def pick_bullet(self, pick_elem):
        """Send movement and IO instructions to pick up a clay cylinder.

        Parameter
        ----------
        pick_elem : :class:`~rapid_clay_formations_fab.fab_data.ClayBullet`
            Representation of fabrication element to pick up.
        """
        self.send(compas_rrc.SetTool(self.pick_place_tool.name))
        log.debug("Tool {} set.".format(self.pick_place_tool.name))
        self.send(compas_rrc.SetWorkObject(self.wobjs.pick))
        log.debug("Work object {} set.".format(self.wobjs.pick))

        # start watch
        self.send(compas_rrc.StartWatch())

        # TODO: Use separate obj for pick elems?
        vector = pick_elem.get_normal(
        ) * self.pick_place_tool.elem_pick_egress_dist
        T = Translation(vector)
        egress_frame = pick_elem.get_uncompressed_top_frame().transformed(T)

        self.send(
            MoveToFrame(egress_frame, self.speed.travel, self.zone.travel))

        self.send(
            MoveToFrame(
                pick_elem.get_uncompressed_top_frame(),
                self.speed.precise,
                self.zone.pick,
            ))

        self.send(compas_rrc.WaitTime(self.pick_place_tool.needles_pause))
        self.extend_needles()
        self.send(compas_rrc.WaitTime(self.pick_place_tool.needles_pause))

        self.send(
            MoveToFrame(
                egress_frame,
                self.speed.precise,
                self.zone.pick,
                motion_type=Motion.LINEAR,
            ))

        self.send(compas_rrc.StopWatch())

        return self.send(compas_rrc.ReadWatch())
Exemplo n.º 3
0
    def pick_bullet(self, cylinder):
        """Send movement and IO instructions to pick up a clay cylinder.

        Uses `fab_conf` set up with command line arguments and configuration
        file.

        Parameters
        ----------
        client : :class:`compas_rrc.AbbClient`
        picking_frame : :class:`compas.geometry.Frame`
            Target frame to pick up cylinder
        """
        # change work object before picking
        self.send(SetTool(self.pick_place_tool.name))
        self.send(SetWorkObject(self.wobjs.pick))

        # start watch
        self.send(StartWatch())

        self.send(
            MoveToFrame(cylinder.get_egress_frame(), self.speed.travel,
                        self.zone.travel))

        self.send(
            MoveToFrame(
                cylinder.get_uncompressed_top_frame(),
                self.speed.travel,
                self.zone.precise,
            ))

        self.send(WaitTime(self.pick_place_tool.needles_pause))
        self.extend_needles()
        self.send(WaitTime(self.pick_place_tool.needles_pause))

        self.send(
            MoveToFrame(cylinder.get_egress_frame(), self.speed.precise,
                        self.zone.precise))

        self.send(StopWatch())

        return self.send(ReadWatch())
def test_speeds():
    with RosClient() as ros:
        client = compas_rrc.AbbClient(ros)
        client.run()

        # Confirm start on flexpendant
        client.send(PrintText("Confirm start by pressing play."))
        client.send(compas_rrc.Stop())

        # The speed and acceleration values are then overriden here
        client.send(compas_rrc.SetMaxSpeed(SPEED_OVERRIDE, SPEED_MAX_TCP))
        client.send(compas_rrc.SetAcceleration(ACCELERATION,
                                               ACCELERATION_RAMP))
        client.send(PrintText(f"Speed override: {SPEED_OVERRIDE} %"))
        client.send(PrintText(f"Max TCP speed: {SPEED_OVERRIDE} mm/s"))
        client.send(PrintText(f"Acceleration: {ACCELERATION} %"))
        client.send(PrintText(f"Acceleration ramp: {ACCELERATION_RAMP} %"))

        client.send(compas_rrc.SetTool(client.pick_place_tool.name))
        client.send(compas_rrc.SetWorkObject("wobj0"))
        client.send(PrintText(f"Tool: {TOOL}"))
        client.send(PrintText(f"wobj: {WOBJ}"))

        if TEST_JOINT_POS:
            for i in range(N_TIMES_REPEAT_LISTS):
                speed = START_SPEED + SPEED_INCREMENTS * i
                client.send(
                    PrintText(f"Speed: {speed} mm/s, Zone: {ZONE} mm.", ))

                client.send(compas_rrc.StartWatch())
                for pos in JOINT_POS:
                    client.send(
                        MoveToJoints(pos, client.EXTERNAL_AXES_DUMMY, speed,
                                     ZONE))

                # Block until finished and print cycle time
                client.send(compas_rrc.StopWatch())
                cycle_time = client.send_and_wait(compas_rrc.ReadWatch(),
                                                  timeout=TIMEOUT)
                client.send(PrintText(f"Cycle took {cycle_time} s."))

        if TEST_FRAMES:
            for i in range(N_TIMES_REPEAT_LISTS):
                speed = START_SPEED + SPEED_INCREMENTS * i
                client.send(
                    PrintText(f"Speed: {speed} mm/s, Zone: {ZONE} mm.", ))

                client.send(compas_rrc.StartWatch())
                for frame in FRAMES:
                    client.send(
                        MoveToFrame(
                            frame,
                            speed,
                            ZONE,
                            motion_type=MOTION_TYPE,
                        ))

                # Block until finished and print cycle time
                client.send(compas_rrc.StopWatch())
                cycle_time = client.send_and_wait(compas_rrc.ReadWatch(),
                                                  timeout=TIMEOUT)
                client.send(PrintText(f"Cycle took {cycle_time} s."))

        client.close()
Exemplo n.º 5
0
def test_speeds(run_conf, run_data):
    rob_conf = run_conf.robot_client

    # Compose up master, driver, bridge
    compose_up_driver(rob_conf.controller)

    pick_station = run_data["pick_station"]

    # This context manager sets up RosClient, inherits from AbbClient
    # with added fabrication specific methods
    # On exit it unadvertises topics and stops RosClient
    with AbbRcfFabricationClient(rob_conf, pick_station) as client:
        # Sends ping (noop) and restarts container if no response
        client.ensure_connection()

        client.log_and_print("Confirm start by pressing play.")
        # Confirm start on flexpendant
        client.confirm_start()

        # Sends move to start position, retracts needles and sets the defaults
        # speed and acceleration values.
        client.pre_procedure()

        # The speed and acceleration values are then overriden here
        client.send(compas_rrc.SetMaxSpeed(SPEED_OVERRIDE, SPEED_MAX_TCP))
        client.send(compas_rrc.SetAcceleration(ACCELERATION,
                                               ACCELERATION_RAMP))
        client.log_and_print(f"Speed override: {SPEED_OVERRIDE} %")
        client.log_and_print(f"Max TCP speed: {SPEED_OVERRIDE} mm/s")
        client.log_and_print(f"Acceleration: {ACCELERATION} %")
        client.log_and_print(f"Acceleration ramp: {ACCELERATION_RAMP} %")

        if PICK_ELEMENT:
            # Sends instruction to pick up element from first position
            # Subsequent calls picks up from next positions
            client.pick_element()

        client.send(compas_rrc.SetTool(client.pick_place_tool.name))
        client.send(compas_rrc.SetWorkObject("wobj0"))
        client.log_and_print(f"Tool: {TOOL}")
        client.log_and_print(f"wobj: {WOBJ}")

        if TEST_FRAMES:
            for i in range(N_TIMES_REPEAT_LISTS):
                speed = START_SPEED + SPEED_INCREMENTS * i
                client.log_and_print(
                    f"Speed: {speed} mm/s, Zone: {ZONE} mm.", )

                client.send(compas_rrc.StartWatch())
                for frame in FRAMES:
                    client.send(
                        MoveToFrame(
                            frame,
                            speed,
                            ZONE,
                            motion_type=MOTION_TYPE,
                        ))

                # Block until finished and print cycle time
                client.send(compas_rrc.StopWatch())
                cycle_time = client.send_and_wait(compas_rrc.ReadWatch(),
                                                  timeout=TIMEOUT)
                client.log_and_print(f"Cycle took {cycle_time} s.")

        if TEST_JOINT_POS:
            for i in range(N_TIMES_REPEAT_LISTS):
                speed = START_SPEED + SPEED_INCREMENTS * i
                client.log_and_print(
                    f"Speed: {speed} mm/s, Zone: {ZONE} mm.", )

                client.send(compas_rrc.StartWatch())
                for pos in JOINT_POS:
                    client.send(
                        MoveToJoints(pos, client.EXTERNAL_AXES_DUMMY, speed,
                                     ZONE))

                # Block until finished and print cycle time
                client.send(compas_rrc.StopWatch())
                cycle_time = client.send_and_wait(compas_rrc.ReadWatch(),
                                                  timeout=TIMEOUT)
                client.log_and_print(f"Cycle took {cycle_time} s.")
Exemplo n.º 6
0
def place_bullet(client, bullet):
    """Send movement and IO instructions to place a clay bullet.

    Uses ``fab_conf`` set up using
    :func:`compas_rcf.fab_data.interactive_conf_setup` for fabrication settings.

    Parameters
    ----------
    client : :class:`compas_rrc.AbbClient`
        Client connected to controller procedure should be sent to.
    bullet : :class:`compas_rcf.fab_data.ClayBullet`
        Bullet to place.

    Returns
    -------
    :class:`compas_rrc.FutureResult`
        Object which blocks while waiting for feedback from robot. Calling result on
        this object will return the time the procedure took.
    """
    log.debug("Location frame: {}".format(bullet.location))

    # change work object before placing
    client.send(SetWorkObject(fab_conf["wobjs"]["placing_wobj_name"].as_str()))

    # add offset placing plane to pre and post frames

    top_bullet_frame = get_offset_frame(bullet.location, bullet.height)
    offset_placement = get_offset_frame(
        top_bullet_frame, fab_conf["movement"]["offset_distance"].as_number())

    # start watch
    client.send(StartWatch())

    # Safe pos then vertical offset
    for frame in bullet.trajectory_to:
        client.send(
            MoveToFrame(
                frame,
                fab_conf["movement"]["speed_travel"].as_number(),
                fab_conf["movement"]["zone_travel"].get(ZoneDataTemplate()),
            ))

    client.send(
        MoveToFrame(
            offset_placement,
            fab_conf["movement"]["speed_travel"].as_number(),
            fab_conf["movement"]["zone_travel"].get(ZoneDataTemplate()),
        ))
    client.send(
        MoveToFrame(
            top_bullet_frame,
            fab_conf["movement"]["speed_placing"].as_number(),
            fab_conf["movement"]["zone_place"].get(ZoneDataTemplate()),
        ))

    grip_and_release(
        client,
        fab_conf["tool"]["io_needles_pin"].get(),
        fab_conf["tool"]["release_state"].get(),
        wait_before=fab_conf["tool"]["wait_before_io"].get(),
        wait_after=fab_conf["tool"]["wait_after_io"].get(),
    )

    client.send(
        MoveToFrame(
            bullet.placement_frame,
            fab_conf["movement"]["speed_placing"].as_number(),
            fab_conf["movement"]["zone_place"].get(ZoneDataTemplate()),
        ))

    client.send(
        MoveToFrame(
            offset_placement,
            fab_conf["movement"]["speed_travel"].as_number(),
            fab_conf["movement"]["zone_travel"].get(ZoneDataTemplate()),
        ))

    # offset placement frame then safety frame
    for frame in bullet.trajectory_from:
        client.send(
            MoveToFrame(
                frame,
                fab_conf["movement"]["speed_travel"].as_number(),
                fab_conf["movement"]["zone_travel"].get(ZoneDataTemplate()),
            ))

    client.send(StopWatch())

    return client.send(ReadWatch())
Exemplo n.º 7
0
def std_move_to_frame(
    frame,
    tool="tool0",
    wobj="wobj0",
    motion_type=Motion.LINEAR,
    speed=200,
    accel=100,
    zone=Zone.FINE,
    timeout=None,
):
    """Move robot arm to target or targets.

    Parameters
    ----------
    frame : :class:`compas.geometry.Frame` or :obj:`list` of :class:`compas.geometry.Frame`
        Target frame or frames.
    tool : :obj:`str`
        Name of tool as named in RAPID code on controller to use for TCP data.
    wobj : :obj:`str`
        Name of work object as named in RAPID code on controller to use for
        coordinate system.
    motion_type : :class:`compas_rrc.Motion`
        Motion type, either linear (:class:`~compas_rrc.Motion.LINEAR`) or
        joint (:class:`~compas_rrc.Motion.JOINT`).
    speed : :obj:`float`
        TCP speed in mm/s. Limited by hard coded max speed in this function as
        well as safety systems on controller.
    accel : :obj:`float`
        Acceleration in percentage of standard acceleration.
    zone : :class:`compas_rrc.Zone`
        Set zone value of movement, (acceptable deviation from target).
    timeout : :obj:`float`
        Time to wait for indication of finished movement. If not defined no
        feedback will be requested.
    """  # noqa: E501
    if not isinstance(frame, Sequence):
        frames = [frame]
    else:
        frames = frame

    with RosClient() as ros:
        # Create ABB Client
        abb = AbbClient(ros)
        abb.run(timeout=5)

        abb.send(SetTool(tool))
        abb.send(SetWorkObject(wobj))

        # Set acceleration data
        ramp = 100  # % Higher values makes the acceleration ramp longer
        abb.send(SetAcceleration(accel, ramp))

        # Set speed override and max speed
        speed_override = 100  # %
        max_tcp_speed = 500  # mm/s
        abb.send(SetMaxSpeed(speed_override, max_tcp_speed))

        # Move to Frame
        for f in frames:
            abb.send(
                PrintText(" Moving to {:.3f}, {:.3f}, {:.3f}.".format(
                    *f.point.data)))
            abb.send(MoveToFrame(f, speed, zone, motion_type))

        if timeout:
            abb.send_and_wait(Noop(), timeout=timeout)
Exemplo n.º 8
0
    def place_bullet(self, cylinder):
        """Send movement and IO instructions to place a clay cylinder.

        Uses `fab_conf` set up with command line arguments and configuration
        file.

        Parameters
        ----------
        client : :class:`compas_rrc.AbbClient`
            Client connected to controller procedure should be sent to.
        cylinder : :class:`compas_rcf.fab_data.ClayBullet`
            cylinder to place.

        Returns
        -------
        :class:`compas_rrc.FutureResult`
            Object which blocks while waiting for feedback from robot. Calling result on
            this object will return the time the procedure took.
        """
        log.debug("Location frame: {}".format(cylinder.location))

        # change work object before placing
        self.send(SetWorkObject(self.wobjs.place))

        # move there with distance sensor TCP active
        self.send(SetTool(self.dist_sensor_tool.name))

        # start watch
        self.send(StartWatch())

        # Safe pos then vertical offset
        for frame in cylinder.trajectory_to:
            self.send(MoveToFrame(frame, self.speed.travel, self.zone.travel))

        self.send(
            MoveToFrame(cylinder.get_egress_frame(), self.speed.travel,
                        self.zone.travel))

        if self.dist_sensor_tool.get("port") is not None:
            dist_diff = self.measure_z_diff(cylinder)

            if self.max_z_diff and self.is_dist_diff_ok(dist_diff):
                self.correct_location(cylinder, dist_diff)
            else:
                raise Exception("Unacceptable distance difference.")

        self.send_and_wait(WaitTime(2, feedback_level=FeedbackLevel.NONE))

        self.send_and_wait(WaitTime(2))

        self.send(SetTool(self.pick_place_tool))

        self.send(
            MoveToFrame(
                cylinder.get_uncompressed_top_frame(),
                self.speed.precise,
                self.zone.precise,
            ))

        self.send(WaitTime(self.pick_place_tool.needles_pause))
        self.retract_needles()
        self.send(WaitTime(self.pick_place_tool.needles_pause))

        self.send(
            MoveToFrame(
                cylinder.get_compressed_top_frame(),
                self.speed.precise,
                self.zone.precise,
            ))

        self.send(
            MoveToFrame(cylinder.get_egress_frame(), self.speed.travel,
                        self.zone.travel))

        # offset placement frame then safety frame
        for frame in cylinder.trajectory_from:
            self.send(MoveToFrame(frame, self.speed.travel, self.zone.travel))

        self.send(StopWatch())

        return self.send(ReadWatch())