Skip to content

Commit

Permalink
Add simple BT.CPP solutions to Problems 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Oct 17, 2024
1 parent 3166770 commit ca4153d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
2 changes: 1 addition & 1 deletion technologies/BehaviorTree.CPP/README.md
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
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>

0 comments on commit ca4153d

Please sign in to comment.