# Setting robot to temporarily unavailable to be assigned a task (#188)

**URL:** <https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694>\
**Category:** Open-RMF General\
**Tags:** rmf-github-discuss\
**Created:** [August 17, 2022, 12:27am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694 "2022-08-17T00:27:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 17, 2022, 12:27am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/1 "2022-08-17T00:27:19Z")

</div>

Posted by @cwrx777:

Hi,

Consider a fleet of food delivery robot in a multi storey hotel. When food is being loaded into the robot (robot A), users on another floor may request for a to collect empty cart (on-demand/adhoc) how to prevent the empty cart collection cart task to be assigned to robot A ?

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 17, 2022, 7:31am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/2 "2022-08-17T07:31:40Z")

</div>

Posted by @Yadunund:

Your question is lacking several details on your specific use case. Please be more descriptive in the future in explaining the setup. For example

- Is the same fleet supposed to be able to perform both “food delivery” and “empty cart collection” tasks? Are they the same type of task? Or different tasks that need to be performed by different fleets?
- When you are loading robot A, is it actively performing a custom defined task for food delivery or is it just idle at a location?
- Is the issue that once the robot finishes the food delivery task, it gets assigned the cart collection which you don’t want? Or is that while you’re loading items onto the robot, it starts performing the new task?

Depending on your answers above, there are multiple ways to address the problem.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 18, 2022, 8:13am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/3 "2022-08-18T08:13:01Z")

</div>

Posted by @cwrx777:

Hi @Yadunund ,

The robot probably looks like [this](https://user-images.githubusercontent.com/3224215/185343478-86c7d609-5802-4939-9ae7-99b5fb139bbe.png).

1. There is only one fleet and it is configured to perform food delivery and collection of empty trays.
2. When kitchen user is loading robot A, it is at an idle location, e.g charging station.
3. The issue there could be another user who requests for a robot to come and collect the empty tray and the task manager may assign the collection task to the robot A while the kitchen user is loading it.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 23, 2022, 4:27am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/4 "2022-08-23T04:27:03Z")

</div>

Posted by @Yadunund:

The problem is that you have the robot idle while loading items but expect Open-RMF to somehow know that it is actually being utilised. This is not a good way to execute your task with Open-RMF.

There are a couple ways to fulfil your task in a safe manner:

Option 1: use the existing [Delivery](https://github.com/open-rmf/rmf_ros2/blob/main/rmf_fleet_adapter/schemas/task_description__delivery.json) task. This task will guide a robot to a pickup location (if the robot is already at this location, it will skip this step), wait for conformation that items have been loaded (via rmf\_dispenser\_msgs), go to a dropoff location, and wait for confirmation that items have been unloaded (via rmf\_ingestor\_msgs). If a human is loading the items, you can implement a interface somewhere on the robot or a dashbaord for them to confirm the loading/unloading which will then publish the suitable confirmation messages. While the robot is executing any of these steps including waiting, it will not be assigned a different task.

if your delivery task is more complicated, eg you have multiple pickup and multiple dropoff locations, you can still create such a task by defining a custom [Compose](https://github.com/open-rmf/rmf_ros2/blob/main/rmf_fleet_adapter/schemas/task_description__compose.json) task with a list of `pickup` and `dropoff` events. See option 2 below for more information.

Option 2: An alternative to not publishing ROS 2 messages for confirmation.  
Create a `compose` task using our flexible task framework (See our documentation [here](https://github.com/osrf/ros2multirobotbook/blob/master/src/task_new.md#building-a-custom-task).) that is a sequence of activities like

```auto
GoToPlace->PerformAction->GoToPlace->PerformAction

```

The `PerformAction` is a really powerful activity whose execution you can totally customize. You’ll need to define an [action\_executor](https://github.com/open-rmf/rmf_ros2/blob/3be4edfce77e1a4ecb5ce99504e7696eb61658d9/rmf_fleet_adapter/include/rmf_fleet_adapter/agv/RobotUpdateHandle.hpp#L178-L179) for the robot which will decide what the robot should do when this event is triggered. In your case, you can simply wait for confirmation from the human before calling [finished()](https://github.com/open-rmf/rmf_ros2/blob/3be4edfce77e1a4ecb5ce99504e7696eb61658d9/rmf_fleet_adapter/include/rmf_fleet_adapter/agv/RobotUpdateHandle.hpp#L150-L151). All this is within your fleet adapter so you can have your adapter integrate with any other system you have to receive the human confirmation.

* * *

Edited by @Yadunund at 2022-08-23T04:28:16Z

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 30, 2022, 4:34am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/5 "2022-08-30T04:34:36Z")

</div>

Posted by @cwrx777:

Hi,

This could be related to this [issue](https://github.com/open-rmf/rmf/discussions/185)

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [August 30, 2022, 4:41am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/6 "2022-08-30T04:41:48Z")

</div>

Posted by @Yadunund:

I would not say they are related.

Yes technically with that feature, you can set a robot as unable to bypass any tasks from being assigned. But like I explained in detail above, you can achieve what your want to do with existing task frameworks in Open-RMF. You can designate a robot as “busy” while it is being loaded.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 1, 2022, 4:38am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/7 "2022-09-01T04:38:46Z")

</div>

Posted by @cwrx777:

Hi @Yadunund ,  
What is [/rmf\_traffic/unregister\_participant](https://github.com/open-rmf/rmf_ros2/blob/3be4edfce77e1a4ecb5ce99504e7696eb61658d9/rmf_traffic_ros2/include/rmf_traffic_ros2/StandardNames.hpp#L37) service? In what scenario is this used?

Assuming the robot has been added (using fleet\_handle.add\_robot) and unregister participant is called against that robot, will calling ‘[/rmf\_traffic/register participant](https://github.com/open-rmf/rmf_ros2/blob/3be4edfce77e1a4ecb5ce99504e7696eb61658d9/rmf_traffic_ros2/include/rmf_traffic_ros2/StandardNames.hpp#L36)’ for the robot put things back to normal (before unregister participant is called) ?

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 1, 2022, 5:05am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/8 "2022-09-01T05:05:16Z")

</div>

Posted by @mxgrey:

`/rmf_traffic/unregister_participant` clears the participant’s itinerary in the traffic schedule. When it was first implemented, it used to remove the participant from the schedule entirely so that no new itinerary could be scheduled for a traffic participant until `/rmf_traffic/register_participant` is called for it again, but after some real-world experience we found that for the sake of robust fail-over it’s better to leave participants registered in the schedule permanently. Therefore “unregister” just clears the participant’s itinerary, but you can resume scheduling itineraries for that participant at any time.

As mentioned in [this discussion](https://github.com/open-rmf/rmf/discussions/179) you can use `/rmf_traffic/register_participant` to change the properties of a participant, but otherwise there is no value to calling it multiple times, even if `/rmf_traffic/unregister_participant` has been called.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 1, 2022, 7:06am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/9 "2022-09-01T07:06:34Z")

</div>

Posted by @cwrx777:

Hi @mxgrey ,

> `/rmf_traffic/unregister_participant` clears the participant’s itinerary in the traffic schedule

By itinerary, do you mean the intended robot trajectories as mentioned [here](https://osrf.github.io/ros2multirobotbook/rmf-core.html#traffic-schedule)? and by calling `/rmf_traffic/unregister_participant`, it will clear all planned trajectories?

> Therefore “unregister” just clears the participant’s itinerary, but you can resume scheduling itineraries for that participant at any time.

What do you mean by ‘resume scheduling itineraries’? does ‘unregister’ pause anything?

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 1, 2022, 7:20am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/10 "2022-09-01T07:20:34Z")

</div>

Posted by @mxgrey:

> By itinerary, do you mean the intended robot trajectories as mentioned [here](https://osrf.github.io/ros2multirobotbook/rmf-core.html#traffic-schedule)?

Correct.

> and by calling /rmf\_traffic/unregister\_participant, it will clear all planned trajectories?

It will clear planned trajectories only for the robot that you request to unregister. The planned trajectories for all other robots will be unaffected.

> What do you mean by ‘resume scheduling itineraries’?

The fleet adapter will automatically schedule itineraries for the robots as they get commanded to perform tasks. That will continue to happen even after you manually unregister the robot.

> does ‘unregister’ pause anything?

No, it does not pause anything. The name of the service is admittedly confusing, because it originally did completely remove the robot from the schedule such that it could not appear again in the traffic schedule until it gets re-registered, but that design proved problematic when it came to supporting robust fail-over. The new (current) behavior allows participants to shut down, restart, and resume operating correctly with no disruption to the overall system.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 11, 2022, 6:59am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/11 "2022-09-11T06:59:33Z")

</div>

Posted by @mxgrey:

@cwrx777 After thinking over the questions you’ve been asking, it’s become clear to me that RMF needs a built-in way to take robots temporarily offline and make it clear to the task planning system that they are not available to perform new tasks.

To that end, I’ve opened [this PR](https://github.com/open-rmf/rmf_ros2/pull/233) which allows you to “decommission” your robots. When a robot is decommissioned it will no longer accept new tasks.

RMF does not currently have a builtin way to reassign tasks from one robot to another. We want to develop that feature but do not currently have funding to do so. Therefore decommissioning will not affect the robot’s current task queue. After you’ve decommissioned a robot, it will continue to perform any tasks that it was already assigned.

If you need the robot to stop what it’s doing immediately, you will need to use the task interrupt, cancel, or kill APIs that are described in the pull request that I linked.

We intend to do a code freeze for the next release on 16 September (Friday), so if you can test out that PR for your use case and give us some feedback that would be very helpful. We have very limited time for testing before the code freeze, so I can’t promise that the feature will be merged for the release without your feedback.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 21, 2022, 9:07am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/12 "2022-09-21T09:07:50Z")

</div>

Posted by @cwrx777:

Hi @mxgrey ,

The [is\_commissioned](https://github.com/open-rmf/rmf_ros2/blob/main/rmf_fleet_adapter/src/rmf_fleet_adapter/agv/RobotUpdateHandle.cpp#L644) flag seems not respected when assigning a task directly to a robot.  
I confirmed that the robot’s `is_commissioned` flag was False before sending the following task.  
I used the following to send a task to a robot.

```bash
ros2 run rmf_demos_tasks dispatch_patrol -p wp1 wp2 -R DeliveryRobot_1 -F DeliveryRobot

```

* * *

Edited by @cwrx777 at 2022-09-21T09:09:05Z

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 21, 2022, 9:22am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/13 "2022-09-21T09:22:12Z")

</div>

Posted by @mxgrey:

That raises an interesting question…

If a robot is decommissioned but a task is directly assigned to it, should it ignore that task? Report an error? Queue the task until the robot is re-commissioned?

The decommissioning feature was specifically designed to prevent the RMF dispatching system from assigning tasks to robots that shouldn’t be receiving any tasks, because otherwise you as the system integrator cannot prevent the dispatching system from assigning tasks to them.

When it comes to direct tasks, you as the system integrator do have complete control over which robots those tasks are given to. So if you as the system integrator are telling RMF “Give this task to Robot A right now” should RMF block that or should RMF believe that you know what you’re doing?

The direct request pipeline was created specifically because system integrators were asking for a way to issue commands to robots without interference from RMF. I think a healthy debate could be had over where the line is between “interference” versus “correct behavior”. Feel free to share your own thoughts on what the correct behavior is.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [September 22, 2022, 6:41am UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/14 "2022-09-22T06:41:06Z")

</div>

Posted by @cwrx777:

I think the expected behavior of a ‘decommissioned’ robot needs to be defined and it needs to be consistent regardless if a robot is to be assigned direct or _indirect_ task request.  
I’m not sure if this is related, if due to some reason, e.g. building owner policy, a robot needs to be turned off, e.g. during weekends/long public holidays, etc, how can this be made known to rmf? coz if it is not handled properly, we’ll see lots of errors in getting the latest robot status.

---

<div class="post-metadata">

**Author:** ![Archive-o-matic](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/archive-o-matic/32/26074_2.png) [@Archive-o-matic](https://discourse.openrobotics.org/u/Archive-o-matic)\
**Post date:** [July 11, 2024, 7:25pm UTC](https://discourse.openrobotics.org/t/setting-robot-to-temporarily-unavailable-to-be-assigned-a-task-188/44694/15 "2024-07-11T19:25:48Z")

</div>

Posted by @mdfesto:

@mxgrey I believe this request is resolved with the latest release on Jazzy?

@cwrx777 FYI
