Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
45 changes: 45 additions & 0 deletions src/lab_sim/objectives/errorcheckvectorsize.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<root BTCPP_format="4" main_tree_to_execute="ErrorCheckVectorSize">
<!--//////////-->
<BehaviorTree
ID="ErrorCheckVectorSize"
_description="Assert that the input vector is the expected length, and if not show a UI error and return FAILURE"
>
<Control ID="Sequence">
<Action
ID="GetSizeOfVector"
vector_in="{vector}"
vector_size="{vector_size}"
/>
<Decorator
ID="Precondition"
else="SUCCESS"
if="vector_size!=expected_vector_size"
name="Error Check "
>
<Control ID="Sequence">
<Action
ID="LogMessage"
log_level="error"
message="'Vector size is wrong'"
/>
<Action ID="AlwaysFailure" />
</Control>
</Decorator>
</Control>
</BehaviorTree>
<TreeNodesModel>
<SubTree ID="ErrorCheckVectorSize">
<MetadataFields>
<Metadata runnable="false" />
<Metadata subcategory="Vector Handling" />
</MetadataFields>
<inout_port name="expected_vector_size" default="1" type="int">
The size the vector should be
</inout_port>
<inout_port name="vector" default="{vector}">
The input vector that is to be checked for size.
</inout_port>
</SubTree>
</TreeNodesModel>
</root>
3 changes: 3 additions & 0 deletions src/lab_sim/objectives/example_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1) A robot may not injure a human being or, through inaction, allow a human being to come to harm;
2) A robot must obey orders from a human, except when they conflict with the First Law; and
3) A robot must protect its own existence, provided it doesn't conflict with the First or Second Law.
149 changes: 149 additions & 0 deletions src/lab_sim/objectives/vector_and_string_example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8" ?>
<root BTCPP_format="4" main_tree_to_execute="Vector and String Example">
<BehaviorTree
ID="Vector and String Example"
_description="Showcases creating, inserting, replacing, and removing strings from a vector, as well as reading strings from file and publishing them to ROS."
_favorite="false"
>
<Control ID="Sequence" name="TopLevelSequence">
<Action ID="ResetVector" vector="{my_vector}" name="Create the Vector" />
<Control ID="Sequence" name="Test Some Vector Operations">
<Action
ID="Script"
code="string1 := 'Copy and run the following command in your &quot;moveit_pro shell&quot; terminal, then rerun this Objective to get the secret message.'"
/>
<Action
ID="CreateStringMessage"
data="{string1}"
string="{string_msg_in}"
/>
<Action
ID="InsertInVector"
element="{string_msg_in}"
index="0"
input_vector="{my_vector}"
output_vector="{my_vector}"
/>
<SubTree
ID="ErrorCheckVectorSize"
_collapsed="true"
expected_vector_size="1"
vector="{my_vector}"
/>
<Action
ID="GetElementOfVector"
element="{string_msg_out}"
index="0"
vector_in="{my_vector}"
/>
<Action
ID="UnpackStringMessage"
data="{string}"
string="{string_msg_out}"
/>
<Action
ID="LogMessage"
message="ros2 topic echo /secret_msg std_msgs/msg/String --qos-profile system_default"
log_level="info"
/>
<Action ID="LogMessage" message="{string}" log_level="info" />
</Control>
<Control ID="Sequence" name="Test Some Vector Operations">
<Action
ID="RemoveFromVector"
index="0"
input_vector="{my_vector}"
output_vector="{my_vector}"
/>
<SubTree
ID="ErrorCheckVectorSize"
_collapsed="true"
expected_vector_size="0"
vector="{my_vector}"
/>
</Control>
<Control ID="Sequence" name="Test Some Vector Operations">
<Action
ID="ReadTextFileAsString"
string_file_contents="{string2}"
text_filename="example_file.txt"
/>
<Action
ID="CreateStringMessage"
data="{string2}"
string="{string_msg_in}"
/>
<Action
ID="InsertInVector"
element="{string_msg_in}"
index="0"
input_vector="{my_vector}"
output_vector="{my_vector}"
/>
<Action
ID="GetElementOfVector"
element="{string_msg_out}"
index="0"
vector_in="{my_vector}"
/>
<Action
ID="PublishString"
queue_size="10"
use_best_effort="false"
message="{string_msg_out}"
topic="/secret_msg"
/>
<SubTree
ID="ErrorCheckVectorSize"
_collapsed="true"
expected_vector_size="1"
vector="{my_vector}"
/>
</Control>
<Control ID="Sequence" name="Test Some Vector Operations">
<Action
ID="Script"
code="string3 := 'Make sure you have INFO alert types enables in order to see the messages.'"
/>
<Action
ID="CreateStringMessage"
data="{string3}"
string="{string_msg_in}"
/>
<Action
ID="ReplaceInVector"
element="{string_msg_in}"
index="0"
input_vector="{my_vector}"
output_vector="{my_vector}"
/>
<Action
ID="GetElementOfVector"
element="{string_msg_out}"
index="0"
vector_in="{my_vector}"
/>
<Action
ID="UnpackStringMessage"
data="{string}"
string="{string_msg_out}"
/>
<SubTree
ID="ErrorCheckVectorSize"
_collapsed="true"
expected_vector_size="1"
vector="{my_vector}"
/>
<Action ID="LogMessage" message="{string}" log_level="warn" />
</Control>
</Control>
</BehaviorTree>
<TreeNodesModel>
<SubTree ID="Vector and String Example">
<MetadataFields>
<Metadata subcategory="Vector Handling" />
<Metadata runnable="true" />
</MetadataFields>
</SubTree>
</TreeNodesModel>
</root>