|
@@ -14,6 +14,7 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
|
|
|
|
GlobalOrchestrationSM.__init__(self)
|
|
GlobalOrchestrationSM.__init__(self)
|
|
KrakenOrchestrationNode.__init__(self)
|
|
KrakenOrchestrationNode.__init__(self)
|
|
|
|
+ self.logger = KrakenOrchestrationNode.get_logger(self)
|
|
|
|
|
|
spin_thread = Thread(target=rclpy.spin, args=(self,))
|
|
spin_thread = Thread(target=rclpy.spin, args=(self,))
|
|
spin_thread.start()
|
|
spin_thread.start()
|
|
@@ -23,10 +24,11 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
|
|
|
|
def get_next_pose(self):
|
|
def get_next_pose(self):
|
|
if self.current_index >= len(self.poses):
|
|
if self.current_index >= len(self.poses):
|
|
- print('Invalid index!')
|
|
|
|
|
|
+ self.logger.error('Invalid index!')
|
|
return PoseStamped()
|
|
return PoseStamped()
|
|
|
|
|
|
pose = self.poses[self.current_index]
|
|
pose = self.poses[self.current_index]
|
|
|
|
+ self.logger.info("Current goal id is %d " % self.current_index)
|
|
self.current_index += 1
|
|
self.current_index += 1
|
|
return pose
|
|
return pose
|
|
|
|
|
|
@@ -35,7 +37,7 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
rclpy.shutdown()
|
|
rclpy.shutdown()
|
|
|
|
|
|
def on_enter_waiting(self):
|
|
def on_enter_waiting(self):
|
|
- print('Has the simulation started?')
|
|
|
|
|
|
+ self.logger.info('Has the simulation started?')
|
|
self.send_state("Wait for connection")
|
|
self.send_state("Wait for connection")
|
|
# Perform a check whether the simulation has started or not.
|
|
# Perform a check whether the simulation has started or not.
|
|
if (self.sim_started):
|
|
if (self.sim_started):
|
|
@@ -45,23 +47,23 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
self.await_start()
|
|
self.await_start()
|
|
|
|
|
|
def on_enter_spawning(self):
|
|
def on_enter_spawning(self):
|
|
- print('Spawning the robot.')
|
|
|
|
|
|
+ self.logger.info('Spawning the robot.')
|
|
self.send_state("Spawning the robot")
|
|
self.send_state("Spawning the robot")
|
|
if self.spawn_kraken():
|
|
if self.spawn_kraken():
|
|
self.spawned()
|
|
self.spawned()
|
|
else:
|
|
else:
|
|
- print('Robot spawning failed.')
|
|
|
|
|
|
+ self.logger.info('Robot spawning failed.')
|
|
|
|
|
|
def on_spawned(self):
|
|
def on_spawned(self):
|
|
- print('Robot spawned successfully. Fetching info.')
|
|
|
|
|
|
+ self.logger.info('Robot spawned successfully. Fetching info.')
|
|
pose = self.get_spawn_point_pose()
|
|
pose = self.get_spawn_point_pose()
|
|
self.poses = self.get_plan_poses(pose)
|
|
self.poses = self.get_plan_poses(pose)
|
|
# Give nav stack a few seconds before we start first goal point
|
|
# Give nav stack a few seconds before we start first goal point
|
|
- print('Waiting for robot sensors to latch...')
|
|
|
|
|
|
+ self.logger.info('Waiting for robot sensors to latch...')
|
|
time.sleep(3)
|
|
time.sleep(3)
|
|
|
|
|
|
def on_enter_gathering(self):
|
|
def on_enter_gathering(self):
|
|
- print('Is the robot in a gathering position?')
|
|
|
|
|
|
+ self.logger.info('Is the robot in a gathering position?')
|
|
# Perform a check whether the robot is in a gathering position or not.
|
|
# Perform a check whether the robot is in a gathering position or not.
|
|
if (self.can_gather):
|
|
if (self.can_gather):
|
|
self.gather()
|
|
self.gather()
|
|
@@ -69,13 +71,13 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
self.navigate()
|
|
self.navigate()
|
|
|
|
|
|
def on_gather(self):
|
|
def on_gather(self):
|
|
- print('Gathering the apples.')
|
|
|
|
|
|
+ self.logger.info('Gathering the apples.')
|
|
# Instruct the robot to start gathering apples.
|
|
# Instruct the robot to start gathering apples.
|
|
self.has_finished = not self.has_finished
|
|
self.has_finished = not self.has_finished
|
|
pass
|
|
pass
|
|
|
|
|
|
def on_enter_finishing(self):
|
|
def on_enter_finishing(self):
|
|
- print('Has the robot completed its job?')
|
|
|
|
|
|
+ self.logger.info('Has the robot completed its job?')
|
|
# Perform a check whether the robot has finished its job or not.
|
|
# Perform a check whether the robot has finished its job or not.
|
|
if (self.current_index >= len(self.poses)):
|
|
if (self.current_index >= len(self.poses)):
|
|
self.finished()
|
|
self.finished()
|
|
@@ -84,7 +86,7 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
|
|
|
|
def on_navigate(self):
|
|
def on_navigate(self):
|
|
self.send_state("Navigating")
|
|
self.send_state("Navigating")
|
|
- print('Navigating the robot to a closest gathering position?')
|
|
|
|
|
|
+ self.logger.info('Navigating the robot to a closest gathering position?')
|
|
self.can_gather = False
|
|
self.can_gather = False
|
|
# Instruct the robot to navigate to the closest gathering position.
|
|
# Instruct the robot to navigate to the closest gathering position.
|
|
self.navigate_to_pose(self.get_next_pose())
|
|
self.navigate_to_pose(self.get_next_pose())
|
|
@@ -96,21 +98,21 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
self.can_gather = True
|
|
self.can_gather = True
|
|
|
|
|
|
def on_gather(self):
|
|
def on_gather(self):
|
|
- print("Requesting gathering...")
|
|
|
|
|
|
+ self.logger.info("Requesting gathering...")
|
|
self.send_state("Gather %.1f "% self.apple_progress)
|
|
self.send_state("Gather %.1f "% self.apple_progress)
|
|
trigger_res = self.trigger_apple_gathering()
|
|
trigger_res = self.trigger_apple_gathering()
|
|
- print(trigger_res.message)
|
|
|
|
|
|
+ self.logger.info(trigger_res.message)
|
|
|
|
|
|
if trigger_res.success:
|
|
if trigger_res.success:
|
|
while not self.gathering_done:
|
|
while not self.gathering_done:
|
|
self.send_state("Gather %.0f %%"% self.apple_progress)
|
|
self.send_state("Gather %.0f %%"% self.apple_progress)
|
|
time.sleep(0.2)
|
|
time.sleep(0.2)
|
|
|
|
|
|
- print("Done gathering apples.")
|
|
|
|
|
|
+ self.logger.info("Done gathering apples.")
|
|
else:
|
|
else:
|
|
- print("Freeing up the AppleKraken...")
|
|
|
|
|
|
+ self.logger.info("Freeing up the AppleKraken...")
|
|
cancel_res = self.cancel_apple_gathering()
|
|
cancel_res = self.cancel_apple_gathering()
|
|
- print(cancel_res.message)
|
|
|
|
|
|
+ self.logger.info(cancel_res.message)
|
|
time.sleep(2)
|
|
time.sleep(2)
|
|
|
|
|
|
def on_finish(self):
|
|
def on_finish(self):
|
|
@@ -119,7 +121,7 @@ class GlobalOrchestration(GlobalOrchestrationSM, KrakenOrchestrationNode):
|
|
|
|
|
|
def on_finished(self):
|
|
def on_finished(self):
|
|
self.send_state("Completed")
|
|
self.send_state("Completed")
|
|
- print('The robot has completed its job.')
|
|
|
|
|
|
+ self.logger.info('The robot has completed its job.')
|
|
# The robot has finished its job.
|
|
# The robot has finished its job.
|
|
pass
|
|
pass
|
|
|
|
|