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

Add BT.CPP solutions to Problems 2, 3, and 4 #72

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion technologies/BehaviorTree.CPP/README.md
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For instance, consider this sample XML in [trees/navigation_demo.xml](pyrobosim_

NOTE: remember that the `name` attribute in the XML is optional and used for debugging only.

You can run the BeahviorTree with the command:
You can run the BehaviorTree with the command:

```bash
ros2 run pyrobosim_btcpp btcpp_executor --ros-args -p tree:=trees/navigation_demo.xml
Expand Down
38 changes: 28 additions & 10 deletions technologies/BehaviorTree.CPP/pyrobosim_btcpp/trees/problem2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@

<BehaviorTree ID="MainTree">
<Sequence>
<Fallback>
<Navigate name="ToTrash" target="dumpster"/>
<Sequence>
<Navigate name="ToTrash" target="hall_dining_trash"/>
<Open target="hall_dining_trash"/>
<Navigate name="ToTrash" target="dumpster"/>
</Sequence>
</Fallback>
<Open target="dumpster"/>
<Navigate name="ToTable" target="table"/>
<Sequence>
<Fallback>
<Navigate name="ToTrash" target="dumpster"/>
<Sequence>
<Navigate name="ToTrashRoomDoor" target="hall_dining_trash"/>
<Open target="hall_dining_trash"/>
<Navigate name="ToTrash" target="dumpster"/>
</Sequence>
</Fallback>
<Open target="dumpster"/>
</Sequence>
<Sequence>
<Navigate name="ToDesk" target="desk"/>
<PickObject name="PickDeskWaste" object="waste0"/>
<Navigate name="ToTrash" target="dumpster"/>
<PlaceObject name="PlaceDeskWaste" object="waste0"/>
</Sequence>
<Sequence>
<Navigate name="ToBin" target="bin"/>
<PickObject name="PickBinWaste" object="waste1"/>
<Navigate name="ToTrash" target="dumpster"/>
<PlaceObject name="PlaceBinWaste" object="waste1"/>
</Sequence>
<Sequence>
<Navigate name="ToDining" target="dining"/>
<Navigate name="ToTrashRoomDoor" target="hall_dining_trash"/>
<Close target="hall_dining_trash"/>
</Sequence>
</Sequence>
</BehaviorTree>

Expand Down
48 changes: 48 additions & 0 deletions technologies/BehaviorTree.CPP/pyrobosim_btcpp/trees/problem3.xml
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<root BTCPP_format="4">

<BehaviorTree ID="MainTree">
<Sequence>
<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToPantry" target="pantry"/>
<Open name="OpenPantry" target="pantry"/>
<PickObject name="PickBread" object="bread0"/>
</Sequence>
</RetryUntilSuccessful>
<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToTable" target="table"/>
<PlaceObject name="PlaceBread" object="bread0"/>
</Sequence>
</RetryUntilSuccessful>
<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToPantry" target="pantry"/>
<Close name="ClosePantry" target="pantry"/>
</Sequence>
</RetryUntilSuccessful>

<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToFridge" target="fridge"/>
<Open name="OpenFridge" target="fridge"/>
<PickObject name="PickButter" object="butter0"/>
</Sequence>
</RetryUntilSuccessful>
<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToTable" target="table"/>
<PlaceObject name="PlaceButter" object="butter0"/>
</Sequence>
</RetryUntilSuccessful>
<RetryUntilSuccessful num_attempts="5">
<Sequence>
<Navigate name="ToFridge" target="fridge"/>
<Close name="CloseFridge" target="fridge"/>
</Sequence>
</RetryUntilSuccessful>

</Sequence>
</BehaviorTree>

</root>
28 changes: 28 additions & 0 deletions technologies/BehaviorTree.CPP/pyrobosim_btcpp/trees/problem4.xml
sea-bass marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<root BTCPP_format="4">

<!-- WORK IN PROGRESS -->
<!-- NOTE: This segfaults the BT executor when the battery crosses the threshold. -->
<BehaviorTree ID="MainTree">
<ReactiveSequence>
<Fallback>
<Inverter>
<IsBatteryLow low_threshold="90"/>
</Inverter>
<Navigate name="ToCharger" target="charger"/>
</Fallback>
<RetryUntilSuccessful num_attempts="10">
<Sequence>
<Navigate name="ToDesk" target="desk"/>
<Navigate name="ToFridge" target="fridge"/>
<Navigate name="ToDesk" target="desk"/>
<Navigate name="ToFridge" target="fridge"/>
<Navigate name="ToDesk" target="desk"/>
<Navigate name="ToFridge" target="fridge"/>
<Navigate name="ToDesk" target="desk"/>
<Navigate name="ToFridge" target="fridge"/>
</Sequence>
</RetryUntilSuccessful>
</ReactiveSequence>
</BehaviorTree>

</root>
Loading