Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 8, 2024
1 parent b1cb975 commit b52961d
Show file tree
Hide file tree
Showing 134 changed files with 1,257 additions and 1,089 deletions.
3 changes: 1 addition & 2 deletions src/float/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
version='1.2.0',
packages=[PACKAGE_NAME],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + PACKAGE_NAME]),
('share/ament_index/resource_index/packages', ['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml']),
],
install_requires=['setuptools'],
Expand Down
14 changes: 8 additions & 6 deletions src/float/test/test_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import pytest
from ament_clang_format.main import main


INO_EXTENSION = ".ino"
SKETCHES = ["float_transceiver", "surface_transceiver"]
SRC = "src"
INCLUDE = "include"
INO_EXTENSION = '.ino'
SKETCHES = ['float_transceiver', 'surface_transceiver']
SRC = 'src'
INCLUDE = 'include'


@pytest.mark.linter
Expand All @@ -20,7 +19,10 @@ def test_clang_format() -> None:

regular_cpp = [
*[os.path.join(os.getcwd(), folder) for folder in [SRC, INCLUDE]],
*[os.path.join(os.getcwd(), folder, folder + INO_EXTENSION) for folder in SKETCHES]
*[
os.path.join(os.getcwd(), folder, folder + INO_EXTENSION)
for folder in SKETCHES
],
]

config_file = os.path.join(os.getcwd(), '.clang-format.yaml')
Expand Down
48 changes: 24 additions & 24 deletions src/pi/camera_streamer/launch/camera_launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""camera_streamer launch file."""

from launch.launch_description import LaunchDescription
from launch_ros.actions import Node

Expand All @@ -18,39 +19,38 @@ def generate_launch_description() -> LaunchDescription:

# USB 3.0 front (fisheye)
front_cam_node: Node = Node(
exec_name="front_cam",
package="v4l2_camera",
executable="v4l2_camera_node",
namespace="front_cam",
exec_name='front_cam',
package='v4l2_camera',
executable='v4l2_camera_node',
namespace='front_cam',
parameters=[
{"video_device":
"/dev/v4l/by-id/usb-3.0_USB_Camera_3.0_USB_Camera-video-index0"},
{"image_size": [640, 480]},
{"time_per_frame": [1, 30]}
{
'video_device': '/dev/v4l/by-id/usb-3.0_USB_Camera_3.0_USB_Camera-video-index0'
},
{'image_size': [640, 480]},
{'time_per_frame': [1, 30]},
],
remappings=[("/pi/front_cam/image_raw", "/tether/front_cam/image_raw")],
remappings=[('/pi/front_cam/image_raw', '/tether/front_cam/image_raw')],
emulate_tty=True,
output='screen'
output='screen',
)

# USB 3.0 bottom
bottom_cam_node: Node = Node(
exec_name="bottom_cam",
package="v4l2_camera",
executable="v4l2_camera_node",
namespace="bottom_cam",
exec_name='bottom_cam',
package='v4l2_camera',
executable='v4l2_camera_node',
namespace='bottom_cam',
parameters=[
{"video_device":
"/dev/v4l/by-id/usb-3.0_USB_Camera_3.0_USB_Camera_2020042501-video-index0"},
{"image_size": [640, 480]},
{"time_per_frame": [1, 30]}
{
'video_device': '/dev/v4l/by-id/usb-3.0_USB_Camera_3.0_USB_Camera_2020042501-video-index0'
},
{'image_size': [640, 480]},
{'time_per_frame': [1, 30]},
],
remappings=[("/pi/bottom_cam/image_raw", "/tether/bottom_cam/image_raw")],
remappings=[('/pi/bottom_cam/image_raw', '/tether/bottom_cam/image_raw')],
emulate_tty=True,
output='screen'
output='screen',
)

return LaunchDescription([
front_cam_node,
bottom_cam_node
])
return LaunchDescription([front_cam_node, bottom_cam_node])
10 changes: 6 additions & 4 deletions src/pi/camera_streamer/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""setup.py for camera_streamer module."""

import os
from glob import glob

Expand All @@ -11,12 +12,13 @@
version='1.2.0',
packages=[PACKAGE_NAME],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + PACKAGE_NAME]),
('share/ament_index/resource_index/packages', ['resource/' + PACKAGE_NAME]),
('share/' + PACKAGE_NAME, ['package.xml']),
# Include all launch files.
(os.path.join('share', PACKAGE_NAME, 'launch'),
glob('launch/*launch.[pxy][yma]*'))
(
os.path.join('share', PACKAGE_NAME, 'launch'),
glob('launch/*launch.[pxy][yma]*'),
),
],
install_requires=['setuptools'],
zip_safe=True,
Expand Down
8 changes: 4 additions & 4 deletions src/pi/camera_streamer/test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_flake8.main import main_with_errors
import pytest
from ament_flake8.main import main_with_errors


@pytest.mark.flake8
@pytest.mark.linter
def test_flake8() -> None:
"""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)
assert error_code == 0, (
f'Found {len(errors)} code style errors / warnings:\n' + '\n'.join(errors)
)
5 changes: 3 additions & 2 deletions src/pi/camera_streamer/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test mypy on this module."""

import os

import pytest
from ament_mypy.main import main

Expand All @@ -9,6 +10,6 @@
@pytest.mark.linter
def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
path = os.path.join(os.getcwd(), '..', '..', '..', 'pyproject.toml')
error_code = main(argv=['--config', path])
assert error_code == 0, 'Found code style errors / warnings'
2 changes: 1 addition & 1 deletion src/pi/camera_streamer/test/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
@pytest.mark.pep257
def test_pep257() -> None:
"""Tests pep257 on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
path = os.path.join(os.getcwd(), '..', '..', '..', 'pyproject.toml')
error_code = main(argv=['.', 'test', '--config', path])
assert error_code == 0, 'Found code style errors / warnings'
8 changes: 4 additions & 4 deletions src/pi/flood_detection/flood_detection/flood_detector.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import lgpio
import rclpy
from rclpy.node import Node

from rov_msgs.msg import Flooding
import lgpio

# Pins used for GPIO
DETECT_PIN = 17


class FloodDetector(Node):

def __init__(self) -> None:
super().__init__('gpio_reader', parameter_overrides=[])
self.publisher = self.create_publisher(Flooding, 'flooding', 10)
Expand All @@ -23,9 +23,9 @@ def timer_callback(self) -> None:

# If any of the sensors detect water, send true to /tether/flooding
msg = Flooding()
msg.flooding = (flood_reading == lgpio.HIGH)
msg.flooding = flood_reading == lgpio.HIGH
if msg.flooding:
self.get_logger().error("The ebay is flooding")
self.get_logger().error('The ebay is flooding')
self.publisher.publish(msg)


Expand Down
4 changes: 2 additions & 2 deletions src/pi/flood_detection/flood_detection/gpio_reader_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def main() -> None:
data = lgpio.gpio_read(gpio_chip, DETECT_PIN)

if data != old_data or first_run:
print("Pin 17: %s" % data)
print('Pin 17: %s' % data)

if data:
print("\nBad Flooding Thing")
print('\nBad Flooding Thing')

first_run = False

Expand Down
6 changes: 2 additions & 4 deletions src/pi/flood_detection/launch/flood_detection_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def generate_launch_description() -> LaunchDescription:
executable='flood_detector',
emulate_tty=True,
output='screen',
remappings=[('/pi/flooding', '/tether/flooding')]
remappings=[('/pi/flooding', '/tether/flooding')],
)

return LaunchDescription([
flood_detection
])
return LaunchDescription([flood_detection])
16 changes: 9 additions & 7 deletions src/pi/flood_detection/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from setuptools import setup
from glob import glob
import os
from glob import glob

from setuptools import setup

package_name = 'flood_detection'

Expand All @@ -9,12 +10,13 @@
version='1.2.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
glob('launch/*launch.[pxy][yma]*'))
(
os.path.join('share', package_name, 'launch'),
glob('launch/*launch.[pxy][yma]*'),
),
],
install_requires=['setuptools'],
zip_safe=True,
Expand All @@ -26,7 +28,7 @@
entry_points={
'console_scripts': [
'flood_detector = flood_detection.flood_detector:main',
'dry_run = flood_detection.gpio_reader_dry_run:main'
'dry_run = flood_detection.gpio_reader_dry_run:main',
],
},
)
8 changes: 4 additions & 4 deletions src/pi/flood_detection/test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_flake8.main import main_with_errors
import pytest
from ament_flake8.main import main_with_errors


@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) + \
'\n'.join(errors)
assert rc == 0, 'Found %d code style errors / warnings:\n' % len(
errors
) + '\n'.join(errors)
5 changes: 3 additions & 2 deletions src/pi/flood_detection/test/test_mypy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test mypy on this module."""

import os

import pytest
from ament_mypy.main import main

Expand All @@ -9,6 +10,6 @@
@pytest.mark.linter
def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
path = os.path.join(os.getcwd(), '..', '..', '..', 'pyproject.toml')
error_code = main(argv=['--config', path])
assert error_code == 0, 'Found code style errors / warnings'
2 changes: 1 addition & 1 deletion src/pi/flood_detection/test/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ament_pep257.main import main
import pytest
from ament_pep257.main import main


@pytest.mark.linter
Expand Down
35 changes: 15 additions & 20 deletions src/pi/manipulators/launch/manip_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,33 @@


def generate_launch_description() -> LaunchDescription:

manip_node = Node(
package="manipulators",
executable="manipulators",
package='manipulators',
executable='manipulators',
parameters=[
{"left": 2},
{"right": 3},
{'left': 2},
{'right': 3},
# {"light": 2},
],
remappings=[("/pi/manipulator_control", "/tether/manipulator_control")],
remappings=[('/pi/manipulator_control', '/tether/manipulator_control')],
emulate_tty=True,
output="screen"
output='screen',
)

lgpio_manip_node = Node(
package="manipulators",
executable="lgpio_manipulator",
remappings=[("/pi/manipulator_control", "/tether/manipulator_control")],
package='manipulators',
executable='lgpio_manipulator',
remappings=[('/pi/manipulator_control', '/tether/manipulator_control')],
emulate_tty=True,
output="screen"
output='screen',
)

valve_manip_node = Node(
package="manipulators",
executable="valve_manipulator",
remappings=[("/pi/valve_manipulator", "/tether/valve_manipulator")],
package='manipulators',
executable='valve_manipulator',
remappings=[('/pi/valve_manipulator', '/tether/valve_manipulator')],
emulate_tty=True,
output="screen"
output='screen',
)

return LaunchDescription([
manip_node,
lgpio_manip_node,
valve_manip_node
])
return LaunchDescription([manip_node, lgpio_manip_node, valve_manip_node])
7 changes: 3 additions & 4 deletions src/pi/manipulators/manipulators/lgpio_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@


class Manipulator(Node):

def __init__(self) -> None:
super().__init__('lgpio_manipulator')

self.create_subscription(
Manip,
'manipulator_control',
self.manip_callback,
qos_profile_system_default
qos_profile_system_default,
)

self.gpio_handle = lgpio.gpiochip_open(0)
Expand All @@ -31,12 +30,12 @@ def manip_callback(self, message: Manip) -> None:
manip_id = message.manip_id
activated = message.activated

if manip_id == "left":
if manip_id == 'left':
if activated:
lgpio.gpio_write(self.gpio_handle, MANIP_PIN_ONE, lgpio.HIGH)
else:
lgpio.gpio_write(self.gpio_handle, MANIP_PIN_ONE, lgpio.LOW)
elif manip_id == "right":
elif manip_id == 'right':
if activated:
lgpio.gpio_write(self.gpio_handle, MANIP_PIN_TWO, lgpio.HIGH)
else:
Expand Down
Loading

0 comments on commit b52961d

Please sign in to comment.