A constraint programming model for the scheduling and workspace layout design of a dual-arm multi-tool assembly robot

The generation of a robot program can be seen as a collection of sub-problems, where many combinations of some of these sub-problems are well studied. The performance of a robot program is strongly conditioned by the location of the tasks. However, the scope of previous methods does not include workspace layout design, likely missing high-quality solutions. In industrial applications, designing robot workspace layout is part of the commissioning. We broaden the scope and show how to model a dual-arm multi-tool robot assembly problem. Our model includes more robot programming sub-problems than previous methods, as well as workspace layout design. We propose a constraint programming formulation in MiniZinc that includes elements from scheduling and routing, extended with variable task locations. We evaluate the model on realistic assembly problems and workspaces, utilizing the dual-arm YuMi robot from ABB Ltd. We also evaluate redundant constraints and various formulations for avoiding arm-to-arm collisions. The best model variant quickly finds high-quality solutions for all problem instances. This demonstrates the potential of our approach as a valuable tool for a robot programmer.


Introduction
Robots are ubiquitous, with many areas of use. Each such area is called an application. An important application is robotic assembly manufacturing. Consumer products are often the result of assembly manufacturing. This means that complex sub-parts, such as cameras and A preliminary version of this paper appeared in the Proceedings of the 17th International Conference on the Integration of Constraint Programming, Artificial Intelligence, and Operations Research (CPAIOR 2020) [47]. Extended author information available on the last page of the article circuit boards, are put together in a manner akin to a 3D puzzle. These products are mainly manufactured by hand, in countries with competitive labor cost.
Recently lightweight industrial robots have been introduced, such as YuMi by ABB Ltd [1] and Sawyer by Rethink Robotics [37]. Many of these robots are designed to take over repetitive and tedious tasks from humans, occupying similar floor area and having similar reach. YuMi in particular caters to small-parts assembly manufacturing [1].
However, robot-based assembly manufacturing is too expensive for many products. The throughput of a robot installation determines the value it creates. The cost is largely determined by the time it takes to deploy the robot, and this often costs significantly more than the robot itself. Deploying industrial robots is a time-consuming, iterative process, and requires trained developers. This incurs cost, and production downtime means loss of revenue. At the same time, production series have become smaller, hence fewer produced items will share the cost.
The initial inspiration for our work came from a real-world installation of a YuMi, where a highly skilled programmer and researcher from ABB spent six weeks to program the robot and to determine where to put equipment in the robot workspace. At deployment, unforeseen obstacles were present in the robot workspace, and large parts of this work needed to be redone, which took another week.
So, while it is important that a robot installation obtain good enough throughput, the incurred cost from deployment time has the greatest impact on the net value of the robot installation. One of the main reasons why deploying a robot takes so much time is that several interconnected problems need to be solved, and there is no prescribed order in which to solve them. For the programming, we know what tasks to perform, but we do not know where to perform them. This is decided by the robot programmer and is called the (A) layout design of the robot workspace. This means deciding where in the robot workspace to put trays for picking components and where to put fixtures for assembly. It also means deciding where to put cameras for detailed arm-to-component calibration, and deciding which camera to use for each individual task.
Robot programming itself can be subdivided into the (B) allocation of tasks to arms and (C) task sequencing. For multiple robot arms, the programmer must schedule all tasks, that is (D) decide their start times in a way that (E) optimizes the throughput. For multiple robot arms, the programmer must also consider the problem of coordinating the arms toward (F) collision avoidance during execution. The need to coordinate arm movements greatly adds to the complexity of the problem. The two-dimensional case is NP-hard [48] and is an active field of research [25]. The workspace layout can be designed given the robot program instead, or vice versa; there is no prescribed order in which to solve these two sub-problems. The key insight here is that all sub-problems (A) to (F) are tightly interconnected.
An important aspect of assembly manufacturing is its cyclic nature: a robot installation typically produces the same assembly repeatedly. Thus, it makes most sense to minimize the time span between the start time of any task in one assembly and the start time of the same task in the subsequent assembly. This is called the period of the recurring schedule. Scheduling using the period as the objective function is called (E) cyclic scheduling. Scheduling using the makespan as the objective function, i.e., optimizing the completion time of a single run, typically leads to a longer period. Cyclic scheduling has been handled extensively over the years, both for the general case [16,18,24,39,46] and for robotics applications [4,7,8,15,20,50]. In our work, we minimize the period, allowing one robot arm to finish the last tasks of one assembly, while the other arm starts working on its first tasks of the subsequent assembly.
Each task, such as picking a component, is itself a small robot program. Each such program is currently generated by a human. However, for the level of abstraction of our and related work, each task can be abstracted as its start time, duration, and work location. Similarly, travel between task locations is a small robot program, which, in our and most of the related work, is abstracted as a constraint on the travel time between two consecutive tasks. Such free-space motion can be generated automatically; however, one should note that the computational complexity of single-arm and multi-arm motion planning [23,26,44] is exponential in the total number of joints of the arms. As the arms can be seen as a composite robot [12], motionplanning methods that search in this composite space allow us to achieve global properties like completeness and optimality, at the cost of high computational overhead. Efficient samplingbased and quadratic-optimization-based methods [30,40] have been developed to mitigate the problem of intractability. However, solving the motion-planning problem for every candidate program is not tractable. This makes it necessary to decouple the motion-planning problems for each arm [12] and precompute the motion for every pair of candidate locations. By also partitioning the workspace into areas, their occupation can be scheduled as a part of the overall problem. We note that such precomputed motion might report arm collisions in situations where collisions can be avoided, thus sacrificing some feasible solutions for tractability. We illustrate the components of a robot program as a Venn diagram in Fig. 1.
The artificial intelligence (AI) community has a long history of addressing model-based robot programming, such as for automated ground vehicles using planning [11] and firstorder logic [5] in order to achieve (C). AI for robotics is a long-standing topic [36], and robotics is an active part of the AI community [35]. Task planning, including temporal planning, is a field of active research [17], and the sub-field of integrated task and motion planning [14,19,22,27,32,33,45] addresses (C) while also generating the motion plans between tasks. Most work addresses single arms, while a recent CP approach includes a second arm [2], thus addressing (B), (D), and (F), whereas (C) was given. Another recent work [31] includes multiple arms and addresses (B), (C), (D), and (F), while optimizing for makespan instead of period as in (E). That work also presents a CP model, however it reports that the implementation did not work well due to the large number of collision constraints, in the form of blocking constraints [29].
In our work, we remove some of the complexity of the multi-arm motion-planning problem by partitioning the workspace into zones and scheduling their use by the arms. In this way we model zones as unary resources, shared by all robots and tasks. This models the same thing as blocking constraints [29,31], which invoke a non-overlap constraint for each pair of tasks, conditioned on the robots performing those tasks and their locations. We also present a second method that assign parts of the workspace to arms. A similar intuition is used across other applications, including industrial manufacturing [40], space exploration [49], collaborative manipulation [10,41], and assembly [43]. All of these papers address multiple problems, including task allocation (B), collision avoidance (F), and motion planning. To the best of our knowledge, no work approaches (B), (C), (D), (E), and (F) in unison, and no work addresses (A).
The main contribution of our work is a unified CP-based optimization model spanning all aspects (A) to (F) of the robot deployment process, but not motion planning. The model is given in Section 3 and contains elements of scheduling, routing, and spatial separation. The efficiency of a robot program and layout design will in turn depend on other choices made by the programmer as well as on outside factors. Therefore the installation of an assembly robot will still be iterative work. So we will need to solve many variations of this problem during a robot installation. Hence we need to obtain solutions of a satisfactory quality robustly and quickly. Fig. 1 Installing an assembly robot includes programming the robot as well as designing its workspace layout. Since the production throughput depends on the interaction of the two, we include both in our model. However, we assume that arm motion plans and task implementation are given: we call these motion planning and execution We here continue the work of two MSc thesis projects [9,21] supervised by the first author, by addressing a more general problem. We extend our preliminary work [47]: we improve the space complexity of its arm-to-arm collision avoidance method from quadratic to linear and present an alternative to that method; we make fewer assumptions about underlying robot motion; we conduct a much more extensive evaluation; and we model a cyclic robot schedule for continuous production. We present the following contributions: -the first optimization-based model integrating (A) workspace layout design, (B) task allocation, (C) task sequencing, (D) task scheduling, (E) cyclic scheduling, and (F) collision avoidance for a dual-arm robot, to the best of our knowledge: the model has features from routing and scheduling, with variable task locations and travel times that depend on the locations and the performing robot arm; -two effective methods for avoiding arm-to-arm collisions as part of robot program generation: a generic method relies on partitioning the workspace into zones, which the scheduling part of the model treats as bookable resources; a specialized method is based on a static division of the workspace into two exclusive-use sides; -an evaluation showing that the model quickly delivers good solutions: the evaluation is performed on problem instances of realistic size, as well as of sizes that exceed the number of tasks of real-world problem instances, with different granularity of the partitioning of the workspace into bookable zones; we also evaluate the different collision avoidance methods, as well as the impact of redundant constraints on solution times.
The rest of the article is organized as follows. In Section 2, we present the dual-arm robot, the assembly cell, and the assembly robot programming problem. In Section 3, we introduce our CP model capturing this problem, with two methods for avoiding arm-to-arm collisions. In Section 4, we describe the experiments we have conducted. We end the article by concluding on the findings in Section 6. Some notation and data are defined in two appendices: the definitions of the used global constraints and search annotations (see Appendix A); and the data that define a problem instance, which depend on the characteristics of the robot arms, the workspace, and the application (see Appendix B).

Problem description
We present the robot assembly application we have captured in our model, and where subproblems (A) to (F) come in. We outline assembly manufacturing in Section 2.1. We present the YuMi robot in Section 2.2, introduce the concept of fixture in Section 2.3, the specifics of a workspace in Section 2.4, assembly robot programming in Section 2.5, and collision avoidance in Section 2.6.

Assembly manufacturing
Assembly manufacturing is a type of production where several components are combined into an assembled product. This is very common when producing consumer electronics. Components could be of any kind such as electronic boards, motors, and sensors. Each component is presented on a component tray. Such a tray holds multiple copies of its component type, and only of that component type, as provided by the component manufacturer. The products are assembled by adding one component at a time in a prescribed order. Until all components have been added to the assembly, we call it a sub-assembly. When the assembly is finished, it is placed on an output tray.

The YuMi robot
For this work, we assume that we have a YuMi robot [1]. The robot, shown on the left in Fig. 2, is built to resemble a human in size and appearance, so we refer to its parts as arm, hand, elbow, and torso. Each hand, shown on the right in Fig. 2, features one gripper tool and two suction cup tools. These tools are designed to carry out the tasks of assembling a product. Two important tasks are picking and placing objects, where an object is a component, an assembly, or a sub-assembly. A gripper picks an object with its two parallel fingers. A suction cup picks an object by adhering to a flat surface of the object. The robot programmer chooses which tool to use for each object. When holding an object with a gripper, the position and orientation, or pose, of  [1]. A video demonstrating the robot can be found at: https://youtu.be/wh3zv5kY0k4. Right: A YuMi robot hand with one gripper and two suction cups the object are sufficiently well known to place it onto the growing assembly. This is not true for a suction cup; however, the object pose can be determined by processing an image of the object held by the tool. Thus, when using a suction cup, such a calibrating camera task must be performed at the focal point of a camera before placing the object. This is the third type of task of assembly manufacturing.
Each tool can hold one object, independently of the other tools. This means that one robot hand can hold up to three objects simultaneously. This fact is often used by experienced programmers in order to improve throughput.

Fixtures
In assembly manufacturing, one repeatedly adds one component at a time to the current sub-assembly. Humans would typically use both hands. Similarly, we would like to utilize the two robot arms' ability to work in parallel. While fixating the sub-assembly and adding components using one robot arm, the other arm is free to work on other tasks. Assigning tasks to arms is sub-problem (B) task allocation.
The fixation is done by using a device to hold the growing sub-assembly. Such a device is called a fixture and is firmly attached at its designated location. After the first component has been mounted on the fixture, we continue adding the other components in the prescribed order. Every placement of a component onto a sub-assembly is followed by applying force to ensure proper incorporation of the component: this is called a press task and is the fourth and last type of task in assembly manufacturing.
On a given fixture, there could be intermediate tasks that are not press tasks, such as peeling off protective tape. There might be components that do not need a press task. Additional tasks might be required between picking and placing for some components, such as blowing an air gun. However, our work is restricted to cases where the order is prescribed, each component type is picked exactly once, and components do not need any tasks other than the outlined standard ones: pick, (camera), place, and press. By the way assembly products are designed, we can use one fixture to finish an entire assembly, and this is probably how most humans would do it. However, due to the hazard of arm-to-arm collisions, only one robot hand can work at a fixture at any time. Typically, it is possible to divide the assembly into two sub-assemblies, to be assembled at different fixtures. Subsequently, one sub-assembly is then picked up and merged onto the other subassembly. This adds three new tasks to perform: picking the first sub-assembly, placing it onto the other sub-assembly, and finally pressing the entire assembly in order to ensure a proper incorporation. When having two robot arms, it is typically more efficient to have two fixtures in order to allow parallel work. More than two fixtures for a dual-arm robot can only incur overhead, because there would be no extra parallelism and every new fixture increases the need to move sub-assemblies. Consequently, in this work, we use two fixtures, and each relevant task is preassigned to one of the two. Note that the location of the fixtures is subject to optimization: sub-problem (A) workspace layout design.

The assembly cell
In industrial robotics, the robot workspace is the space used by one or more robot arms and the equipment required to assemble a product; if a workspace is used for assembly manufacturing, then it is called an assembly cell.
An example of a real-world assembly cell is shown in Fig. 3. The fixtures and horizontal trays are on the bottom-most horizontal plane, called the table. Each component tray is paired with a camera facing it, for calibration and in order to keep track of component availability. The focal point of each camera is located between the camera and its tray. Additional cameras can be mounted if there is a need to cover additional locations. Typically, there is a single output at a given location. Without loss of generality, we assume it to be on the right-hand side of the robot; it is not shown in the figure.
Related to sub-problem (A) layout design, we address the decision of where best to put component trays and fixtures, which generally can be located anywhere, as long as they can be reached, even mounted on walls. Typically, the fixtures are located in front of the robot, as in Fig. 3, or possibly on the small horizontal surface in the middle behind the shoulders of the robot arms. Towards optimizing the layout, we let the number of candidate tray locations be greater than the number of component trays to position, and add the horizontal surface on top of the robot as a third candidate fixture location.

Assembly robot programming
The software controlling a robot with its cameras is called a robot program. It consists of two sequences of tasks, one per arm, and of synchronization between these sequences. Each arm performs a task, moves to the next task, possibly waits for the other arm to move away, before repeating the sequence. Deciding on an order is sub-problem (C) task sequencing. The decision at which time point to perform each task is sub-problem (D) task scheduling. When the robot should output multiple copies of the same assembly product, this is sub-problem (E) cyclic scheduling.
Each task is itself a program, provided by the robot programmer. However, for our purposes, it suffices to know the duration of each task. Similarly, for arm movements, it suffices to know the travel time between any two locations.

Arm-to-Arm collision avoidance
We must avoid arm-to-arm collisions: this is sub-problem (F). A robot programmer often spends considerable effort to keep robot arms apart. We assume there is a small (implicit) Fig. 3 An assembly cell with an ABB YuMi, two fixtures, five component trays, and five cameras, one per tray volume around each candidate location, dedicated to the arm working at that location. When using zone resources as collision avoidance method (see below), each such volume corresponds to a zone. However, when using a static division of the workspace as collision avoidance method (see below), leaving the location upon completion of the task is an assumption for this approach to be viable and is part of the task implementation: this is included in the task duration. Collision avoidance is especially important for fixture tasks, since multiple tasks occur at the same location. We now present these two methods, with their different benefits and drawbacks.

Zone-resource collision avoidance
The zone-resource method for collision avoidance does not require any additional assumptions on tasks and travel. The robot programmer, or a collision detection algorithm, defines zones and determines, for any arm movement between two locations, which of these zones are entered and exited. The approach then considers these zones as resources that only one arm can utilize at any given time. In Fig. 4 we show a robot and a cuboid-shaped zone, as in the experiments. The details can be found in Section 3.9.1.

Static collision avoidance
The static method for collision avoidance, described in Section 3.9.2, relies on the following assumptions on tasks and travel: -Parallel work: Any task at one fixture, performed by one arm, does not interfere with any task at the other fixture, performed by the other arm.  This method requires the robot programmer to rank the non-fixture locations from left to right. By partitioning those locations into a left part and a right part, a static division of the workspace is achieved. In Fig. 5 we show a robot and a dividing plane, which is not given up front but part of the solution, where every non-fixture location to the left (right) side of this plane can only be visited by the left (right) arm.

Model
Our CP model captures the problem of continuous dual-arm robot assembly manufacturing. It features variable task locations, thus optimizing component-tray layout, fixture layout, and which camera to use for each camera task. It is a scheduling model integrated with a pickup and delivery vehicle routing model, augmented with constraints to avoid collisions of the arms. The routing part of the model is implemented using a Giant-Tour formulation [13]: while all tasks form a Hamiltonian cycle, this cycle consists of the two arms' task sequences, connected at the start and end by dummy tasks. This is done by forcing the start dummy task of each arm to be the successor of the other arm's end dummy task.
Since the problem is the continuous production of assemblies, we repeat the set of tasks perpetually using the same schedule. The objective to be minimized is the completion time of one assembly during continuous production, called the period of the schedule. Therefore the locations of the dummy start and end tasks are constrained in such a way that both arms travel back to their initial locations at the end of the schedule. Thus we obtain the correct time and location for the last task of each arm.
In the following subsections, we introduce the main simplifications we have made (Section 3.1); we introduce notation for constants and sets (Section 3.2); we introduce the CP model's core decision variables (Section 3.3); we give the details of a Giant Tour formulation that captures task order (Section 3.4); we present constraints on time variables (Section 3.5), for cyclic scheduling (Section 3.6), on tool capacity and load (Section 3.7), on locations (Section 3.8), and for avoiding arm-to-arm collisions (Section 3.9). We then give a dual Giant Tour representation (Section 3.10) and present some redundant constraints that help reduce the search effort (Section 3.11). Finally, we describe our search strategy (Section 3.12). The global constraints and search annotations used in this section are defined in Appendix A.

Simplifications
In our model, we have made a few noteworthy simplifications. These are design choices aimed at making the problem easier to solve, but which might remove solutions of higher quality: -We pre-compute a unique path between every pair of locations, for each arm. Alternative pre-computed paths or dynamic path planning could increase solution quality. This is discussed as future work (Section 5.2). -The size and shape of zones are user-defined. In the experiments, the zones are shaped as tall cuboids, which implies that the two arms cannot coexist in the same zone even if they are laterally separated. This means that we are over-conservative with regards to collisions in the experiments.

Instance data
In the given problem instance, let T be the number of tasks, L the number of locations, W the number of discrete time points, and Z the number of workspace zones in the case of zone-resource collision avoidance. In addition to the actual tasks, the model uses four dummy tasks: StartLeftArm = T − 4 and EndLeftArm = T − 2 are the dummy start and end tasks of the left arm, respectively, while StartRightArm = T − 3 and EndRightArm = T − 1 are the dummy start and end tasks of the right arm, respectively. We model the suction cups of a particular arm as one tool, capable of holding two objects, because there is never any need to distinguish its two suction cups for our purposes. The load of the suction cup or gripper of a particular arm is the number of objects it currently holds. We introduce the following sets of values: It is useful to partition the task and location sets: -T start = {StartLeftArm, StartRightArm}, the dummy start tasks -T end = {EndLeftArm, EndRightArm}, the dummy end tasks -T Actual = T \ T start \ T end , the actual tasks -T TrayPick ⊂ T, the set of actual tasks that occur at some component tray -T Camera ⊂ T, the set of camera tasks -T Fixture1 ⊂ T, the set of actual tasks that occur at fixture 1 -T Fixture2 ⊂ T, the set of actual tasks that occur at fixture 2 -T Output ⊂ T, the singleton set of actual tasks that occur at the output tray -L TrayLocation ⊂ L, the set of candidate component-tray locations -L CameraLocation ⊂ L, the set of candidate focal-point locations for camera tasks -L FixtureLocation ⊂ L, the set of candidate fixture locations -L OutputLocation ⊂ L, the singleton set of the given output-tray location Additional instance data, mentioned in the following subsections, is compiled in Appendix B. Some straightforward aspects of the model are omitted for brevity (e.g., sequencing constraints), but the complete set is provided in that appendix.

Core decision variables
Below are the core decision variables. We introduce additional variables for collision avoidance later. For each task t ∈ T, we have the decision variables: - . In this way, we model an unbroken chain of time intervals for each arm, thus keeping track of the arm over time. This is used in Section 3.9.1 when preventing arm-to-arm collisions.
The following variables are used to define the cost function, period, which is to be minimized: makespan ∈ W, the maximum arrival[t] for t ∈ T end period ∈ W, the time span between the start time of any task of one assembly and the start time of the same task of the subsequent assembly: this equals the minimum arrival[t] for t ∈ T end -cycle_overlap ∈ W, the time span between one arm starting work on an assembly and the other arm starting work on the same assembly: this equals the maximum arrival [t] for t ∈ T start , and also equals the difference between makespan and period.   The time variables of each task t. Note that there are neither gaps between the intervals for a task, nor gaps between tasks

Giant-tour representation
At the heart of the model is the concept of route. We refer to an arm route as a sequence of tasks performed by that arm, beginning with its dummy start task and finishing with its dummy end task.
We have chosen to represent a Giant-Tour formulation [13] as a successor list t, succ [t], succ[succ [t]], . . . , t, for some first task t. The list starts with the dummy StartLef-tArm, followed by the left arm's route, followed by the dummy EndLeftArm, then the dummy StartRightArm, followed by the right arm's route, followed by the dummy EndRightArm, and finally by StartLeftArm: see Fig. 6. We constrain each arm's dummy tasks to take the location of its first task. In this way, each robot arm returns to its original location. Thus the cyclic schedule continues. Of course, the samearm must be used within each arm route. We have the following constraints, which are relevant for sub-problems (A) layout design, (B) task allocation, and (C) task sequencing: (1)

Time constraints
We now come to the constraints that are relevant for sub-problem (D) task scheduling. As the location of each task is a variable, the travel times are defined between locations, not tasks. All travel times are dependent on the arm and direction of travel (such as upward vs downward). The matrices W D of task durations and W L of travel times are provided by simulation, other algorithms, manual estimation, or real-world measurements. We define travel_time[t] and duration[t] of each task t as follows: The following constraint relates the time variables of each actual task (see Fig. 7) and connects them with the successor variables: The following constraint defines the time variables of each dummy task, and requires at least one arm to start at time zero: Precedences at fixtures are encoded as a set of task sequences O F (see Appendix B). Similarly, precedences among tasks using the gripper (the suction cup) are encoded as a set of task sequences O G (O S ). This is typically a pick task and a place task, and possibly an intermediate task such as a camera task. They are enforced by the following constraints: Note that the same arm for t and t is required in Constraint (6), which is why Constraint (5) is on the performing phase of the tasks whereas Constraint (6) is on the whole time span of activity of the tasks; see Fig. 7. As mentioned in Section 2.6, arms leave locations as part of their task duties. This means that at the end time of any fixture task t, end[t], the performing robot arm has left the fixture zone. This is of course a bit on the conservative side for cases when the same arm performs the subsequent task on that fixture. Constraint (5) ensures that arms do not collide on a fixture; see the continuation in Section 3.9.2.

Cyclic scheduling
Since our target is continuous production, we want to minimize not the finish time for a single assembly (makespan), but the cycle time ( period): this is sub-problem (E) -please refer to Section 2.5. These constraints define the period, which is the cost function, but are also required for imposing zone-resource collision avoidance across cycles. See Section 3.9.1 for details. The cyclic scheduling constraint is as follows (see Fig. 8): To guarantee a cyclic schedule with the same period for both arms, we must ensure that cycle_overlap equals not only the time span between the two arms starting work on an assembly, but also the time span between the two arms ending work on an assembly, by adding the constraint: Let f irst(t) (last(t)) denote the first (last) item of a sequence t. Since the two arms can work on the current and subsequent assembly simultaneously we must ensure that each fixture is emptied before it is being used for the subsequent assembly. This is achieved by adding the following constraint, again using instance data O F (see Appendix B):

Tool capacity constraints
Relevant for sub-problem (C) task sequencing, a feasible task sequence must not exceed tool capacities. Also, the gripper must be empty for press tasks. Please refer to Section 2.2 for a description of the YuMi robot and its tools. To this end, we have variables load[t, τ ] for each task t and tool τ ∈ H. They are linked in the constraint below. Also, the press tasks use the gripper for the pressing; they require the gripper to be empty on arrival: , if task t uses tool τ to pick something, −1, if task t uses tool τ to place something, 0, otherwise , if task t requires tool τ to be empty, 1, if tool τ is the gripper, 2, if tool τ is the suction cup (10)

Location constraints
Variable locations are a means to optimize the layout for best performance: this is subproblem (A) layout design. Whereas a typical routing problem has fixed locations, we can perform tasks on the same arm close to each other in order to minimize travel time, and separate apart tasks performed on different arms in order to avoid collisions. We have several types of tasks, each with a dedicated set of candidate locations. Refer to Sections 2.3 and 2.4 for a description of fixtures and the assembly cell, respectively. No location can accommodate more than one task at a time. This assumption is not strictly necessary for all assembly problems, but is most often the case. We have the following constraints, which constrain the domains of the location variables: We have other location constraints on two types of tasks. First, recall that we assume that each component is picked by exactly one task, and that there is only room for one component tray at each candidate tray location: Second, each fixture task must occur on its dedicated fixture, while the two fixtures themselves must be at different locations: This completes our description of the core model, i.e., Constraints (1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13), which covers all the essential constraints, except collision avoidance, which is the subject of the next subsection.

Arm-to-Arm collision avoidance constraints
We present two methods for sub-problem (F) collision avoidance. This sub-problem is described in Section 2.6. The first method is new compared to our previous paper [47]: it is a zone-resource method, where each arm books a zone each time it occupies it. The second method enforces a static division of the workspace, and improves on its version in [47] by needing a linear instead of quadratic number of constraints.

Zone-resource collision avoidance
The idea is to avoid collisions by constraining the arms not to be at the same place at the same time. To model the spatial whereabouts of the arms, we introduce a set B of disjoint zones, where a zone is an instance-specific volume of space in the robot workspace. We treat every zone as a non-consumable unary resource. This abstraction prevents collisions in any given zone; thus we require the zones to partition the reachable workspace. This abstraction also requires us to keep track of the robot arms at all times. We can do that because the tasks of each arm form an unbroken chain of the three kinds of time intervals [a, b) in Fig. 7. In order for a task t to use a zone z during one of those time intervals, it must book z, which prevents z from being used by any other task during that time interval. For that purpose, we introduce the following variables:

whether task t books zone z when arm[t] is waiting at loc[t] per f orm Z B[t, z] ∈ {0, 1}, whether task t books zone z when arm[t] is performing at loc[t] travel Z B ∈ {0, 1}, whether task t books zone z when arm[t] is traveling from loc[t] to loc[succ[t]]
These variables are constrained as follows, using the zone data defined in Appendix B:

wait Z B[t, z] = Z B Wait (arm[t], loc[t], z), per f orm Z B[t, z] = Z B Perform (arm[t], loc[t], z), travel Z B[t, z] = Z B Travel (arm[t], loc[t], loc[succ[t]], z)∀t
In order to prevent collisions, imagine for zone z the set of time intervals during which some task books z. If these sets are non-overlapping for all zones, then no collision can occur. With cyclic work schedules, we also need to take into account collisions across cycles. Thus, the sets of relevant time intervals are formed by taking all time intervals [a, b) as well as [a + period, b + period) for all active tasks. The non-overlapping interval view is encoded by constraints (15) and (16) These alternatives will be raced against each other in the evaluation.

Static collision avoidance
The idea is to allow access to both fixtures by both arms, but to allow access to non-fixture locations by one arm only, to be decided for each such location, as described below. Collisions at fixture locations are already avoided by Constraint (5). This approach may imply that solutions are sub-optimal compared to the previous collision avoidance method, but will be shown in Section 4.2 to be much faster. Each non-fixture location is pre-assigned a relative position on the left to right dimension of the workspace, as encoded in the function P L , defined in Appendix B. We introduce a decision variable p mid to define the rightmost non-fixture location of the left arm. All tasks performed by the left arm are required to be performed at or to the left of p mid . Similarly, all tasks performed by the right arm need to be performed strictly to the right of p mid . Also, while arms perform at, or travel to, non-fixture locations, they may pass fixture locations. To avoid such collision hazards, we must constrain how far right the left arm can move, and vice versa, using the quantities P L min and P L max : Thanks to an anonymous reviewer of our earlier paper [47], we need only a linear number of constraints on p mid , instead of the quadratic number of constraints in that paper.

Dual giant-tour representation
For improved search and redundant constraints (see Section 3.11), we add a dual representation of the Giant Tour. We define the value set and variables: -P = {0, . . . , T − 1}, the set of positions in the Giant Tour task[ p] ∈ T, the task at position p ∈ P in the Giant Tour Even though P contains the same integers as T, they enumerate different things. We arbitrarily choose the dummy start task of the left arm to be the task at the first position of the Giant Tour; thus the dummy end task of the right arm is the task at its last position, by line 3 of Constraint (1). To link succ and task, we have:

Redundant constraints
We can significantly improve the performance by introducing a number of redundant constraints, that is constraints that are implied by constraints in the core model and that do not remove solutions. We now describe these redundant constraints, which use task precedence data, defined in Appendix B.

Order-enforcing vonstraints
The following constraint is redundant with Constraint (5). It enforces a pairwise order on the Grand Tour for fixture tasks that are performed by the same arm. If the two tasks are performed by different arms, then their order on the Grand Tour cannot be enforced, and the constraint is effectively disabled, relying on Constraint (5) for the fixture schedule. The constrained term (i, j) implements this mechanism: The following constraint is redundant with Constraint (6). It enforces a Grand-Tour order on pick-(camera-)place sequences:

Regular expressions
We constrain the array task to be recognized by some regular expressions, utilizing the regular constraint. The resulting constraints are redundant with Constraints (5, 6, 10). Like in Constraint (20), we use O F to post constraints that are redundant with Constraint (5): they enforce an order on the tasks at the fixtures. Similarly, like in Constraint (21), we use O G and O S to post constraints that are redundant with Constraint (6): they enforce an order on pick-(camera-)place sequences.
We also post constraints that are redundant with Constraints (10): they enforce that tool capacities are never exceeded. Each robot hand has two suction cups and one gripper, which results in different regular expressions for the two tool types. Also, recall that press tasks require the gripper to be empty on arrival.
To sum up, for various regular expressions σ , we have redundant constraints of the form: For the sake of brevity, we do not present the regular expressions themselves.

Cumulative constraints
The following constraints are redundant with Constraint (3) and provide a global view of the time variables, aimed at improving propagation: These constraints express that, at any time point, (i) at most two tasks can be active, (ii) at most one task can be active for the left arm, and (iii) at most one task can be active for the right arm.

Search strategy
We perform the following branching decisions in order. The annotations are defined in Appendix A.2: 1. dom_w_deg(arm), assigning each variable a random value from its domain. 2. dom_w_deg(loc), assigning each variable its smallest domain value first. 3. input_order(task), assigning each variable its smallest domain value first. 4. smallest(arrival), bisecting the variable domains and excluding the upper half first.
The search is restarted from scratch according to the schedule given by restart_luby(100).

Evaluation
We have implemented our model of Section 3 in the high-level modeling language MiniZinc [34]. We now evaluate it by using a set of problem instances ranging from realistic to large. 1 As the model has several alternative constraints ensuring collision-free schedules, we compare them. We also evaluate the benefit that the redundant constraints bring.
All instances are solved using three threads, using the Gecode 6.1.1 Flat-Zinc solver with the default MiniZinc to FlatZinc compilation of Mini-Zinc 2.4.2, on an Intel Core i7-4600 2.1 GHz CPU. We use a timeout of 2 minutes and each instance is run 5 times, each with a unique random seed. Unless noted otherwise, we report the median performance of those 5 runs.
We first describe the problem instances (Section 4.1) for which we then conduct experiments over the model variants (Section 4.2).

Problem instances
We describe the generation of the problem data related to the assembly instance (Section 4.1.1) and workspace instance (Section 4.1.2).

Assembly instances
The typical assembly problem involves 3 to 5 components. To evaluate the model, we consider 4 to 10 components. For each of these 7 numbers of components, we generate 4 assembly instances: one where all components are handled with the gripper, one where all components are handled with suction cups, and two where half of the components are handled with suction cups and the other half with the gripper. Half the components are to be assembled at each fixture. The finished sub-assembly of one fixture is picked and placed on top of the subassembly of the other fixture; no further sub-assemblies are picked and placed. We include a press task after each place task. Also, we include a camera task after each suction-cup pick and before the corresponding placing of the object. Moving a sub-assembly from one fixture to the next is always done using the gripper. The duration for each task and arm is determined by using a template value for the task type, estimated by experienced robot programmers and randomly perturbed by up to ±25%. This results in 7 · 4 = 28 assembly instances.

Workspace instances
For fixtures, we have three candidate locations (see Fig. 9): two directly in front of the robot torso on the table, and a third at the center of the flat surface on top of the robot.
The trays are, in the real world, either at a small fixed number of locations in a standardized assembly cell, or freely positioned by the robot programmer within the reach of the robot arms. A grid is a proxy for both scenarios, as sparse grid points emulate the first scenario and dense grid points emulate the latter.
We distribute candidate tray locations within a grid in a horizontal x, y-plane. Trays are typically quite large and there is only room for a few of them. We consider workspaces with a realistic number of candidate tray locations, and also some workspaces with a larger number of candidate tray locations, in order to demonstrate that the model can handle this with reasonable performance. To do this, we generate workspace layouts with candidate tray locations on an n × m grid, with the YuMi robot along one edge of the grid. For our experiments, we consider the use of a 3 × 3-grid, a 3 × 4-grid, a 5 × 5-grid, and a 7 × 7grid. This results in 4 workspace instances, where each grid cell is a candidate tray location, thereby forming L TrayLocation .
By default, a tray is situated at table level. However, if a grid cell is out of reach at table level for both arms, then an elevated tray is considered at that grid cell, emulating a slanted tray as seen in Fig. 3. We then apply a data filtering step where a candidate tray location is removed from L TrayLocation if it overlaps with a candidate fixture location or is out of reach of both robot arms even if elevated. This results in workspaces with 8, 12, 21, and 41 candidate tray locations respectively. This means that our two assembly instances with 9 or 10 components are trivially unsatisfiable for the smallest workspace: the resulting problem instances are removed when running the experiments.
Candidate camera locations are generated similarly to the candidate tray locations: we introduce one per grid cell, followed by a data filtering step. The only difference is that camera focal points are slightly above the candidate tray locations.
A collision-avoiding path planner is used to generate paths. We implemented a non-optimal path planner that ensures that the elbows point outward. It computes a path and traversed zones in around 0.02 seconds. This results in a computation time per arm of 4 s, 9 s, 18 s, and 1 min respectively for the four workspaces.
Travel times are in turn approximated using the distance for the robot hand to travel and arm-speed estimates, obtained by simulation.
For zone-resource collision avoidance (see Section 2.6.1), we introduce one zone per grid cell. Each zone is a polyhedron that extends infinitely in the vertical direction, and whose projection onto the horizontal plane equals the grid cell. We compute the zones that are booked when an arm is waiting at a location, so as to define the matrix Z B Wait (see Appendix B). Similarly, we compute the zones that are booked when an arm is performing a task at a location or traveling between locations, so as to define the matrices Z B Perform and Z B Travel (see Appendix B).
For static collision avoidance (see Section 2.6.2), we compare every non-fixture location with every other such location in order to evaluate whether the first location is to the left or right of the second location, or neither, We also check for the left arm how far right it can travel without blocking any fixture location, and vice-versa for the right arm: this defines the values P L min and P L max (see Appendix B). ImpCu-ZoneCumul (1-13, 14, 15, 23) Recall that the workspace with a 3 × 3-grid results in 8 candidate tray locations after the data filtering above: since 2 of them cannot be reached without blocking some fixture, only 6 candidate tray locations are available when using static collision avoidance. This means that our two assembly instances with 7 or 8 components are then also unsatisfiable for this workspace. Instead of removing the resulting problem instances, we consider them as failures when analyzing the results, because we are interested in how much the solution quality is impaired by using static instead of zone-resource collision avoidance.
This methodology results in problem instances with T comprising 17 to 45 tasks, L comprising 20 to 86 locations, and B comprising 10 to 45 zones. Using 10 discrete time steps per second and a trivial upper bound, W comprises 2,500 to 7,500 discrete time steps. The upper bound of W is calculated by assuming that each arm performs all tasks it can perform, and uses the longest path possible from every task to the next. The longest possible path from a task is the longest path from any reachable location of said task to any other task location. Finally, we use the maximum time for any arm as the value W . 2

Experiments
Using the 28 assembly instances and 4 workspace instances described above, we get a test suite of 28 · 4 = 112 problem instances, of which 2 · 4 = 8 are trivially unsatisfiable due to too few candidate tray locations, leaving us with 104 problem instances.
In Table 1, we list the model variants that we evaluate: they differ in the collision-avoidance method to use, and which redundant constraints to include.
We summarize model quality by using cactus plots [3], which are best viewed in color. The y axis shows the normalized period. We normalize with respect to the best period found for that problem instance by any model variant, making 1.0 the smallest possible period. In this way, we put all problem instances on the same scale. The x axis indicates the number of instances having a period less than or equal to the threshold of the y axis. For example, a curve crossing x = 10, y = 1.3 means that the corresponding model yields solutions with at most 1.3 times the period of the best approach for 10 of the problem instances. Note that for plots showing median solution cost, we still normalize with respect to the best period found.
Thus: the lower a curve, the better. A line y = 1.0 for all x is an oracle.

Fig. 10 Evaluating collision-avoidance model variants
Evaluating collision-avoidance variants The static collision-avoidance method removes another 2 candidate tray locations for the smallest grid since they cannot be reached without blocking some fixtures. Thus another 2 · 4 = 8 otherwise satisfiable assembly-workspace combinations become unsatisfiable, leaving us with 104 − 8 = 96 satisfiable problem instances. The order-enforcing Constraints (20,21) are included, because otherwise too many problem instances would time out. As can be seen in Fig. 10, a static division of the workspace yields, as expected, the best performance of the problem instances it finds solutions for. The three alternatives of the zone-resource method have very similar performance, but using cumulative (see Constraints (15)) solves all but two problem instances, while the other two fail on three problem instances each, which corresponds to less than 2% and 3% of the problem instances respectively Evaluating redundant constraints with static collision avoidance It is evident from Fig. 11 that the redundant constraints enforcing an order on the sequence of tasks give the best results, Fig. 11 Evaluating redundant constraints using static collision avoidance in terms of both quality and the number of instances solved. However, adding redundant cumulative constraints on the time variables (see Constraints (23)) worsens the performance compared to the core model and we therefore recommend not to add them. Figure 12 paints a picture similar to Fig. 11, with the same ranking of the model variants. However, the number of solved instances differs more between the better and the worse model variants.

Evaluating redundant constraints with zone-resource collision avoidance
From the two latter experiments, it is clear that extending the core model with the redundant Constraints (20,21) gives a significant performance boost.

Robustness
To evaluate robustness, we present in Table 2 the rate of success of each model variant, i.e., the percentage of runs that led to a solution. We find that ImpVC-ZoneCumul has the highest rate of success. It is worth noting that the only instances that ImpVC-Static and ImpReg-Static are unable to solve are the ones that are unsatisfiable due to the more conservative, static collision avoidance.

Longer timeouts
We ran the same experiments with a 4-minute timeout. However, an improvement to solution quality was often not achieved and was rarely more than 0.1%. We also conducted experiments with a 30-minute timeout by using the best model variant for each collision-avoidance method, namely ImpVC-ZoneCumul and ImpVC-Static. The gains were greater, but not proportional to the additional effort. The convergence of the normalized median cost for the respective model variant is illustrated in Figs. 13 and 14. The plots show the results aggregated by number of components. For example, in Fig. 13, the curve "7 components" crosses the coordinates (1, 1.3), which means that after one minute, the mean normalized cost of the instances with 7 components is 1.3. For all instances, we assume a normalized cost of 3 initially, before any solution has been found. For both models, we observe good convergence toward the best solution. The convergence is faster for ImpVC-Static.

Scalability
The tray granularity has physical meaning. A smaller tray size than in our experiments is not meaningful in practice, as the trays for the 7 × 7 grid workspace are 9 × 19 Fig. 12 Evaluating redundant constraints using zone-resource collision avoidance cm, which is already much smaller than current industry standards. The evaluated problem instances are all industry-size, or beyond. However, in order to truly test our model we scaled up the number of tasks 4-fold, until we pick one component per tray location of the 7 × 7-grid workspace, that is 41 components. The largest instance has 169 tasks. We ran each instance until the first solution is found. We used a 30-minute timeout. The best model variant for each collision-avoidance method was used, namely ImpVC-ZoneCumul and ImpVC-Static. As seen in Fig. 15, for every problem instance, at least three out of the five runs found a solution.

Spatial distribution of locations in solutions
For the experiments with longer timeouts, as well as the experiments to test scalability, we analyzed the statistics of the layout of the solutions. The locations within the solutions reported at timeout are not symmetrically distributed as an artefact of our location numbering and our value selection heuristic for loc [t] variables, given in Section 3.12.

Fig. 13
Tracking normalized solution quality for ImpVC-ZoneCumul median solutions

Model generalizations and future work
Our application is a very prevalent type of robot installation. However, it is merely a specialization of a broader model class, addressing a broad spectrum of robot applications. By utilizing the versatility of CP it is straightforward to apply variations to our model, resulting in models for a wide range of other applications. We present some of the possible variations in Section 5.1. Then, we outline avenues for future work in Section 5.2.

Model variations
Without going into details, we present a non-exhaustive list of interesting applications that are easily modeled by using our model as template and applying an atomic variation. Compound variations can then be achieved by simply performing several of these atomic variations: 1. As robot perception becomes more mature we might be able to place objects without precise calibration in the suction-cup tool. In such a scenario we do not need camera tasks and remove them from the model. 2. Some assembly applications have multiple intermediate tasks between the pick and place tasks, such as the airgun described in [47]. These can be with or without internal ordering. We can easily add such tasks to the model, and impose arbitrary combinations of precedence between tasks by employing the same constraints used for our model, but for other variable tuples. 3. Some assembly applications have some flexibility on the ordering of placing components on the fixtures. This can easily be addressed as we can impose arbitrary combinations of precedence constraints between placement tasks by simply using our model. 4. If there is only one robot arm, then this can be modeled by fixing all agent variables to 1, and removing all arm-to-arm collision-avoidance constraints. 5. If there are additional robot arms, then we can add values to the domains of the existing agent variables, two dummy tasks, and another distance matrix. For zone-resource collision avoidance we add the corresponding zone data. The static collision avoidance model would need modification. 6. If there are more robot arms, then we might want to evaluate using more fixtures. This can be achieved by adding one task for picking up from the new fixtures and one task on where the sub-assembly should be placed. The model is easily adapted by defining a new set of tasks T Fixture3 ⊂ T in Section 3.2 and straightforward update of constraints (11) and (13). Similarly, it is straightforward to only use one fixture. 7. As robots can have a maximum load or exert large forces on joints when carrying heavy objects, we can model the maximum weight of carried components by using the same type of capacity constraints as in Section 3.7, but using weight instead of 1 for pick, −1 for place and Cap(t, τ ) depend on robot arm instead of tool. 8. In some applications the same type of component is used more than once for a particular assembly. Such components could then be picked from the same tray. This can be modeled by posting equality constraints on the location variables of such pick tasks, and excluding one of the variables from the all_different constraint (12). 9. There are applications where the component tray or output tray are available in fixed or recurring time intervals. Such trays can be brought by an autonomous ground vehicle (AGV) or a conveyor belt, delivering components in a just-in-time fashion. This model can easily be implemented by adding a constraint on the start and finish time of the task in question.
We can create compound model variations by combining such atomic variations. An interesting robotics application is the emptying of boxes in a fulfillment center, and putting the content into new boxes: this is captured by our model combined with variations 3, 6, and possibly 5.

Future work
Our collision-avoidance methods relies on unique, precomputed paths between locations. In our approach the entire swept volume is booked throughout the travel time of such paths. This makes the model tractable, but quite conservative. There are many potential remedies to this. One avenue for future work is to book zones only for the time span during which they are actually occupied, and how to solve this in an efficient way. Another avenue could be to precompute multiple paths between locations, and assign path as part of the optimization. How to generate such paths to make them useful is an interesting direction.
In general, one would use one of many available algorithms to get collision-free paths, as well as travel times and traversed zones for such paths. There are time-optimal path planners, such as those in the MoveIt package [6]. However, such general planners might take 10 to 100 times the computational time of the planner we used, while most paths will never be part of a robot program. A way to minimize computational overhead could be to delay computations of paths and zone booking for paths until paths are part of a candidate program, akin to an admissible heuristic of A* search [38].
Future work also includes integrating path planning into the model. Also, the conservative nature of our static collision avoidance makes zone-resource collision avoidance much more general and attractive. Therefore, we will examine ways to make it more efficient.
Finally, we could recover from some types of failures without any change to the approach. Such failures would be handled in a feedback loop by changing the input data and re-solving. Examples are a faulty camera or an arm breaking down, which would be removed from the data. A final avenue would be to introduce optional tasks for handling contingencies.

Conclusions
This work presents the first CP-based model integrating (A) workspace layout design, (B) task allocation, (C) task sequencing, (D) task scheduling, optimization for (E) cyclic scheduling, and (F) collision avoidance for a dual-arm robot, to the best of our knowledge. We presented this as a core model containing all necessary constraints, plus two alternative methods for collision avoidance and three redundant constraints that speed up the search. The resource-based collision-avoidance method requires arms to book user-defined zones as non-consumable resources, and can be generalized to scheduling more than two robot arms. The static collision-avoidance method implements a division of the workspace into two sides, but is limited to two arms, is more conservative thus rendering some problem instances unsatisfiable, and requires some additional assumptions. However, when solutions are found, it outperforms the resource-based method, in terms of both solution quality and number of instances solved.
We compared the model with and without redundant constraints, and found that the redundant constraints on the routing part of the model significantly increase the solution quality compared to the core model. Notably, the best choice of redundant constraints increases the number of instances solved from 37.9% to 98.5% for zone-resource collision avoidance. Furthermore, the redundant constraints that use cumulative constraints for the scheduling part of the model actually decrease the performance on both measures compared to the core model.
We performed an extensive evaluation of problem instances by combining assembly instances and workspace instances. The assembly instances are of realistic size, or larger, having 17 to 45 tasks, which exceeds the typical number of tasks for an assembly robot. The workspace instances vary from a few candidate tray locations to a large number of candidate tray locations. We allow fixture locations to be variable, leaving almost all locations available for optimization. The empirical results show that the model delivers solutions within a twominute timeout for almost every problem instance, for both collision-avoidance methods. We also performed longer experiments using the same experiment setting: they gave the same efficacy ordering of the redundant constraints. Using the best choice of redundant constraints, we ran experiments with a very large number of tasks, for the most fine-grained workspace: they indicate that the approach displays an increase of computation time that is exponential in the number of tasks. Even for instances well beyond the typical number of tasks in an industrial application, our approach always finds solutions within 30 minutes.
We also demonstrated that joint solving of all subproblems is more effective than solving subproblems separately.
We emphasize the ability to generalize our CP model beyond our application: other interesting robot applications can be modeled by applying small variations to our model.

Conflicts of interest
The authors have no conflicts of interest to declare that are relevant to the content of this article.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

A.1 Constraint definitions
The article uses the following global constraints; we quote their definitions from the MiniZinc Handbook [42]: -all_different(x) constrains the array of integers x to be all different.

B Additional instance data
We have the following data that encodes precedences: -O G = {t 0 , t 1 , . . . , t N }, set of task sequences t i that determine the order of tasks to be performed by the gripper on the same arm -O S = {t 0 , t 1 , . . . , t N }, set of task sequences t i that determine the order of tasks to be performed by a suction cup on the same arm -O F = {t 1 , t 2 }, two task sequences t f that determine the order of tasks to be performed on the fixture f ∈ {1, 2} Zone-resource based collision avoidance (see Section 2.6.1) utilizes precomputed trajectories and user-defined zones. Each location can overlap multiple zones and the mapping of arm trajectories to entered zones is arm dependent: