Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into iron
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Dec 5, 2023
2 parents 3862faf + de190a9 commit 80ffda5
Show file tree
Hide file tree
Showing 100 changed files with 704 additions and 1,122 deletions.
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
31 changes: 27 additions & 4 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,7 +134,9 @@ 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+`.

It runs the tests and pipes the output to the terminal.
In VSCode, press `F1` or `ctrl+shift+p` and enter `Tasks: Run Test Task` as another method to run the above command.

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'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from pi_main.install_on_boot import main
from pi_main.run_on_boot import main

ROS_DISTRO = os.getenv("ROS_DISTRO")

Expand Down
Loading

0 comments on commit 80ffda5

Please sign in to comment.