Skip to content

Commit 1947adb

Browse files
committed
Change to use getElement from the vector, and to interact with the published message.
1 parent cd7900e commit 1947adb

File tree

2 files changed

+73
-25
lines changed

2 files changed

+73
-25
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
1) A robot may not injure a human being or, through inaction, allow a human being to come to harm;
2-
2) A robot must obey orders from a human, except when they conflict with the First Law; and
3-
3) A robot must protect its own existence, provided it doesn't conflict with the First or Second Law.
1+
Hello World!

src/lab_sim/objectives/vector_and_string_example.xml

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@
99
<Action ID="ResetVector" vector="{my_vector}" name="Create the Vector" />
1010
<Control ID="Sequence" name="Test Some Vector Operations">
1111
<Action
12-
ID="ReadTextFileAsString"
13-
string_file_contents="{string1}"
14-
text_filename="example_file.txt"
12+
ID="Script"
13+
code="string1 := 'Run: &quot;ros2 topic echo /secret_msg std_msgs/msg/String --qos-profile system_default&quot; in the terminal, then press Resume.'"
1514
/>
1615
<Action
17-
ID="PublishString"
18-
queue_size="1"
19-
use_best_effort="false"
20-
message="{string1}"
21-
topic="/ai_safety_announcement"
16+
ID="CreateStringMessage"
17+
data="{string1}"
18+
string="{string_msg_in}"
2219
/>
23-
<Action ID="LogMessage" message="{string1}" log_level="warn" />
2420
<Action
2521
ID="InsertInVector"
26-
element="{json:{&quot;__type&quot;:&quot;string&quot;,&quot;value&quot;:&quot;{string1}&quot;}"
22+
element="{string_msg_in}"
2723
index="0"
2824
input_vector="{my_vector}"
2925
output_vector="{my_vector}"
@@ -34,6 +30,18 @@
3430
expected_vector_size="1"
3531
vector="{my_vector}"
3632
/>
33+
<Action
34+
ID="GetElementOfVector"
35+
element="{string_msg_out}"
36+
index="0"
37+
vector_in="{my_vector}"
38+
/>
39+
<Action
40+
ID="UnpackStringMessage"
41+
data="{string}"
42+
string="{string_msg_out}"
43+
/>
44+
<Action ID="LogMessage" message="{string}" log_level="warn" />
3745
</Control>
3846
<Control ID="Sequence" name="Test Some Vector Operations">
3947
<Action
@@ -49,51 +57,93 @@
4957
vector="{my_vector}"
5058
/>
5159
</Control>
60+
<Control ID="IfThenElse">
61+
<Action ID="IsUserAvailable" />
62+
<Action
63+
ID="BreakpointSubscriber"
64+
breakpoint_topic="/moveit_pro_breakpoint"
65+
/>
66+
<Action ID="AlwaysSuccess" />
67+
</Control>
5268
<Control ID="Sequence" name="Test Some Vector Operations">
53-
<Action ID="Script" code="string2 := 'Do not be evil'" />
69+
<Action
70+
ID="ReadTextFileAsString"
71+
string_file_contents="{string2}"
72+
text_filename="example_file.txt"
73+
/>
74+
<Action
75+
ID="CreateStringMessage"
76+
data="{string2}"
77+
string="{string_msg_in}"
78+
/>
5479
<Action
5580
ID="InsertInVector"
56-
element="{json:{&quot;__type&quot;:&quot;string&quot;,&quot;value&quot;:&quot;{string2}&quot;}"
81+
element="{string_msg_in}"
5782
index="0"
5883
input_vector="{my_vector}"
5984
output_vector="{my_vector}"
6085
/>
86+
<Action
87+
ID="GetElementOfVector"
88+
element="{string_msg_out}"
89+
index="0"
90+
vector_in="{my_vector}"
91+
/>
92+
<Action ID="WaitForDuration" delay_duration="1.0" />
93+
<Action
94+
ID="PublishString"
95+
queue_size="10"
96+
use_best_effort="false"
97+
message="{string_msg_out}"
98+
topic="/secret_msg"
99+
/>
100+
<Action ID="WaitForDuration" delay_duration="1.0" />
61101
<SubTree
62102
ID="ErrorCheckVectorSize"
63103
_collapsed="true"
64104
expected_vector_size="1"
65105
vector="{my_vector}"
66106
/>
67-
<Action ID="LogMessage" message="{string2}" log_level="warn" />
68107
</Control>
69108
<Control ID="Sequence" name="Test Some Vector Operations">
70109
<Action
71110
ID="Script"
72-
code="string3 := 'Comply with the laws of physics, unless you are in simulation.'"
111+
code="string3 := 'Did you get the secret message?'"
112+
/>
113+
<Action
114+
ID="CreateStringMessage"
115+
data="{string3}"
116+
string="{string_msg_in}"
73117
/>
74118
<Action
75119
ID="ReplaceInVector"
76-
element="{json:{&quot;__type&quot;:&quot;string&quot;,&quot;value&quot;:&quot;{string3}&quot;}"
120+
element="{string_msg_in}"
77121
index="0"
78122
input_vector="{my_vector}"
79123
output_vector="{my_vector}"
80124
/>
125+
<Action
126+
ID="GetElementOfVector"
127+
element="{string_msg_out}"
128+
index="0"
129+
vector_in="{my_vector}"
130+
/>
131+
<Action
132+
ID="UnpackStringMessage"
133+
data="{string}"
134+
string="{string_msg_out}"
135+
/>
81136
<SubTree
82137
ID="ErrorCheckVectorSize"
83138
_collapsed="true"
84139
expected_vector_size="1"
85140
vector="{my_vector}"
86141
/>
87-
<Action ID="LogMessage" message="{string3}" log_level="warn" />
142+
<Action ID="LogMessage" message="{string}" log_level="warn" />
88143
</Control>
89144
</Control>
90145
</BehaviorTree>
91146
<TreeNodesModel>
92-
<SubTree ID="Vector and String Example">
93-
<MetadataFields>
94-
<Metadata runnable="true" />
95-
<Metadata subcategory="Vector Handling" />
96-
</MetadataFields>
97-
</SubTree>
147+
<SubTree ID="Vector and String Example" />
98148
</TreeNodesModel>
99149
</root>

0 commit comments

Comments
 (0)