Skip to content

Commit

Permalink
it does something
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Henkel <[email protected]>
  • Loading branch information
ct2034 committed Dec 15, 2024
1 parent f8cd877 commit 7465db1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<BehaviorTree ID="simple_robot_blackboard">
<Sequence name="control_loop">
<!-- Store goal and robot pose in 4 blackboard variables -->
<Action ID="UpdateGoalAndCurrentPosition" goal_x="{goal_x}" goal_y="{goal_y}" curr_x="{curr_x}" curr_y="{curr_y}" move="{move}" />
<Action ID="UpdateGoalAndCurrentPosition" goal_x="{goal_x}" goal_y="{goal_y}" curr_x="{curr_x}" curr_y="{curr_y}" move_out="{move}" move_in="{move}" />
<Fallback name="move_to_goal">
<!--
Movement enum in the world.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<bt_declare_port_out key="goal_y" type="int32" />
<bt_declare_port_out key="curr_x" type="int32" />
<bt_declare_port_out key="curr_y" type="int32" />
<bt_declare_port_in key="move" type="int32" />
<bt_declare_port_in key="move_in" type="int32" />
<bt_declare_port_out key="move_out" type="int32" />
<!--
move: 0 - right
1 - left
Expand Down Expand Up @@ -63,28 +64,30 @@
</state> -->

<state id="init">
<onentry>
<bt_set_output key="move_out" expr="4" />
</onentry>
<transition target="wait_for_tick" />
</state>

<state id="wait_for_tick">
<bt_tick target="running">
<assign location="goal_x" expr="4" /> <!-- TODO: Math.floor(Math.random() * n) -->
<assign location="goal_y" expr="9" /> <!-- TODO: Math.floor(Math.random() * n) -->
<bt_set_output key="goal_x" expr="goal_x" />
<bt_set_output key="goal_y" expr="goal_y" />
<bt_set_output key="curr_x" expr="pose_x" />
<bt_set_output key="curr_y" expr="pose_y" />
<if cond="first_tick">
<assign location="first_tick" expr="false" />
<assign location="move" expr="4" />
<else />
<assign location="move">
<expr>
<bt_get_input key="move" />
</expr>
</assign>
</if>
<assign location="move">
<expr>
<bt_get_input key="move_in" />
</expr>
</assign>
</bt_tick>
</state>

<state id="running">
<transition target="init" cond="move != 4">
<transition target="wait_for_tick">
<if cond="move == 0 &amp;&amp; pose_x &lt; n - 1">
<!-- right -->
<assign location="pose_x" expr="pose_x + 1" />
Expand All @@ -98,6 +101,7 @@
<!-- down -->
<assign location="pose_y" expr="pose_y - 1" />
</if>
<bt_set_output key="move_out" expr="4" />
<if cond="pose_x == goal_x &amp;&amp; pose_y == goal_y">
<ros_topic_publish name="at_goal">
<field name="data" expr="true" />
Expand Down

0 comments on commit 7465db1

Please sign in to comment.