Skip to content

Commit

Permalink
improve performance of dance node script
Browse files Browse the repository at this point in the history
  • Loading branch information
CullenSUN committed Nov 6, 2023
1 parent 875d349 commit d9645b1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions mini_pupper_dance/mini_pupper_dance/dance_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def send_dance_request(self, dance_command):
def send_music_request(self, trigger):
req = SetBool.Request()
req.data = trigger
future = self.music_cli.call_async(req)
rclpy.spin_until_future_complete(self, future)
return future.result()
self.music_cli.call_async(req) # Fire-and-forget style communication


def main():
Expand All @@ -40,10 +38,8 @@ def main():
for index, command in enumerate(minimal_client.dance_commands):
# Start music for the first command
if index == 0:
minimal_client.get_logger().info('Playing music...')
start_music_response = minimal_client.send_music_request(True)
if start_music_response.success:
minimal_client.get_logger().info('Music playback started.')
minimal_client.get_logger().info('Starting music...')
minimal_client.send_music_request(True)

# Send movemoment comment for the robot to dance
response = minimal_client.send_dance_request(command)
Expand All @@ -53,9 +49,7 @@ def main():
# Stop music after the last command
if index == len(minimal_client.dance_commands) - 1:
minimal_client.get_logger().info('Stopping music...')
stop_music_response = minimal_client.send_music_request(False)
if stop_music_response.success:
minimal_client.get_logger().info('Music playback stopped.')
minimal_client.send_music_request(False)

minimal_client.destroy_node()
rclpy.shutdown()
Expand Down

0 comments on commit d9645b1

Please sign in to comment.