Skip to content
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

Implement behavior tree #22

Merged
merged 32 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1f5c7fe
Started development of a cleaned up dockerfile
evan-palmer Aug 2, 2023
07e5110
Continued docker setup
evan-palmer Aug 2, 2023
8873287
Finished up updated dockerfile
evan-palmer Aug 3, 2023
4d60645
here we go again
evan-palmer Aug 3, 2023
4c2065e
Removed armv7
evan-palmer Aug 3, 2023
1eaf5ea
Added requirement for vtk
evan-palmer Aug 3, 2023
bb5542d
Replaced kinpy installation with fork
evan-palmer Aug 3, 2023
3cc8b98
Added updated docker compose script
evan-palmer Aug 4, 2023
544f239
Moved tf to blue
evan-palmer Aug 4, 2023
0504519
Started integration of a bezier curve planner
evan-palmer Aug 6, 2023
d467331
Split kinematics into separate package
evan-palmer Aug 7, 2023
8cb5224
Started arming behaviors
evan-palmer Aug 7, 2023
3f02a24
Removed drake stuff and finished arming behaviors
evan-palmer Aug 8, 2023
b0bdead
Created base controller
evan-palmer Aug 9, 2023
481dcac
Started implementing trajectory controller
evan-palmer Aug 9, 2023
74e59dd
wip: continued joint trajectory controller implementation
evan-palmer Aug 10, 2023
7a77dec
Finished initial version of trajectory interface
evan-palmer Aug 11, 2023
34a48d8
Rebuild image to include blue changes
evan-palmer Aug 12, 2023
c5a3b81
Finished joint trajectory controller
evan-palmer Aug 14, 2023
29419a8
wip: finished initial version of behavior tree
evan-palmer Aug 15, 2023
4158cb7
removed branch from pipeline
evan-palmer Aug 15, 2023
8b82489
Started debugging tree
evan-palmer Aug 16, 2023
1dab4b3
Fixed data gathering behaviors
evan-palmer Aug 21, 2023
ef97ea1
Finished debugging behavior tree
evan-palmer Aug 22, 2023
28911ab
Finished initial version of behavior tree
evan-palmer Aug 22, 2023
7b063b4
Added gripper and cleanup behaviors
evan-palmer Aug 22, 2023
41622fc
started trajectory replanner
evan-palmer Aug 22, 2023
76dde5e
Cleaned up params
evan-palmer Aug 24, 2023
b085320
cleaned up behavior tree
evan-palmer Aug 24, 2023
6f3f9fc
Resolved pr comments as much as i feel like resolving them
evan-palmer Aug 29, 2023
82fc13b
Fixed bug in frame names
evan-palmer Aug 29, 2023
92931c6
updated issue templates
evan-palmer Aug 29, 2023
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
330 changes: 172 additions & 158 deletions .docker/Dockerfile

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

# Except the following
!angler_bringup
!angler_control
!angler_description
!angler_planning
!angler_msgs
!angler_mux
!angler_utils
!angler_kinematics
!angler_behaviors
!angler.repos
!sim.repos
!.docker/entrypoints
!requirements-build.txt
!requirements-dev.txt
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bug Report
description: Report a bug.
title: "[BUG]: <Please write a descriptive title after the '[BUG]: ' prefix>"
labels: [bug]
labels: [bug, needs triage]

body:
- type: markdown
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Documentation Improvement
description: Report an issue related to the Angler documentation.
title: "[DOC]: <Please write a descriptive title after the '[DOC]: ' prefix>"
labels: [documentation]
labels: [documentation, needs triage]

body:
- type: markdown
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Feature Request
description: Suggest a new idea for the project.
title: "[FEATURE]: <Please write a descriptive title after the '[FEATURE]: ' prefix>"
labels: [enhancement]
labels: [enhancement, needs triage]

body:
- type: markdown
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
submodules: recursive

- name: Log into registry
uses: docker/login-action@v2.0.0
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
54 changes: 51 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/login-action@v2.0.0
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -40,14 +40,14 @@ jobs:
- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/metadata-action@v4.0.1
uses: docker/metadata-action@v4.6.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/build-push-action@v3.0.0
uses: docker/build-push-action@v4.1.1
with:
context: .
file: .docker/Dockerfile
Expand All @@ -56,3 +56,51 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}

robot:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble, rolling, iron]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
platforms: linux/amd64,linux/arm64
17 changes: 6 additions & 11 deletions angler.repos
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ repositories:
url: https://github.com/evan-palmer/blue.git
version: main

ros_gz:
kinpy:
type: git
url: https://github.com/gazebosim/ros_gz
version: ros2
url: https://github.com/evan-palmer/kinpy.git
version: master

gz-plugin:
py_trees_ros_viewer:
type: git
url: https://github.com/gazebosim/gz-plugin.git
version: gz-plugin2

gz_ros2_control:
type: git
url: https://github.com/evan-palmer/gz_ros2_control.git
version: patch-rolling-garden
url: https://github.com/splintered-reality/py_trees_ros_viewer.git
version: devel
17 changes: 17 additions & 0 deletions angler_behaviors/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
31 changes: 31 additions & 0 deletions angler_behaviors/behavior_tree/behaviors/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023, Evan Palmer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import py_trees


def make_on_mission_complete_behavior() -> py_trees.behaviour.Behaviour:
"""Make a behavior that initiates a post-mission completion sequence.
Returns:
A post-mission behavior.
"""
# For now, we just idle on mission completion
return py_trees.behaviours.Running("Idle")
64 changes: 64 additions & 0 deletions angler_behaviors/behavior_tree/behaviors/configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2023, Evan Palmer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import operator

import py_trees
from behavior_tree.primitives.arming import make_system_arming_behavior


def make_setup_behavior(
setup_finished_flag_key: str, armed_key: str
) -> py_trees.behaviour.Behaviour:
"""Make a behavior that sets up the system prior to beginning a mission.

Args:
setup_finished_flag_key: The key at which the setup flag is stored.

Returns:
A system setup behavior.
"""
# Don't repeat setup if we have already done it
check_setup_finished = py_trees.behaviours.CheckBlackboardVariableValue(
name="Setup complete?",
check=py_trees.common.ComparisonExpression(
variable=setup_finished_flag_key, value=True, operator=operator.eq
),
)

# Once we have a plan, arm so that we can start trajectory tracking
arming = make_system_arming_behavior(
arm=True, armed_key=armed_key, use_passthrough_mode=True
)

# Finish up by indicating that the setup has finished
finished_setup = py_trees.behaviours.SetBlackboardVariable(
"Setup finished!", setup_finished_flag_key, True, overwrite=True
)

setup = py_trees.composites.Sequence(
name="Setup the system for a mission",
memory=True,
children=[arming, finished_setup],
)

return py_trees.composites.Selector(
name="Run system setup", memory=False, children=[check_setup_finished, setup]
)
95 changes: 95 additions & 0 deletions angler_behaviors/behavior_tree/behaviors/mission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2023, Evan Palmer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import operator

import py_trees
import py_trees_ros
from behavior_tree.primitives.control import make_execute_multidof_trajectory_behavior
from behavior_tree.primitives.planning import make_high_level_planning_behavior


def make_save_start_mission_behavior(
start_mission_key: str,
) -> py_trees.behaviour.Behaviour:
"""Make a behavior that saves the "start mission" flag to the blackboard.

Args:
start_mission_key: The key at which the flag should be saved.

Returns:
A behavior that saves the key to trigger arming.
"""
return py_trees_ros.subscribers.EventToBlackboard(
name="ROS2BB: Start mission",
topic_name="/angler/cmd/start_mission",
qos_profile=py_trees_ros.utilities.qos_profile_unlatched(),
variable_name=start_mission_key,
)


def make_execute_mission_behavior(
start_mission_key: str,
robot_state_key: str,
planner_id: str,
controller_id: str,
) -> py_trees.behaviour.Behaviour:
"""Make a behavior that executes a mission.

Args:
start_mission_key: The key at which the signal indicating that a mission should
start is stored.
robot_state_key: The key at which the robot state is stored.
planner_id: The key at which the high-level planner ID is stored.
controller_id: The key at which the joint trajectory controller ID is
stored.

Returns:
A system setup behavior.
"""
# Start by checking whether or not to start the mission
check_start_mission = py_trees.behaviours.CheckBlackboardVariableValue(
name="Start the mission?",
check=py_trees.common.ComparisonExpression(
variable=start_mission_key, value=True, operator=operator.eq
),
)

planning_result_key = "planning_result"

get_mission_plan = make_high_level_planning_behavior(
robot_state_key=robot_state_key,
planner_id=planner_id,
planning_result_key=planning_result_key,
)

execute_mission = make_execute_multidof_trajectory_behavior(
trajectory_key=planning_result_key, controller_id=controller_id
)

return py_trees.composites.Sequence(
name="Execute mission",
memory=True,
children=[
check_start_mission,
get_mission_plan,
execute_mission,
],
)
Loading