Posted by @Vortex-TH:
In the latest update, it says:
Localization Hook: The
EasyFullControl
API now has a hook that will trigger a localization request whenever the robot has arrived at a new floor after taking the lift.
But I don’t know how to make use of that… I’m using the python fleet adapter template with EasyFullControl. I added an endpoint to my robot where I can load a new map and send data (position and orientation) for initial localization, but how do I add it to the API, so it gets triggered by RMF? The documentation doesn’t seem to be updated yet in this regard.
My idea was to trigger a map change and localization on the robot when the map in a navigate (to the next waypoint) request is different to the previous one. The problem is that there is no way of knowing the robot’s orientation that it took when moving into the lift, is there? (position should be obvious).
Chosen answer
Answer chosen by @Vortex-TH at 2024-01-19T17:44:10Z.
Answered by @xiyuoh:
Hi! Thanks for bringing this up, this hasn’t been documented, but here’s an example of how you can pass the localize callback when returning RobotCallbacks to be triggered by RMF:
def _make_callbacks(self):
callbacks = rmf_easy.RobotCallbacks(
lambda destination, execution: self.navigate(
destination, execution
),
lambda activity: self.stop(activity),
lambda category, description, execution: self.perform_action(
category, description, execution
)
)
callbacks.localize = lambda estimate, execution: self.localize(
estimate, execution
)
return callbacks
where estimate
is a Destination object containing information about the robot’s position on the new map. That includes the orientation data as well, so your localize
callback should be able to update the robot’s map and pose from RMF accordingly.