Skip to content

Commit

Permalink
Fixed model
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Lampacrescia <[email protected]>
  • Loading branch information
MarcoLm993 committed Nov 29, 2024
1 parent bf596da commit f668748
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<scxml
initial="running"
version="1.0"
name="ShallMove"
name="Move"
model_src=""
xmlns="http://www.w3.org/2005/07/scxml">

Expand All @@ -24,7 +24,7 @@

<state id="running">
<bt_tick target="running">
<ros_topic_publish name="goal">
<ros_topic_publish name="move_pub">
<field name="data">
<expr>
<bt_get_input key="direction" />
Expand Down
28 changes: 14 additions & 14 deletions test/jani_generator/_test_data/grid_robot_blackboard/world.scxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
initial="init">

<datamodel>
<data id="n" type="int" expr="10" /> <!-- grid size -->
<data id="pose_x" type="int32" expr="Math.floor(Math.random() * n)" />
<data id="pose_y" type="int32" />
<data id="goal_x" type="int32" />
<data id="goal_y" type="int32" />
<data id="n" type="int32" expr="10" /> <!-- grid size -->
<data id="pose_x" type="int32" expr="0" /> <!-- TODO: Math.floor(Math.random() * n) -->
<data id="pose_y" type="int32" expr="0" /> <!-- TODO: Math.floor(Math.random() * n) -->
<data id="goal_x" type="int32" expr="4" />
<data id="goal_y" type="int32" expr="9" />
</datamodel>

<ros_topic_subscriber topic="move" type="std_msgs/Int16" />
Expand All @@ -23,30 +23,30 @@
<ros_topic_publisher topic="pose" type="grid_robot_interfaces/Int2D" />
<ros_topic_publisher topic="goal" type="grid_robot_interfaces/Int2D" />

<state name="init">
<state id="init">
<onentry>
<!-- if at goal -->
<if cond="pose_x == goal_x and pose_y == goal_y">
<assign location="goal_x" expr="Math.floor(Math.random() * n)" />
<assign location="goal_y" expr="Math.floor(Math.random() * n)" />
<if cond="pose_x == goal_x &amp;&amp; pose_y == goal_y">
<assign location="goal_x" expr="goal_x + 1" /> <!-- TODO: Math.floor(Math.random() * n) -->
<assign location="goal_y" expr="goal_y - 1" /> <!-- TODO: Math.floor(Math.random() * n) -->
<ros_topic_publish name="goal">
<field name="x" expr="goal_x" />
<field name="y" expr="goal_y" />
</ros_topic_publish>
</if>
</onentry>

<ros_topic_callback name="move">
<if cond="_msg.data == 0 and pose_x &lt; n - 1">
<ros_topic_callback name="move" target="init">
<if cond="_msg.data == 0 &amp;&amp; pose_x &lt; n - 1">
<!-- right -->
<assign location="pose_x" expr="pose_x + 1" />
<elseif cond="_msg.data == 1 and pose_x &gt; 0" />
<elseif cond="_msg.data == 1 &amp;&amp; pose_x &gt; 0" />
<!-- left -->
<assign location="pose_x" expr="pose_x - 1" />
<elseif cond="_msg.data == 2 and pose_y &lt; n - 1" />
<elseif cond="_msg.data == 2 &amp;&amp; pose_y &lt; n - 1" />
<!-- up -->
<assign location="pose_y" expr="pose_y + 1" />
<elseif cond="_msg.data == 3 and pose_y &gt; 0" />
<elseif cond="_msg.data == 3 &amp;&amp; pose_y &gt; 0" />
<!-- down -->
<assign location="pose_y" expr="pose_y - 1" />
</if>
Expand Down

0 comments on commit f668748

Please sign in to comment.