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

Misc changes #75

Merged
merged 47 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
32ebc50
Update industrial_ci_action.yml
InvincibleRMC Oct 23, 2023
ab7300d
Update industrial_ci_action.yml
InvincibleRMC Oct 23, 2023
151c361
Merge remote-tracking branch 'origin/main' into pylint
InvincibleRMC Oct 29, 2023
36c3dfc
Merge branch 'main' into pylint
InvincibleRMC Dec 3, 2023
1615c5a
clean up constants
InvincibleRMC Dec 3, 2023
f29ce97
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
c0c3b2b
docstrings for testing
InvincibleRMC Dec 3, 2023
b07c2e1
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
072ca43
sub
InvincibleRMC Dec 3, 2023
ac617ae
sub
InvincibleRMC Dec 3, 2023
fa74e4d
yippee?
InvincibleRMC Dec 3, 2023
0194c04
remove extra newline
InvincibleRMC Dec 3, 2023
c4c81c3
pep257
InvincibleRMC Dec 3, 2023
6413a65
Merge branch 'pylint' into misc-changes
InvincibleRMC Dec 3, 2023
6900175
remove pylint stuff
InvincibleRMC Dec 3, 2023
45cdf7d
fix flake8 test
InvincibleRMC Dec 3, 2023
263ab59
add back pylint check oops
InvincibleRMC Dec 3, 2023
743e8a5
disable duplicate-code
InvincibleRMC Dec 3, 2023
8f8bc2c
pyqt6 pain
InvincibleRMC Dec 3, 2023
2494b70
more cleanup
InvincibleRMC Dec 3, 2023
201f428
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
56401f5
fixmes are cool with me
InvincibleRMC Dec 3, 2023
6eced2c
zoggers
InvincibleRMC Dec 3, 2023
948772e
fix import order
InvincibleRMC Dec 3, 2023
c96cea5
pylint
InvincibleRMC Dec 3, 2023
8909ff7
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
1dbc37d
l
InvincibleRMC Dec 3, 2023
a978159
add docstrings to pi
InvincibleRMC Dec 3, 2023
683cbbf
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
c8cae3a
add header
InvincibleRMC Dec 3, 2023
9aa9746
fix pep257 failings
InvincibleRMC Dec 3, 2023
efd289e
Merge branch 'misc-changes' into pylint
InvincibleRMC Dec 3, 2023
c2d6408
docstrings 2
InvincibleRMC Dec 3, 2023
e7d2e2a
fixed test
InvincibleRMC Dec 3, 2023
b75147e
yipppee
InvincibleRMC Dec 3, 2023
8e791ab
add periods.
InvincibleRMC Dec 3, 2023
59150f0
module docstrings
InvincibleRMC Dec 3, 2023
b95885f
better setup.py
InvincibleRMC Dec 4, 2023
1bd2953
add missing period.
InvincibleRMC Dec 4, 2023
3c66723
add missing module docstrings
InvincibleRMC Dec 4, 2023
592a5b5
yippe
InvincibleRMC Dec 4, 2023
07566ef
Merge remote-tracking branch 'origin/main' into misc-changes
InvincibleRMC Dec 4, 2023
ac613d4
add example
InvincibleRMC Dec 4, 2023
d4a4058
add extension
InvincibleRMC Dec 4, 2023
24e1594
add to setup
InvincibleRMC Dec 4, 2023
9580311
Merge remote-tracking branch 'origin/main' into misc-changes
InvincibleRMC Dec 4, 2023
37b4ff4
in vscode
InvincibleRMC Dec 4, 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
2 changes: 1 addition & 1 deletion .github/workflows/industrial_ci_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
DOCKER_IMAGE: ghcr.io/cwrurobotics/rov-24:main
ROS_REPO: ${{ matrix.ROS_REPO }}
# Crazy one liner for install python dependencies
AFTER_INSTALL_TARGET_DEPENDENCIES_EMBED: 'for d in /root/target_ws/src/rov-24/src/pi/*/ /root/target_ws/src/rov-24/src/surface/*/; do pip install -e "$d"; done'
AFTER_INSTALL_TARGET_DEPENDENCIES_EMBED: 'for d in /root/target_ws/src/rov-24/src/pi/*/ /root/target_ws/src/rov-24/src/surface/*/; do pip install -e "$d"; done'
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[main]
disable=duplicate-code,fixme
extension-pkg-whitelist=PyQt6,cv2
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ git clone --recurse-submodules git@github.com:cwruRobotics/rov-24.git

If you've never contributed to a git repository before, you might receive an error message saying you don't have access. In that case visit [this tutorial](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh) to set up SSH for local GitHub access.

After cloning the code, we need to set up our IDE: VSCode. If you already have it, great. Otherwise follow [this](https://code.visualstudio.com/download) tutorial.
After cloning the code, we need to set up our IDE: VSCode. If you already have it, great. Otherwise follow [this](https://code.visualstudio.com/download) tutorial. We recommend installing the mypy, flake8 and autoDocstring VSCode extensions. Our setting for autoDocstring are set to Numpy and auto docstring on new line.

### Linux

Expand Down Expand Up @@ -134,6 +134,8 @@ If you're working on package's `setup.py` or rov_msgs, you'll need to run `🏃

If you want to run our unit tests use this command `colcon test --event-handlers=console_direct+`.

n VSCode, press `F1` or `ctrl+shift+p` and enter `Tasks: Run Test Task` as another method to run the above command.
InvincibleRMC marked this conversation as resolved.
Show resolved Hide resolved

It runs the tests and pipes the output to the terminal. To test pi_main make sure to type your password into the terminal after running the above command.

If you install the flake8 and mypy extension they should help enforce the linters.
Expand Down Expand Up @@ -173,5 +175,26 @@ Any topics or services communicating across will be renamed first into the tethe
Documentation will take place at 3 levels:

- High Level - Overarching Design Document outlining our general structure and what goes where.
- Device Level - ROS Docs as set out in the ROS2 standards.
- Inline Level - Inline Documentation to the level that someone who has some basic code knowledge can understand what the code does.
- Device Level - Following the markdown tempate in `doc` directory.
- Inline Level - Using reST / Numpy Standard. To autogenerate in VSCode we use autoDocstring extension with the setting set to Numpy and auto docstring on new line. Below is an example of an inline function docstring.

```python
def __init__(self, srv_type: SrvType, topic: str, signal: pyqtBoundSignal,
timeout: float = 1.0, expected_namespace: str = '/surface/gui'):
"""
_summary_

Parameters
----------
srv_type : SrvType
_description_
topic : str
_description_
signal : pyqtBoundSignal
_description_
timeout : float, optional
_description_, by default 1.0
expected_namespace : str, optional
_description_, by default '/surface/gui'
"""
```
9 changes: 9 additions & 0 deletions src/pi/camera_streamer/launch/camera_launch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"""camera_streamer launch file."""
from launch.launch_description import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description() -> LaunchDescription:
"""
Generate LaunchDescription for camera_streamer.

Returns
-------
LaunchDescription
Launches Front and Bottom Cameras nodes

"""
# Symlinks are auto-generated by V4L2
# ls /dev/v4l/by-id to see all the available symlinks
# ls /dev/v4l/by-path for usb slot based symlinks
Expand Down
13 changes: 7 additions & 6 deletions src/pi/camera_streamer/setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
"""setup.py for camera_streamer module."""
import os
from glob import glob

from setuptools import setup

package_name = 'camera_streamer'
PACKAGE_NAME = 'camera_streamer'

setup(
name=package_name,
name=PACKAGE_NAME,
version='1.0.0',
packages=[package_name],
packages=[PACKAGE_NAME],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
(os.path.join('share', PACKAGE_NAME, 'launch'),
glob('launch/*launch.[pxy][yma]*'))
],
install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'],
Expand Down
8 changes: 5 additions & 3 deletions src/pi/camera_streamer/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test flake8 on this module."""
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +20,8 @@
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8() -> None:
rc, errors = main_with_errors(argv=[])
assert rc == 0, \
'Found %d code style errors / warnings:\n' % len(errors) + \
"""Tests flake8 on this module."""
error_code, errors = main_with_errors(argv=[])
assert error_code == 0, \
f'Found {len(errors)} code style errors / warnings:\n' + \
'\n'.join(errors)
6 changes: 4 additions & 2 deletions src/pi/camera_streamer/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test mypy on this module."""
import os

import pytest
Expand All @@ -7,7 +8,8 @@
@pytest.mark.mypy
@pytest.mark.linter
def test_mypy() -> None:
"""Tests mypy on this module."""
file_path = __file__.replace(f'{__name__}.py', '')
config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini')
rc = main(argv=['--config', config_file])
assert rc == 0, 'Found code style errors / warnings'
error_code = main(argv=['--config', config_file])
assert error_code == 0, 'Found code style errors / warnings'
6 changes: 4 additions & 2 deletions src/pi/camera_streamer/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test pep257 on this module."""
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,5 +20,6 @@
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257() -> None:
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
"""Tests pep257 on this module."""
error_code = main(argv=['.', 'test'])
assert error_code == 0, 'Found code style errors / warnings'
17 changes: 7 additions & 10 deletions src/pi/manipulators/setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
"""setup.py for manipulators module."""
import os
import sys
from glob import glob

from setuptools import setup

major_num = sys.version_info[0]
minor_num = sys.version_info[1]

package_name = 'manipulators'
PACKAGE_NAME = 'manipulators'

setup(
name=package_name,
name=PACKAGE_NAME,
version='1.0.0',
packages=[package_name],
packages=[PACKAGE_NAME],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
(os.path.join('share', PACKAGE_NAME, 'launch'),
glob('launch/*launch.[pxy][yma]*'))
],
install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'],
Expand Down
8 changes: 5 additions & 3 deletions src/pi/manipulators/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test flake8 on this module."""
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +20,8 @@
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8() -> None:
rc, errors = main_with_errors(argv=[])
assert rc == 0, \
'Found %d code style errors / warnings:\n' % len(errors) + \
"""Tests flake8 on this module."""
error_code, errors = main_with_errors(argv=[])
assert error_code == 0, \
f'Found {len(errors)} code style errors / warnings:\n' + \
'\n'.join(errors)
6 changes: 4 additions & 2 deletions src/pi/manipulators/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test mypy on this module."""
import os

import pytest
Expand All @@ -7,7 +8,8 @@
@pytest.mark.mypy
@pytest.mark.linter
def test_mypy() -> None:
"""Tests mypy on this module."""
file_path = __file__.replace(f'{__name__}.py', '')
config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini')
rc = main(argv=['--config', config_file])
assert rc == 0, 'Found code style errors / warnings'
error_code = main(argv=['--config', config_file])
assert error_code == 0, 'Found code style errors / warnings'
6 changes: 4 additions & 2 deletions src/pi/manipulators/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test pep257 on this module."""
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,5 +20,6 @@
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257() -> None:
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
"""Tests pep257 on this module."""
error_code = main(argv=['.', 'test'])
assert error_code == 0, 'Found code style errors / warnings'
14 changes: 12 additions & 2 deletions src/pi/pi_main/launch/pi_launch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""pi_launch launch file."""
import os

from ament_index_python.packages import get_package_share_directory
Expand All @@ -8,7 +9,16 @@


def generate_launch_description() -> LaunchDescription:
NS = 'pi'
"""
Generate LaunchDescription for pi_main.

Returns
-------
LaunchDescription
Launches camera_streamer package and pixhawk_communication package.

"""
NAMESPACE = 'pi'
# Manipulator Controller
# manip_path: str = get_package_share_directory('manipulators')
#
Expand Down Expand Up @@ -56,7 +66,7 @@ def generate_launch_description() -> LaunchDescription:

namespace_launch = GroupAction(
actions=[
PushRosNamespace(NS),
PushRosNamespace(NAMESPACE),
# manip_launch,
pixhawk_launch,
cam_launch,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""When run sets up environment for the robot to run on boot."""
import os
import sys
import subprocess
Expand All @@ -8,6 +9,13 @@


def main() -> None:
"""
Set up Pi file environment.

Copies udev rules from this package into udev folder.
Also uses robot_upstart to allow robot to automatically start on power on.

"""
pi_main_share = get_package_share_directory('pi_main')

launch_dir = os.path.join(pi_main_share, 'launch')
Expand All @@ -27,14 +35,14 @@ def main() -> None:
cmd = ['/usr/bin/sudo', '/usr/bin/python3', udev_script, pi_main_share]

try:
p = subprocess.run(cmd, capture_output=True, check=True)
process = subprocess.run(cmd, capture_output=True, check=True)
# Logs Error
except subprocess.CalledProcessError as e:
print(e.stderr)
except subprocess.CalledProcessError as error:
print(error.stderr)
sys.exit(1)

# Success Message
print(p.stdout.decode())
print(process.stdout.decode())

install_path = os.path.join(pi_main_share, "..", "..")
workspace_path = os.path.join(install_path, "setup.bash")
Expand Down
1 change: 1 addition & 0 deletions src/pi/pi_main/pi_main/udev_copy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Copies udev rules from separate process to ensure ideal protections of sudo."""
import os
import shutil
import sys
Expand Down
17 changes: 9 additions & 8 deletions src/pi/pi_main/setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
"""setup.py for pi_main module."""
import os
from glob import glob

from setuptools import setup

package_name = 'pi_main'
PACKAGE_NAME = 'pi_main'


setup(
name=package_name,
name=PACKAGE_NAME,
version='1.0.0',
packages=[package_name],
packages=[PACKAGE_NAME],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
(os.path.join('share', PACKAGE_NAME, 'launch'),
glob('launch/*launch.[pxy][yma]*')),
(os.path.join('share', package_name, 'udev_rules'),
(os.path.join('share', PACKAGE_NAME, 'udev_rules'),
glob('udev_rules/*'))
],
install_requires=['setuptools', 'flake8==4.0.1', 'mypy >= 1.7'],
Expand All @@ -29,7 +30,7 @@
tests_require=['pytest'],
entry_points={
'console_scripts': [
'install = pi_main.install_on_boot:main',
'install = pi_main.run_on_boot:main',
],
},
)
8 changes: 5 additions & 3 deletions src/pi/pi_main/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test flake8 on this module."""
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +20,8 @@
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8() -> None:
rc, errors = main_with_errors(argv=[])
assert rc == 0, \
'Found %d code style errors / warnings:\n' % len(errors) + \
"""Tests flake8 on this module."""
error_code, errors = main_with_errors(argv=[])
assert error_code == 0, \
f'Found {len(errors)} code style errors / warnings:\n' + \
'\n'.join(errors)
6 changes: 4 additions & 2 deletions src/pi/pi_main/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test mypy on this module."""
import os

import pytest
Expand All @@ -7,7 +8,8 @@
@pytest.mark.mypy
@pytest.mark.linter
def test_mypy() -> None:
"""Tests mypy on this module."""
file_path = __file__.replace(f'{__name__}.py', '')
config_file = os.path.join(file_path, '..', '..', '..', '..', 'mypy.ini')
rc = main(argv=['--config', config_file])
assert rc == 0, 'Found code style errors / warnings'
error_code = main(argv=['--config', config_file])
assert error_code == 0, 'Found code style errors / warnings'
6 changes: 4 additions & 2 deletions src/pi/pi_main/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test pep257 on this module."""
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,5 +20,6 @@
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257() -> None:
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
"""Tests pep257 on this module."""
error_code = main(argv=['.', 'test'])
assert error_code == 0, 'Found code style errors / warnings'
Loading