Posted by @cwrx777:
My latest code:
EventListener
class EventListener(graph.lane.Executor):
def __init__(self, event, lane_index, dock_to_wp, lift_lane_index, entry_waypoint, exit_waypoint, node):
graph.lane.Executor.__init__(self)
self.event = event
self.entry = entry_waypoint
self.exit = exit_waypoint
self.lane_index = lane_index
self.dock_to_wp = dock_to_wp
self.lift_lane_index = lift_lane_index
self.node = node
def dock_execute(self, dock):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-dock_execute [{dock.dock_name}] [{dock.duration}]')
#to capture dock_name to exit waypoint
self.dock_to_wp[dock.dock_name] = self.exit
return
def wait_execute(self, wait):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-wait_execute [{wait.duration}]')
return
def door_open_execute(self, door_open):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-door_open_execute [{door_open.name}] [{door_open.duration}]')
return
def door_close_execute(self, door_close):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-door_close_execute [{door_close.name}] [{door_close.duration}]')
return
def lift_door_open_execute(self, lift_door_open):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-lift_door_open_execute [{lift_door_open.lift_name}]')
return
def lift_door_close_execute(self, lift_door_close):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-lift_door_close_execute [{lift_door_close.lift_name}]')
return
def lift_session_begin_execute(self, lift_session_begin):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-lift_session_begin_execute [{lift_session_begin.lift_name}]')
if self.lift_lane_index.get(lift_session_begin.lift_name, None) is None:
self.lift_lane_index[lift_session_begin.lift_name] = []
self.lift_lane_index[lift_session_begin.lift_name].append(self.lane_index)
return
def lift_session_end_execute(self, lift_session_end):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-lift_session_end_execute [{lift_session_end.lift_name}]')
if self.lift_lane_index.get(lift_session_end.lift_name, None) is None:
self.lift_lane_index[lift_session_end.lift_name] = []
self.lift_lane_index[lift_session_end.lift_name].append(self.lane_index)
return
def lift_move_execute(self, lift_move):
self.node.get_logger().info(f'[{self.event}][{self.entry.waypoint_name}]=>[{self.exit.waypoint_name}][{self.lane_index}]-lift_move_execute [{lift_move.lift_name}]')
return
Traverse lanes
dock_to_wp = {}
lift_lane_index = {}
for i in range(nav_graph.num_lanes):
lane = nav_graph.get_lane(i)
entry_waypoint = nav_graph.get_waypoint(lane.entry.waypoint_index)
exit_waypoint = nav_graph.get_waypoint(lane.exit.waypoint_index)
# lane.entry and lane.exit are a Lane::Node wrappers
if lane.entry.event:
executor = EventListener(f'enter', i, dock_to_wp, lift_lane_index, entry_waypoint, exit_waypoint, node)
try:
lane.entry.event.execute(executor)
except Exception as ex:
node.get_logger().error(f'setting entry event executor {ex}')
if lane.exit.event:
executor = EventListener(f'exit', i, dock_to_wp, lift_lane_index, entry_waypoint, exit_waypoint, node)
try:
lane.exit.event.execute(executor)
except Exception as ex:
node.get_logger().error(f'setting exit event executor {ex}')
_lift_state_sub_cb
def _lift_state_sub_cb(msg: LiftState):
if msg.current_mode == LiftState.MODE_OFFLINE:
lift_name = msg.lift_name
node.get_logger().info(
f"Lift [{msg.lift_name}] is [{msg.current_mode}]. publishing close lane requests")
lane_closure_requests_msg = LaneRequest()
lane_closure_requests_msg.fleet_name = fleet_name
lane_closure_requests_msg.close_lanes = []
lane_closure_requests_msg.close_lanes.extend(lift_lane_index[lift_name])
lane_closure_requests_pub.publish(lane_closure_requests_msg)
And I modified the lift plugin so that the state it is reporting can be overridden, here using this message.
I can see that when the lanes are closed, it will be shown as below in rviz.
My issue now, when there are no lifts available, when there is a task that requires using a lift, the fleet adapter crashed. No issue if the task does not require lift.
Error Log (for dispatch task request)
[rmf_task_dispatcher-8] [rmf_dispatcher_node][INFO] Add Task [patrol.dispatch-0] to a bidding queue
[rmf_task_dispatcher-8] [rmf_dispatcher_node][INFO] - Start new bidding task: patrol.dispatch-0
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] [Bidder] Received Bidding notice for task_id [patrol.dispatch-0]
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Planning for [4] robot(s) and [1] request(s)
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Submitted BidProposal to accommodate task [patrol.dispatch-0] by robot [DeliveryRobot_02] with new cost [196.601681]
[rmf_task_dispatcher-8] [rmf_dispatcher_node][INFO] Determined winning Fleet Adapter: [DeliveryRobot], from 1 responses
[rmf_task_dispatcher-8] [rmf_dispatcher_node][INFO] Dispatcher Bidding Result: task [patrol.dispatch-0] is awarded to fleet adapter [DeliveryRobot], with expected robot [DeliveryRobot_02].
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Bid for task_id [patrol.dispatch-0] awarded to fleet [DeliveryRobot]. Processing request...
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Beginning next task [patrol.dispatch-0] for robot [DeliveryRobot/DeliveryRobot_02]
[ERROR] [fleet_adapter-4]: process has died [pid 186718, exit code -11, ...].
Error Log (for direct task request)
fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Direct request [patrol_d316d645-8b5c-4f9a-b561-84cddf8f46a3] successfully queued for robot [DeliveryRobot_01]
[fleet_adapter-4] [DeliveryRobot_fleet_adapter][INFO] Beginning next task [patrol_d316d645-8b5c-4f9a-b561-84cddf8f46a3] for robot [DeliveryRobot/DeliveryRobot_01]
[ERROR] [fleet_adapter-4]: process has died [pid 190405, exit code -11, ...].