Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: text hmi and implement hmi task as ros2 action #176

Merged
merged 15 commits into from
Sep 6, 2024

Conversation

boczekbartek
Copy link
Member

@boczekbartek boczekbartek commented Aug 30, 2024

First merge: #188

Purpose

  • Task from HMI is implemented as a ros2 action

Proposed Changes

  • refactor streamlit text application for ros2 actions
  • prepare 2 column layout
  • implementation allows to ask agent to:
    • submit tasks
    • check task status (both ros2 action feedback and result)

TODOs (out of scope of this PR):

Issues

Testing

Implementation was tested using RosbotXL demo rai_whoami_node

Terminal 1 - streamlit app:

. ./setup_shell.sh
streamlit run src/rai_hmi/rai_hmi/text_hmi.py rosbot_xl_whoami

Terminal 2 - whoami:

. ./setup_shell.sh
ros2 run rai_whoami rai_whoami_node --ros-args -p robot_description_package:="rosbot_xl_whoami" 

Terminal 3 - simple ros2 action server for testing

mock_rai_node.py

import time

import rclpy
from rclpy.action import ActionServer
from rclpy.node import Node

from rai_interfaces.action import Task


class MyNode(Node):
    def __init__(self) -> None:
        super().__init__("my_node_server")
        self.task_action_server = ActionServer(
            self, Task, "perform_task", self.execute_callback
        )

    def execute_callback(self, goal_handle):
        self.get_logger().info(f"Executing goal: {goal_handle.request.description} ")

        feedback_msg = Task.Feedback()
        feedback_msg.current_status = "Not started"

        for i in range(15):
            feedback_msg.current_status = "In progress"
            self.get_logger().info("Feedback: {0}".format(feedback_msg.current_status))
            goal_handle.publish_feedback(feedback_msg)
            time.sleep(1)

        goal_handle.succeed()

        result = Task.Result()
        result.success = True
        result.report = "Task completed successfully"
        self.get_logger().info("Result: {0}".format(result.success))
        self.get_logger().info("Report: {0}".format(result.report))

        return result


if __name__ == "__main__":
    rclpy.init()
    node = MyNode()
    rclpy.spin(node)
    rclpy.shutdown()
. ./setup_shell.sh
python3 mock_rai_node.py

@boczekbartek boczekbartek changed the title feat: implement task as a ros2 action refactor: text hmi Sep 3, 2024
@boczekbartek boczekbartek marked this pull request as ready for review September 5, 2024 15:15
Copy link
Member

@maciejmajek maciejmajek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done. I've tested using the provided instructions and it works as intended. Great job

@boczekbartek boczekbartek changed the title refactor: text hmi refactor: text hmi and implement hmi task as ros2 action Sep 6, 2024
@boczekbartek boczekbartek merged commit a2df0b9 into refactor/hmi Sep 6, 2024
@boczekbartek boczekbartek deleted the bb/task_as_action branch September 6, 2024 07:23
maciejmajek pushed a commit that referenced this pull request Sep 6, 2024
maciejmajek pushed a commit that referenced this pull request Sep 6, 2024
maciejmajek pushed a commit that referenced this pull request Sep 9, 2024
boczekbartek added a commit that referenced this pull request Sep 17, 2024
maciejmajek pushed a commit that referenced this pull request Sep 17, 2024
maciejmajek pushed a commit that referenced this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants