forked from PickNikRobotics/moveit_pro_empty_ws
-
Notifications
You must be signed in to change notification settings - Fork 6
Objectathon Example Vector and String Handling #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "moveit_pro shell" 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.