Skip to content

Commit

Permalink
clean files
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Feb 16, 2024
1 parent fa23934 commit 0a167f4
Show file tree
Hide file tree
Showing 31 changed files with 207 additions and 194 deletions.
3 changes: 2 additions & 1 deletion 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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
3 changes: 2 additions & 1 deletion src/pi/heartbeat/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
3 changes: 2 additions & 1 deletion src/pi/manipulators/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
12 changes: 5 additions & 7 deletions src/pi/pi_main/launch/pi_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ def generate_launch_description() -> LaunchDescription:
)
)

realsense_path: str = get_package_share_directory('realsense')
realsense_path: str = get_package_share_directory("realsense")

# Launches Realsense
realsense_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
os.path.join(
realsense_path, 'launch', 'realsense_launch.py'
)
])
PythonLaunchDescriptionSource(
[os.path.join(realsense_path, "launch", "realsense_launch.py")]
)
)

# Launches ip_publisher node.
Expand All @@ -106,7 +104,7 @@ def generate_launch_description() -> LaunchDescription:
# cam_launch,
realsense_launch,
ip_publisher_node,
heartbeat_launch
heartbeat_launch,
]
)

Expand Down
3 changes: 2 additions & 1 deletion src/pi/pi_main/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
3 changes: 2 additions & 1 deletion src/pi/pixhawk_communication/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
16 changes: 7 additions & 9 deletions src/pi/realsense/launch/realsense_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ def generate_launch_description() -> LaunchDescription:

# Launches Realsense
realsense_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
os.path.join(
realsense_path, 'launch', 'rs_launch.py'
)
]),
PythonLaunchDescriptionSource([os.path.join(realsense_path, "launch", "rs_launch.py")]),
# Values are width x height x fps.
launch_arguments={'depth_module.profile': '640x360x30',
'initial_reset': 'true',
'rgb_camera.profile': '640x360x30',
'align_depth.enable': 'true'}.items()
launch_arguments={
"depth_module.profile": "640x360x30",
"initial_reset": "true",
"rgb_camera.profile": "640x360x30",
"align_depth.enable": "true",
}.items(),
)

realsense_action = GroupAction(
Expand Down
3 changes: 2 additions & 1 deletion src/pi/realsense/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
72 changes: 31 additions & 41 deletions src/surface/flight_control/flight_control/manual_control_node.py
Original file line number Diff line number Diff line change
@@ -1,81 +1,70 @@
from collections.abc import MutableSequence

import rclpy
from flight_control.pixhawk_instruction import PixhawkInstruction
from mavros_msgs.msg import OverrideRCIn
from rclpy.executors import MultiThreadedExecutor
from rclpy.node import Node
from rclpy.publisher import Publisher
from rclpy.qos import qos_profile_sensor_data, qos_profile_system_default
from rclpy.subscription import Subscription
from sensor_msgs.msg import Joy
from mavros_msgs.msg import OverrideRCIn

from rov_msgs.msg import CameraControllerSwitch, Manip

from flight_control.pixhawk_instruction import PixhawkInstruction

# Button meanings for PS5 Control might be different for others
X_BUTTON: int = 0 # Manipulator 0
O_BUTTON: int = 1 # Manipulator 1
TRI_BUTTON: int = 2 # Manipulator 2
SQUARE_BUTTON: int = 3 # Manipulator 3
L1: int = 4
R1: int = 5
L2: int = 6
R2: int = 7
PAIRING_BUTTON: int = 8
MENU: int = 9
PS_BUTTON: int = 10
LJOYPRESS: int = 11
RJOYPRESS: int = 12
X_BUTTON: int = 0 # Manipulator 0
O_BUTTON: int = 1 # Manipulator 1
TRI_BUTTON: int = 2 # Manipulator 2
SQUARE_BUTTON: int = 3 # Manipulator 3
L1: int = 4
R1: int = 5
L2: int = 6
R2: int = 7
PAIRING_BUTTON: int = 8
MENU: int = 9
PS_BUTTON: int = 10
LJOYPRESS: int = 11
RJOYPRESS: int = 12
# Joystick Directions 1 is up/left -1 is down/right
# X is forward/backward Y is left/right
# L2 and R2 1 is not pressed and -1 is pressed
LJOYY: int = 0
LJOYX: int = 1
LJOYY: int = 0
LJOYX: int = 1
L2PRESS_PERCENT: int = 2
RJOYY: int = 3
RJOYX: int = 4
RJOYY: int = 3
RJOYX: int = 4
R2PRESS_PERCENT: int = 5
DPADHOR: int = 6
DPADVERT: int = 7
DPADHOR: int = 6
DPADVERT: int = 7


class ManualControlNode(Node):
def __init__(self) -> None:
super().__init__('manual_control_node',
parameter_overrides=[])
super().__init__("manual_control_node", parameter_overrides=[])

self.rc_pub: Publisher = self.create_publisher(
OverrideRCIn,
'mavros/rc/override',
qos_profile_system_default
OverrideRCIn, "mavros/rc/override", qos_profile_system_default
)

self.subscription: Subscription = self.create_subscription(
Joy,
'joy',
self.controller_callback,
qos_profile_sensor_data
Joy, "joy", self.controller_callback, qos_profile_sensor_data
)

# Manipulators
self.manip_publisher: Publisher = self.create_publisher(
Manip,
'manipulator_control',
qos_profile_system_default
Manip, "manipulator_control", qos_profile_system_default
)

# Cameras
self.camera_toggle_publisher = self.create_publisher(
CameraControllerSwitch,
"camera_switch",
qos_profile_system_default
CameraControllerSwitch, "camera_switch", qos_profile_system_default
)

self.manip_buttons: dict[int, ManipButton] = {
X_BUTTON: ManipButton("claw0"),
O_BUTTON: ManipButton("claw1"),
TRI_BUTTON: ManipButton("light")
TRI_BUTTON: ManipButton("light"),
}

self.seen_left_cam = False
Expand All @@ -96,7 +85,7 @@ def joystick_to_pixhawk(self, msg: Joy) -> None:
vertical=axes[RJOYX], # Right Joystick Z
forward=axes[LJOYX], # Left Joystick X
lateral=-axes[LJOYY], # Left Joystick Y
yaw=(axes[R2PRESS_PERCENT] - axes[L2PRESS_PERCENT]) / 2 # L2/R2 buttons
yaw=(axes[R2PRESS_PERCENT] - axes[L2PRESS_PERCENT]) / 2, # L2/R2 buttons
)

# Smooth out adjustments
Expand All @@ -120,8 +109,9 @@ def manip_callback(self, msg: Joy) -> None:
log_msg: str = f"manip_id= {manip_button.claw}, manip_active= {new_manip_state}"
self.get_logger().info(log_msg)

manip_msg: Manip = Manip(manip_id=manip_button.claw,
activated=manip_button.is_active)
manip_msg: Manip = Manip(
manip_id=manip_button.claw, activated=manip_button.is_active
)
self.manip_publisher.publish(manip_msg)

manip_button.last_button_state = just_pressed
Expand Down
20 changes: 12 additions & 8 deletions src/surface/flight_control/launch/flight_control_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@

def generate_launch_description() -> LaunchDescription:
manual_control_node = Node(
package='flight_control',
executable='manual_control_node',
remappings=[('/surface/manipulator_control', '/tether/manipulator_control'),
('/surface/mavros/rc/override', '/tether/mavros/rc/override')],
package="flight_control",
executable="manual_control_node",
remappings=[
("/surface/manipulator_control", "/tether/manipulator_control"),
("/surface/mavros/rc/override", "/tether/mavros/rc/override"),
],
emulate_tty=True,
output="screen",
)

auto_docking_node = Node(
package='flight_control',
executable='auto_docking_node',
remappings=[('/surface/manipulator_control', '/tether/manipulator_control'),
('/surface/mavros/rc/override', '/tether/mavros/rc/override')],
package="flight_control",
executable="auto_docking_node",
remappings=[
("/surface/manipulator_control", "/tether/manipulator_control"),
("/surface/mavros/rc/override", "/tether/mavros/rc/override"),
],
emulate_tty=True,
output="screen",
)
Expand Down
6 changes: 3 additions & 3 deletions src/surface/flight_control/launch/keyboard_control_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

def generate_launch_description() -> LaunchDescription:
keyboard_control_node = Node(
package='flight_control',
executable='keyboard_control_node',
remappings=[('/surface/mavros/rc/override', '/tether/mavros/rc/override')],
package="flight_control",
executable="keyboard_control_node",
remappings=[("/surface/mavros/rc/override", "/tether/mavros/rc/override")],
emulate_tty=True,
output="screen",
)
Expand Down
3 changes: 2 additions & 1 deletion src/surface/flight_control/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 @@ -11,4 +12,4 @@ def test_mypy() -> None:
"""Tests mypy on this module."""
path = os.path.join(os.getcwd(), "..", "..", "..", "pyproject.toml")
error_code = main(argv=["--config", path])
assert error_code == 0, 'Found code style errors / warnings'
assert error_code == 0, "Found code style errors / warnings"
5 changes: 3 additions & 2 deletions src/surface/gui/gui/event_nodes/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def __init__(
self.expected_namespace = expected_namespace

self.cli = self.create_client(srv_type, topic)
Thread(target=self.__connect_to_service, daemon=True,
name=f'{self.name}_connect_to_service').start()
Thread(
target=self.__connect_to_service, daemon=True, name=f"{self.name}_connect_to_service"
).start()

def __connect_to_service(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/surface/gui/gui/event_nodes/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from threading import Thread
from typing import Callable

from rclpy.service import SrvType, SrvTypeRequest, SrvTypeResponse
from rclpy.executors import SingleThreadedExecutor
from rclpy.node import Node
from rclpy.service import SrvType, SrvTypeRequest, SrvTypeResponse


class GUIEventServer(Node):
Expand Down
Loading

0 comments on commit 0a167f4

Please sign in to comment.