Skip to content

Commit

Permalink
Merge branch 'main' into More-Graph-Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Isopod00 committed Jul 3, 2024
2 parents 3695fec + 9e789dc commit 604497f
Show file tree
Hide file tree
Showing 37 changed files with 327 additions and 193 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/linter_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint Check

on:
# Trigger the workflow on push to main or any pull request.
push:
branches:
- main
pull_request:

permissions: { }

jobs:
run-linters:
name: Lint
runs-on: ubuntu-latest

permissions:
contents: read
packages: read
# To report GitHub Actions status checks
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Super-linter
uses: super-linter/[email protected] # x-release-please-version
env:
VALIDATE_ALL_CODEBASE: true
VALIDATE_PYTHON_FLAKE8: true
VALIDATE_PYTHON_RUFF: true
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/trufflehog_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Trufflehog Scan

on:
# Trigger the workflow on push to main or any pull request.
push:
branches:
- main
pull_request:

jobs:
run-scan:
name: Run scan
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Secret Scanning
uses: trufflesecurity/trufflehog@main
with:
extra_args: --only-verified
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The official NASA Lunabotics 2024 repository for University of Minnesota Robotics.

[![Lint Check](https://github.com/GOFIRST-Robotics/Lunabotics-2024/actions/workflows/linter_check.yml/badge.svg)](https://github.com/GOFIRST-Robotics/Lunabotics-2024/actions/workflows/linter_check.yml) [![Trufflehog Scan](https://github.com/GOFIRST-Robotics/Lunabotics-2024/actions/workflows/trufflehog_scan.yml/badge.svg)](https://github.com/GOFIRST-Robotics/Lunabotics-2024/actions/workflows/trufflehog_scan.yml)

```mermaid
---
title: Connectivity Chart
Expand Down
10 changes: 8 additions & 2 deletions src/apriltag/launch/apriltag_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def generate_launch_description():
plugin="nvidia::isaac_ros::apriltag::AprilTagNode",
name="isaac_ros_apriltag",
namespace="",
remappings=[("image", "zed2i/zed_node/left/image_rect_color_rgb"), ("camera_info", "zed2i/zed_node/left/camera_info")],
remappings=[
("image", "zed2i/zed_node/left/image_rect_color_rgb"),
("camera_info", "zed2i/zed_node/left/camera_info"),
],
)

image_format_converter_node_left = ComposableNode(
Expand All @@ -29,7 +32,10 @@ def generate_launch_description():
"encoding_desired": "rgb8",
}
],
remappings=[("image_raw", "zed2i/zed_node/left/image_rect_color"), ("image", "zed2i/zed_node/left/image_rect_color_rgb")],
remappings=[
("image_raw", "zed2i/zed_node/left/image_rect_color"),
("image", "zed2i/zed_node/left/image_rect_color_rgb"),
],
)

apriltag_container = ComposableNodeContainer(
Expand Down
26 changes: 13 additions & 13 deletions src/apriltag/setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
from setuptools import find_packages, setup
import os
from glob import glob
package_name = 'apriltag'

package_name = "apriltag"

setup(
name=package_name,
version='0.0.0',
packages=find_packages(exclude=['test']),
version="0.0.0",
packages=find_packages(exclude=["test"]),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
("share/" + package_name, ["package.xml"]),
(
os.path.join("share", package_name),
glob("launch/*launch.[pxy][yma]*", recursive=True),
),
],
install_requires=['setuptools'],
install_requires=["setuptools"],
zip_safe=True,
maintainer='umn-robotics',
maintainer_email='[email protected]',
description='Package for processing apriltag detections received from ISAAC ROS Apriltag.',
license='MIT License',
tests_require=['pytest'],
maintainer="umn-robotics",
maintainer_email="[email protected]",
description="Package for processing apriltag detections received from ISAAC ROS Apriltag.",
license="MIT License",
tests_require=["pytest"],
entry_points={
'console_scripts': ["apriltag_node = apriltag.apriltag_node:main"],
"console_scripts": ["apriltag_node = apriltag.apriltag_node:main"],
},
)
6 changes: 3 additions & 3 deletions src/apriltag/test/test_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


# Remove the `skip` decorator once the source file(s) have a copyright header
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
@pytest.mark.skip(reason="No copyright header has been placed in the generated source file.")
@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
rc = main(argv=[".", "test"])
assert rc == 0, "Found errors"
4 changes: 1 addition & 3 deletions src/apriltag/test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
@pytest.mark.linter
def test_flake8():
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)
4 changes: 2 additions & 2 deletions src/apriltag/test/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
rc = main(argv=[".", "test"])
assert rc == 0, "Found code style errors / warnings"
102 changes: 74 additions & 28 deletions src/drivetrain/drivetrain/drivetrain_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,26 @@ def __init__(self, drive_motor, turning_motor, drivetrain):
self.drivetrain = drivetrain

def set_power(self, power: float) -> None:
self.drivetrain.cli_motor_set.call_async(MotorCommandSet.Request(can_id=self.drive_motor_can_id, type="duty_cycle", value=power))
self.drivetrain.cli_motor_set.call_async(
MotorCommandSet.Request(can_id=self.drive_motor_can_id, type="duty_cycle", value=power)
)

def set_angle(self, angle: float) -> None:
angle = (360 - angle) % 360

self.drivetrain.cli_motor_set.call_async(
MotorCommandSet.Request(
can_id=self.turning_motor_can_id, type="position", value=(angle - self.encoder_offset) * self.drivetrain.STEERING_MOTOR_GEAR_RATIO
can_id=self.turning_motor_can_id,
type="position",
value=(angle - self.encoder_offset) * self.drivetrain.STEERING_MOTOR_GEAR_RATIO,
)
)

def reset(self, current_relative_angle) -> None:
self.encoder_offset = self.current_absolute_angle - current_relative_angle
self.drivetrain.get_logger().info(f"CAN ID {self.turning_motor_can_id} Absolute Encoder angle offset set to: {self.encoder_offset}")
self.drivetrain.get_logger().info(
f"CAN ID {self.turning_motor_can_id} Absolute Encoder angle offset set to: {self.encoder_offset}"
)
self.set_angle(0) # Rotate the module to the 0 degree position

def set_state(self, power: float, angle: float) -> None:
Expand Down Expand Up @@ -176,22 +182,42 @@ def absolute_angle_reset(self):
if self.front_left.current_absolute_angle is not None:
print("Absolute Encoder angles reset")

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
front_left_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.FRONT_LEFT_TURN))
front_left_future.add_done_callback(lambda future: self.front_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
front_left_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.FRONT_LEFT_TURN)
)
front_left_future.add_done_callback(
lambda future: self.front_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
front_right_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.FRONT_RIGHT_TURN)
)
front_right_future.add_done_callback(
lambda future: self.front_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
front_right_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.FRONT_RIGHT_TURN))
front_right_future.add_done_callback(lambda future: self.front_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
back_left_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.BACK_LEFT_TURN)
)
back_left_future.add_done_callback(
lambda future: self.back_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
back_left_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.BACK_LEFT_TURN))
back_left_future.add_done_callback(lambda future: self.back_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
back_right_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.BACK_RIGHT_TURN)
)
back_right_future.add_done_callback(
lambda future: self.back_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
back_right_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.BACK_RIGHT_TURN))
back_right_future.add_done_callback(lambda future: self.back_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))

self.absolute_angle_timer.cancel()

# Define subsystem methods here
Expand Down Expand Up @@ -295,21 +321,41 @@ def drive_callback(self, request, response):
def calibrate_callback(self, request, response):
"""This service request calibrates the drivetrain."""
if self.front_left.current_absolute_angle is not None:
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
front_left_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.FRONT_LEFT_TURN))
front_left_future.add_done_callback(lambda future: self.front_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
front_left_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.FRONT_LEFT_TURN)
)
front_left_future.add_done_callback(
lambda future: self.front_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
front_right_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.FRONT_RIGHT_TURN))
front_right_future.add_done_callback(lambda future: self.front_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
front_right_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.FRONT_RIGHT_TURN)
)
front_right_future.add_done_callback(
lambda future: self.front_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
back_left_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.BACK_LEFT_TURN))
back_left_future.add_done_callback(lambda future: self.back_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
back_left_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.BACK_LEFT_TURN)
)
back_left_future.add_done_callback(
lambda future: self.back_left.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

# future.result().data will contain the position of the MOTOR (not the wheel) in degrees. Divide this by the gear ratio to get the wheel position.
back_right_future = self.cli_motor_get.call_async(MotorCommandGet.Request(type="position", can_id=self.BACK_RIGHT_TURN))
back_right_future.add_done_callback(lambda future: self.back_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO))
# future.result().data will contain the position of the MOTOR (not the wheel) in degrees.
# Divide this by the gear ratio to get the wheel position.
back_right_future = self.cli_motor_get.call_async(
MotorCommandGet.Request(type="position", can_id=self.BACK_RIGHT_TURN)
)
back_right_future.add_done_callback(
lambda future: self.back_right.reset(future.result().data / self.STEERING_MOTOR_GEAR_RATIO)
)

response.success = 0 # indicates success
else:
Expand Down
4 changes: 2 additions & 2 deletions src/drivetrain/test/test_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
rc = main(argv=[".", "test"])
assert rc == 0, "Found errors"
4 changes: 1 addition & 3 deletions src/drivetrain/test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
@pytest.mark.linter
def test_flake8():
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)
4 changes: 2 additions & 2 deletions src/drivetrain/test/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
@pytest.mark.linter
@pytest.mark.pep257
def test_pep257():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found code style errors / warnings'
rc = main(argv=[".", "test"])
assert rc == 0, "Found code style errors / warnings"
6 changes: 2 additions & 4 deletions src/gstreamer/gstreamer/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ class ClientPlugin(Plugin):
def __init__(self, context):
super(ClientPlugin, self).__init__(context)
self.setObjectName("ClientPlugin")
assert hasattr(context, 'node'), 'Context does not have a node.'
assert hasattr(context, "node"), "Context does not have a node."
self._widget = ClientWidget(context.node)
if context.serial_number() > 1:
self._widget.setWindowTitle(
self._widget.windowTitle() + (' (%d)' % context.serial_number()))
self._widget.setWindowTitle(self._widget.windowTitle() + (" (%d)" % context.serial_number()))
context.add_widget(self._widget)

Loading

0 comments on commit 604497f

Please sign in to comment.