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

Added pre-commit and license #150

Merged
merged 4 commits into from
Dec 14, 2024
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
1 change: 1 addition & 0 deletions .codespell-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fof
2 changes: 2 additions & 0 deletions .github/LICENSE_HEADER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright (c) 2024, Personal Robotics Laboratory
License: BSD 3-Clause. See LICENSE.md file in root directory.
18 changes: 9 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Describe this pull request. Link to relevant GitHub issues, if any.

[TODO]
\[TODO\]

## Explain how this pull request was tested, including but not limited to the below checkmarks.

[TODO]
\[TODO\]

***
______________________________________________________________________

**Before creating a pull request**

- [ ] Format React code with `npm run format`
- [ ] Format Python code by running `python3 -m black .` in the top-level of this repository
- [ ] Thoroughly test your code's functionality, including unintended uses.
- [ ] Fully test the responsiveness of the feature as documented in the [Responsiveness Testing Guidelines](https://github.com/personalrobotics/feeding_web_interface/blob/main/feedingwebapp/ResponsivenessTesting.md). If you deviate from those guidelines, document above why you deviated and what you did instead.
- [ ] Consider the user flow between states that this feature introduces, consider different situations that might occur for the user, and ensure that there is no way for the user to get stuck in a loop.
- \[ \] Format React code with `npm run format`
- \[ \] Format Python code by running `python3 -m black .` in the top-level of this repository
- \[ \] Thoroughly test your code's functionality, including unintended uses.
- \[ \] Fully test the responsiveness of the feature as documented in the [Responsiveness Testing Guidelines](https://github.com/personalrobotics/feeding_web_interface/blob/main/feedingwebapp/ResponsivenessTesting.md). If you deviate from those guidelines, document above why you deviated and what you did instead.
- \[ \] Consider the user flow between states that this feature introduces, consider different situations that might occur for the user, and ensure that there is no way for the user to get stuck in a loop.

**Before merging a pull request**

- [ ] Squash all your commits into one (or `Squash and Merge`)
- \[ \] Squash all your commits into one (or `Squash and Merge`)
3 changes: 3 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

name: pre-commit

on:
push:
branches:
- main
- master
- ros2-devel
pull_request:
workflow_dispatch:

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

env:
PYTHON_VERSION: "3.10"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

## Run pre-commit and try to apply fixes
- name: Run pre-commit
uses: pre-commit/[email protected]
- name: Apply fixes from pre-commit
uses: pre-commit-ci/[email protected]
if: always()
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install --force-reinstall pylint==3.1.0
# pip install overrides
# - name: Analysing the code with pylint
# run: |
# pylint --recursive=y --rcfile=.pylintrc . --disable fixme --disable import-error
82 changes: 82 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.0
hooks:
- id: insert-license
args:
- --license-file
- .github/LICENSE_HEADER.md
- --use-current-year
types_or: [python, yaml]

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.0
hooks:
- id: insert-license
args:
- --license-file
- .github/LICENSE_HEADER.md
- --use-current-year
- --comment-style
- "<!--| |-->"
types_or: [xml, html]
exclude: ".*package\\.xml$|.*\\.xacro$|.*\\.svg$"

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.0
hooks:
- id: insert-license
args:
- --license-file
- .github/LICENSE_HEADER.md
- --use-current-year
- --comment-style
- "/*| *| */"
types_or: [javascript, jsx, ts, tsx, css]

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black

- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
args:
- --number

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args:
- --ignore-words=.codespell-ignore
exclude: ".*\\.svg$|.*package-lock\\.json$"
28 changes: 28 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2024, Personal Robotics Laboratory

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion feeding_web_app_ros2_msgs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# feeding_web_app_ros2_msgs

This directory contains custom messages used by the nodes in `feeding_web_app_ros2_test` that are **NOT** robot interfaces. Robot interface messages are in [`ada_feeding` (branch: `ros2-devel`)](https://github.com/personalrobotics/ada_feeding/tree/ros2-devel).
This directory contains custom messages used by the nodes in `feeding_web_app_ros2_test` that are **NOT** robot interfaces. Robot interface messages are in [`ada_feeding` (branch: `ros2-devel`)](https://github.com/personalrobotics/ada_feeding/tree/ros2-devel).
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ string input
---
string result
---
float32 progress
float32 progress
2 changes: 1 addition & 1 deletion feeding_web_app_ros2_msgs/srv/ReverseString.srv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
string input
---
string reversed
string reversed
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See the [`ada_feeding` top-level README for setup instructions](https://github.c
To launch the dummy nodes, rosbridge, and web_video_server, run `source install/setup.bash; ros2 launch feeding_web_app_ros2_test feeding_web_app_dummy_nodes_launch.xml`.

You can also toggle off certain combinations of dummy nodes with arguments:

- **Don't run motion nodes**: `ros2 launch feeding_web_app_ros2_test feeding_web_app_dummy_nodes_launch.xml run_motion:=false`
- **Don't run the face detection node**: `ros2 launch feeding_web_app_ros2_test feeding_web_app_dummy_nodes_launch.xml :run_face_detection=false`
- **Don't run the food detection node**: `ros2 launch feeding_web_app_ros2_test feeding_web_app_dummy_nodes_launch.xml :run_food_detection=false`
Expand All @@ -21,10 +22,12 @@ You can also combine any of the above arguments.
## Simulating an AcquireFood Goal

If you launch the code in `--sim mock` (see [here](https://github.com/personalrobotics/ada_feeding/blob/ros2-devel/README.md)), using bite selection through the app should properly call AcquireFood, and you should be able to see the acquisition action in RVIZ (it is recommended to add an `Axes` visualization to RVIZ for the `food` frame to see the perceived top-center and orientation of the detected food item). However, this approach has two downsides:

1. The detected food mask is a dummy mask, not a real output of SegmentAnything.
2. Each time you use the app to invoke AcquireFood, the mask and depth will be slightly different, which is a challenge for repeatability.

To address these issues, we have pickled goal request(s) from the app to the AcquireFood action. These goal request(s) were Segmented by the actual `SegmentFromPoint` node with the dummy RGB and depth images (found in `./data`). To invoke bite acquisition with this static goal request, do the following:

1. `cd ~/colcon_ws`
2. `python3 src/ada_feeding/start-py --sim mock`. See [here](https://github.com/personalrobotics/ada_feeding/blob/ros2-devel/README.md) for more info.
3. `ros2 launch feeding_web_app_ros2_test feeding_dummy_acquirefood_launch.py`. This will have the robot move above the plate, and then invoke `AcquireFood` for the stored goal request.
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/AcquireFood.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import AcquireFood
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/AcquireFoodClient.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python3

# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

# Standard imports
import pickle

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python3

# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

# Standard imports
import array
import threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.msg import FaceDetection
from std_srvs.srv import SetBool
import cv2
Expand Down Expand Up @@ -96,13 +99,13 @@ def toggle_face_detection_callback(self, request, response):
self.is_on = True
self.is_on_lock.release()
response.success = True
response.message = "Succesfully turned face detection on"
response.message = "Successfully turned face detection on"
else:
self.is_on_lock.acquire()
self.is_on = False
self.is_on_lock.release()
response.success = True
response.message = "Succesfully turned face detection off"
response.message = "Successfully turned face detection off"
return response

def camera_callback(self, msg):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.msg import FoodOnForkDetection
from std_srvs.srv import SetBool
import rclpy
Expand Down Expand Up @@ -78,13 +81,13 @@ def toggle_food_on_fork_detection_callback(self, request, response):
self.is_on = True
self.is_on_lock.release()
response.success = True
response.message = "Succesfully turned food-on-fork detection on"
response.message = "Successfully turned food-on-fork detection on"
else:
self.is_on_lock.acquire()
self.is_on = False
self.is_on_lock.release()
response.success = True
response.message = "Succesfully turned food-on-fork detection off"
response.message = "Successfully turned food-on-fork detection off"
return response

def camera_callback(self, msg):
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveAbovePlate.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveFromMouth.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveFromMouthToAbovePlate.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveFromMouthToRestingPosition.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

import rclpy
from rclpy.action import ActionServer, CancelResponse, GoalResponse
from rclpy.node import Node
Expand Down Expand Up @@ -64,7 +66,7 @@ def goal_callback(self, goal_request):
def cancel_callback(self, goal_handle):
"""
Always accept client requests to cancel the active goal. Note that this
function should not actually impelement the cancel; that is handled in
function should not actually implement the cancel; that is handled in
`execute_callback`

Parameters
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveToMouth.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveToMouth
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveToRestingPosition.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
3 changes: 3 additions & 0 deletions feeding_web_app_ros2_test/feeding_web_app_ros2_test/MoveToStagingConfiguration.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3
# Copyright (c) 2024, Personal Robotics Laboratory
# License: BSD 3-Clause. See LICENSE.md file in root directory.

from ada_feeding_msgs.action import MoveTo
from feeding_web_app_ros2_test.MoveToDummy import MoveToDummy
import rclpy
Expand Down
Loading
Loading