Skip to content

About

A ros package to solve robot task allocation problem through optimizer

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ubuntu ROS Python Gurobi License

Task Allocation MILP πŸ€–

This repository uses Mixed-Integer Linear Programming (MILP) optimization algorithm to solve task allocation problems and is implemented as a ROS package.

πŸ“š Table of Contents

πŸ“ Introduction

This project aims to solve task allocation problems using the MILP optimization algorithm. It can run in a ROS environment and provides flexible interfaces for easy integration into other systems.

This package directly supports solving Single-Robot Single-Task (SR-ST) allocation problems. For Multi-Robot Single-Task (MR-ST) scenarios, where a task requires simultaneous execution by multiple robots, you can decompose such tasks into multiple atomic tasks. By representing each required robot as a separate atomic task and enforcing simultaneity constraints among them, the package can indirectly handle MR-ST problems as well.

πŸ“– Mathematical Model

The task allocation problem is formulated as a Mixed-Integer Linear Programming (MILP) model.

Parameters

  • $a_{ij}$: Robot $i$ is able to execute task $j$
  • $A$: Set of tuples $(j, k)$ where tasks $j$ and $k$ must be executed simultaneously
  • $S$: Set of tuples $(j, k)$ where tasks $j$ and $k$ must be executed by the same robot
  • $D$: Set of tuples $(j, k)$ where tasks $j$ and $k$ must be executed by different robots
  • $d_{ij}$: Travel time from the initial position of robot $i$ to task $j$
  • $d_{jk}$: Travel time from task $j$ to task $k$
  • $e_j$: Execution time of task $j$
  • $\text{prec}(j)$: Set of precedent tasks for task $j$

Variables

  • $x_{ij} \in {0,1}$: Robot $i$ executes task $j$
  • $y_{jk} \in {0,1}$: Task $k$ is adjacent to task $j$ ($j \to k$)
  • $z_{jk} \in {0,1}$: Task $j$ is executed earlier than task $k$
  • $t_j$: Start time of task $j$
  • $T_{\max}$: The maximum finish time of all tasks

Objective Function and Constraints

Mathematical Model

This formulation ensures that each task is assigned to exactly one robot while respecting time dependencies, adjacency constraints, and precedence relationships. The goal is to minimize the overall makespan $( T_{\max} )$.

⬇️ Installation

This repo is a ROS package, so you can directly clone it to your own workspace.

  1. Create your workspace:

    mkdir -p your_ws/src
    cd your_ws
    catkin_make
  2. Add this package:

    cd src
    git clone https://github.com/TCXM/task_alloc_milp.git
  3. Install Dependencies

    pip install -r requirements.txt

    ⚠️Note: This package is tested in Ubuntu-20.04 ROS Noetic Environment. You may need to install Gurobi if your problem is huge.

πŸš€ Test

After constructing your environment, you can build and test this package:

catkin_make
source ./devel/setup.bash
roslaunch task_alloc_milp test.launch

🧭 Usage

To use this package's functionality, access the /task_alloc_service service through ROS's service communication. The service uses JSON string format for input and output. Since ROS does not provide a standard string service message, I have defined a custom service message type called TaskAllocSrv for your use. The input and output formats are listed below.

Input Format:

  • robot: the agent to handle atomic task
    • id: a string or integer used to uniquely identify this robot.
    • skills: a list of string or integer to describe the ability of this robot.
    • speed: maximum velocity of the robot.
    • free_pos: the position of the robot when it finishes the tasks on hand.
    • free_time: the time when the robot finishes the tasks on hand.
  • atomic_task: the smallest unit of a task
    • id: a string or integer used to uniquely identify this atomic task.
    • location: the 3D coordinates [x, y, z] of the task.
    • required_skill: the skill required to execute this task.
    • duration: time needed to complete the task after arrival.
  • task_dependencies: list of [predecessor_id, successor_id] pairs indicating precedence constraints.
  • task_simultaneity: list of [task_id_1, task_id_2] pairs that must be executed simultaneously.
  • task_consistency: list of [task_id_1, task_id_2] pairs that must be assigned to the same robot.
  • task_exclusivity: list of [task_id_1, task_id_2] pairs that must be assigned to different robots.
{
    "robots": [
        {"id": 0, "skills": ["1"], "speed": 1.0, "free_pos": [0, 10, 0], "free_time": 0},
        {"id": 1, "skills": ["1"], "speed": 1.0, "free_pos": [-10, 10, 0], "free_time": 0},
        {"id": 2, "skills": ["1"], "speed": 1.0, "free_pos": [-20, 10, 0], "free_time": 0}
    ],
    "atomic_tasks": [
        {"id": 0, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
        {"id": 1, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
        {"id": 2, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
        {"id": 3, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
        {"id": 4, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
        {"id": 5, "location": [10, 10, 0], "required_skill": "1", "duration": 2}
    ],
    "task_dependencies": [[1, 0]],
    "task_simultaneity": [[1, 2]],
    "task_consistency": [[3, 4]],
    "task_exclusivity": [[0, 5]]
}

Output Format:

  • T_max: The makespan, i.e., the maximum completion time among all robots for their assigned tasks.
  • robot_schedule: A dictionary where each key is a robot's ID, and the value is an ordered list of atomic tasks assigned to that robot.
{
    "T_max": 28.01,
    "robot_schedule": {
        "0": [
            {"id": 0, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
            {"id": 1, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
            {"id": 3, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
            {"id": 4, "location": [10, 10, 0], "required_skill": "1", "duration": 2}
        ],
        "1": [
            {"id": 2, "location": [10, 10, 0], "required_skill": "1", "duration": 2},
            {"id": 5, "location": [10, 10, 0], "required_skill": "1", "duration": 2}
        ],
        "2": []
    }
}

About

A ros package to solve robot task allocation problem through optimizer

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages