Posted by @ptientho:
Hi Community,
I’d like to share a good practice for those developing a fleet adapter for their robot fleet. A few weeks ago, I encountered a problem that my robots did not receive real-time commands from the RMF system; in fact, the integration works fine - the adapter sends/receives commands from lower-level controllers. However, there was a strange behavior as in the following video.
https://github.com/user-attachments/assets/cc8982e7-80de-44cb-8f56-199f16b47b4e
Normally, what we expect is that the current robot pose (purple sphere) follows the RMF navigation plan (yellow circle), but in this video, the robot got stuck and did not move, even the replanning occurred. I then checked the log history and found there’s a problem in my adapter implementation.
[rmf_task_dispatcher-7] [ERROR] [1748960731.495016394] [rmf_dispatcher_node]: Dispatch command [0] type [1] for task [patrol.dispatch-1] directed at fleet [Fastbot] has expired. This likely means something is wrong with the fleet adapter for [Fastbot] preventing it from responding.
So I needed to check my adapter, particularly in RobotAPI, and found that.
def position(self, robot_name: str):
''' Return [x, y, theta] expressed in the robot's coordinate frame or
None if any errors are encountered'''
# ------------------------ #
# MY CODE HERE
while try_seconds <= timeout:
transform = self.tf_handlers[robot_name].get_transform()
try_seconds += time_step
time.sleep(time_step)
I used a while loop and it causes communication blocking; it delays until timeout
seconds then RMF receives a message.
This is a bad practice and you should avoid that. Instead, to handle or strange behavior, use exception handling (try-except) block.
After I removed the loop, my robots are synchronous with RMF system.