Current Robot Mode (#175)

Posted by @cwrx777:

Hi,

Environment:

  • RMF main branch.
  • galactic
  • Ubuntu 20.04 LTS

I’ve implemented a fleet adapter based on the fleet adapter template..

I am confused with the RobotStatus information shown in the rmf-panel. When the environment is just started (rmf core and fleet adapter running, and the robot is shown as the intended location), the status shown in the rmf panel is constantly shown as ‘Moving-2’.
I noticed that the robot_mode() in Task Manager, here, keeps getting called, and _context->current_mode() returns Moving.
When the robot is performing task, the Status shown is Idle-0, as show in screenshot below:


After there is no other pending task:

In here, what does the following mean? set mode to IDLE if _active_task is true?
.mode(_active_task ? RobotModeMsg::MODE_IDLE : _context->current_mode()). I believe the current_mode method is here, which is deprecated.

Chosen answer

Answer chosen by @cwrx777 at 2024-01-11T12:13:57Z.
Answered by @Yadunund:

@cwrx777 let me know if this PR fixes the problem Fix RobotMode in FleetState message published by fleet adapter by Yadunund · Pull Request #220 · open-rmf/rmf_ros2 · GitHub

Posted by @Yadunund:

In general, the rmf_demos/rmf_demos_panel application is considered deprecated and not actively maintained. Please use the rmf-web dashboard and open a ticket if the problem exists.

Posted by @cwrx777:

Hi @Yadunund ,

Is the robot_mode method here also deprecated? if not, is it implemented correctly?

Posted by @Yadunund:

Oh I see the problem now. Sorry for not getting it initially.

The RMF panel retrieves the information on task status from the FleetState message that gets published by the fleet adapter. The status field of this message is filled by the convert_state() function which gets the mode from robot_mode(). But as you pointed out in your description, the implementation of this function is incorrect. It should set MODE_IDLE when there is not active task. I’ll open a PR to fix that.

But I’d also like to point out that the recommended method to get accurate updates on task statuses and progress is via the websocket server. The fleet adapter implementation can take in an optional uri that points to a websocket server. See here. If this uri is provided, the fleet adapter will send out updates eachtime an event completes. The json message sent out contains a lot more useful information. The robot status for this json is populated using the robot_status() function. The implementation for this function is correct as seen here. This is recommended as it provides more flexibility to users on what the status should be and does not limit the number of status to those defined in the RobotMode message. There is also an API in RobotUpdateHandle to manually set the status for whatever specific task your robot may be doing. For example, if you robot is performing a cleaning task, you can use this function to set the status to "cleaning" which does not have an enum in the RobotMode. The rmf-web dashboard gets task information via websocket.


Edited by @Yadunund at 2022-08-15T05:08:13Z

Posted by @Yadunund:

@cwrx777 let me know if this PR fixes the problem Fix RobotMode in FleetState message published by fleet adapter by Yadunund · Pull Request #220 · open-rmf/rmf_ros2 · GitHub


This is the chosen answer.