Skip to content

More robust mission behavior tree script #5

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion mission_behavior_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rclpy.node import Node
from rclpy.qos import qos_profile_system_default
from std_msgs.msg import String
from as2_msgs.msg import PlatformInfo, PlatformStatus


class StartBehaviorTree(Node):
Expand All @@ -14,14 +15,21 @@ class StartBehaviorTree(Node):
def __init__(self, namespace):
super().__init__('start_bt', namespace=namespace)

self.stop = False

self.status_sub = self.create_subscription(
PlatformInfo, "platform/info", self.status_cbk, qos_profile_system_default)
self.start_pub = self.create_publisher(
String, "start", qos_profile_system_default)

def status_cbk(self, msg: PlatformInfo):
self.stop = True if msg.status.state == PlatformStatus.TAKING_OFF else False
self.start_pub.publish(String())


if __name__ == "__main__":
rclpy.init()
start_bt = StartBehaviorTree(namespace="drone0")
rclpy.spin_once(start_bt, timeout_sec=1)
while not start_bt.stop:
rclpy.spin_once(start_bt, timeout_sec=1)
rclpy.shutdown()