Skip to content

Commit

Permalink
Merge pull request #39 from brown-ccv/add-black-checks
Browse files Browse the repository at this point in the history
chore: add black checks
  • Loading branch information
hollandjg authored Oct 8, 2024
2 parents 1628d28 + f35ffe1 commit 7ebd79e
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 267 deletions.
8 changes: 7 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/python:1": {}
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.black-formatter"
]
}
}
10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
7 changes: 3 additions & 4 deletions norms/ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ def create_root() -> py_trees.behaviour.Behaviour:
eventually=py_trees.common.Status.SUCCESS,
)
approach = py_trees.behaviours.Running(name="Approach Ball")

move_to_ball.add_children([isClose, approach])


isGrasped = py_trees.behaviours.StatusQueue(
name="Ball Grasped?",
queue=[
Expand All @@ -160,7 +159,7 @@ def create_root() -> py_trees.behaviour.Behaviour:
eventually=py_trees.common.Status.SUCCESS,
)
grasp = py_trees.behaviours.Running(name="Grasp Ball")

obtain_ball.add_children([isGrasped, grasp])

return root
Expand Down Expand Up @@ -204,4 +203,4 @@ def main() -> None:


if __name__ == "__main__":
main()
main()
29 changes: 14 additions & 15 deletions norms/ball_blackboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
blackboard.isBallClose = False
blackboard.isBallGrasped = False


def description() -> str:
"""
Print description and usage information about the program.
Expand Down Expand Up @@ -146,28 +147,26 @@ def create_root() -> py_trees.behaviour.Behaviour:

print(blackboard)


isClose = py_trees.behaviours.CheckBlackboardVariableValue(
name="Ball Close?",
check=py_trees.common.ComparisonExpression(
variable="isBallClose", value=True, operator=operator.eq
),
)
name="Ball Close?",
check=py_trees.common.ComparisonExpression(
variable="isBallClose", value=True, operator=operator.eq
),
)

approach = py_trees.behaviours.Running(name="Approach Ball")

move_to_ball.add_children([isClose, approach])

move_to_ball.add_children([isClose, approach])

isGrasped = py_trees.behaviours.CheckBlackboardVariableValue(
name="Ball Grasped?",
check=py_trees.common.ComparisonExpression(
variable="isBallGrasped", value=True, operator=operator.eq
),
)
name="Ball Grasped?",
check=py_trees.common.ComparisonExpression(
variable="isBallGrasped", value=True, operator=operator.eq
),
)

grasp = py_trees.behaviours.Running(name="Grasp Ball")

obtain_ball.add_children([isGrasped, grasp])

return root
Expand Down Expand Up @@ -218,4 +217,4 @@ def main() -> None:


if __name__ == "__main__":
main()
main()
99 changes: 45 additions & 54 deletions norms/deliver_medicine.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
blackboard.isElevatorOn7th = False
blackboard.canLeaveElevator = False


def description() -> str:
"""
Print description and usage information about the program.
Expand Down Expand Up @@ -128,6 +129,7 @@ def command_line_argument_parser() -> argparse.ArgumentParser:
)
return parser


def wait(name, ticks) -> py_trees.behaviours.StatusQueue:
queue = []
for i in range(0, ticks + 1):
Expand All @@ -150,7 +152,6 @@ def create_root() -> py_trees.behaviour.Behaviour:

root = py_trees.composites.Sequence(name="Sequence", memory=False)


get_medicine = py_trees.composites.Sequence(name="Sequence", memory=False)

take_elevator = py_trees.composites.Sequence(name="Sequence", memory=False)
Expand All @@ -159,74 +160,71 @@ def create_root() -> py_trees.behaviour.Behaviour:

root.add_children([get_medicine, take_elevator, deliver_medicine])



go_to = py_trees.behaviours.Success(name="Go To Medicine Cabinet")
unlock = py_trees.composites.Selector(name="Selector", memory=False)
take = py_trees.behaviours.Success(name="Take Medicine")
get_medicine.add_children([go_to, unlock, take])

unlock_cabinet = py_trees.behaviours.CheckBlackboardVariableValue(
name="Unlock Cabinet",
check=py_trees.common.ComparisonExpression(
variable="isCabinetUnlocked", value=True, operator=operator.eq
),
)
name="Unlock Cabinet",
check=py_trees.common.ComparisonExpression(
variable="isCabinetUnlocked", value=True, operator=operator.eq
),
)
wait_cabinet = wait("Wait for at most 3 Ticks", 3)
supervisor = py_trees.behaviours.Success(name="Call Supervisor for Virtual Unlock")
unlock.add_children([unlock_cabinet, wait_cabinet, supervisor])


go_to_elevator = py_trees.behaviours.Success(name="Go to Elevator")
click_up_button = py_trees.behaviours.Success(name="Click Up Button")
wait_for_elevator = py_trees.composites.Sequence(name="Sequence", memory=False)
enter_elevator = py_trees.composites.Sequence(name="Sequence", memory=False)

take_elevator.add_children([go_to_elevator, click_up_button, wait_for_elevator, enter_elevator])
take_elevator.add_children(
[go_to_elevator, click_up_button, wait_for_elevator, enter_elevator]
)

is_elevator_open = py_trees.composites.Selector(name="Selector", memory=False)
has_space_in_elevator = py_trees.composites.Selector(name="Selector", memory=False)
can_enter_elevator = py_trees.composites.Selector(name="Selector", memory=False)
wait_for_elevator.add_children([is_elevator_open, has_space_in_elevator, can_enter_elevator])

wait_for_elevator.add_children(
[is_elevator_open, has_space_in_elevator, can_enter_elevator]
)

elevator_open = py_trees.behaviours.CheckBlackboardVariableValue(
name="Is Elevator Open?",
check=py_trees.common.ComparisonExpression(
variable="isElevatorOpen", value=True, operator=operator.eq
),
)
name="Is Elevator Open?",
check=py_trees.common.ComparisonExpression(
variable="isElevatorOpen", value=True, operator=operator.eq
),
)
wait_for_open_elevator = wait("Wait for at most 5 Ticks", 5)
supervisor = py_trees.behaviours.Success(name="Call Supervisor to Virtually Call Elevator")
supervisor = py_trees.behaviours.Success(
name="Call Supervisor to Virtually Call Elevator"
)
is_elevator_open.add_children([elevator_open, wait_for_open_elevator, supervisor])

elevator_space = py_trees.behaviours.CheckBlackboardVariableValue(
name=">= 9ft^2 of space in the Elevator?",
check=py_trees.common.ComparisonExpression(
variable="elevatorHasSpace", value=True, operator=operator.eq
),
)
wait_for_space = py_trees.behaviours.Running(name="State \'I’ll wait\'")
name=">= 9ft^2 of space in the Elevator?",
check=py_trees.common.ComparisonExpression(
variable="elevatorHasSpace", value=True, operator=operator.eq
),
)
wait_for_space = py_trees.behaviours.Running(name="State 'I’ll wait'")
has_space_in_elevator.add_children([elevator_space, wait_for_space])

elevator_enter = py_trees.behaviours.CheckBlackboardVariableValue(
name="Ask to enter Elevator",
check=py_trees.common.ComparisonExpression(
variable="canEnterElevator", value=True, operator=operator.eq
),
)
name="Ask to enter Elevator",
check=py_trees.common.ComparisonExpression(
variable="canEnterElevator", value=True, operator=operator.eq
),
)
wait_to_enter_elevator = py_trees.behaviours.Running(name="State I’ll wait")
can_enter_elevator.add_children([elevator_enter, wait_to_enter_elevator])





enter_elevator_task = py_trees.behaviours.Success(name="Enter Elevator")
hit_7th_floor_button = py_trees.behaviours.Success(name="Hit 7th Floor Button")
enter_elevator.add_children([enter_elevator_task, hit_7th_floor_button])


exit = py_trees.composites.Sequence(name="Sequence", memory=False)
exit_statement = py_trees.behaviours.Success(name="State: I'll exit now")
go_to_patient = py_trees.behaviours.Success(name="Go to Patient")
Expand All @@ -235,34 +233,27 @@ def create_root() -> py_trees.behaviour.Behaviour:

get_to_7th = py_trees.composites.Selector(name="Selector", memory=False)
can_exit_now = py_trees.composites.Selector(name="Selector", memory=False)

exit.add_children([get_to_7th, can_exit_now])

is_elevator_on_7th = py_trees.behaviours.CheckBlackboardVariableValue(
name="Is Elevator on 7th?",
check=py_trees.common.ComparisonExpression(
variable="isElevatorOn7th", value=True, operator=operator.eq
),
)
name="Is Elevator on 7th?",
check=py_trees.common.ComparisonExpression(
variable="isElevatorOn7th", value=True, operator=operator.eq
),
)
elevator_wait = py_trees.behaviours.Running(name="Wait")
get_to_7th.add_children([is_elevator_on_7th, elevator_wait])

are_people_on_elevator = py_trees.behaviours.CheckBlackboardVariableValue(
name="Is >= 1 Person in Elevator?",
check=py_trees.common.ComparisonExpression(
variable="canLeaveElevator", value=True, operator=operator.eq
),
)
name="Is >= 1 Person in Elevator?",
check=py_trees.common.ComparisonExpression(
variable="canLeaveElevator", value=True, operator=operator.eq
),
)
exit_elevator_wait = wait("Wait for at most 3 Ticks", 3)
can_exit_now.add_children([are_people_on_elevator, exit_elevator_wait])








return root


Expand Down Expand Up @@ -330,4 +321,4 @@ def main() -> None:


if __name__ == "__main__":
main()
main()
Loading

0 comments on commit 7ebd79e

Please sign in to comment.