Skip to content

Commit

Permalink
merge with recent missions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniParr committed Nov 8, 2024
2 parents b220c0a + a954883 commit 8ca9a24
Show file tree
Hide file tree
Showing 65 changed files with 1,916 additions and 327 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/autopush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ env:
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
runs-on:
group: mala-lab-pre-commit
if: github.event.sender.login == 'cbrxyz'
steps:
- name: Check out code from GitHub
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
name: Run tests and build docs
needs: avoid-duplicate-ci
if: needs.avoid-duplicate-ci.outputs.should_skip != 'true'
runs-on: self-hosted
runs-on:
group: mala-lab-main
steps:
- name: Configure catkin workspace folder structure
run: |
Expand Down Expand Up @@ -111,7 +112,8 @@ jobs:

deploy-docs:
name: Deploy docs from master
runs-on: self-hosted
runs-on:
group: mala-lab-main
needs: super-ci
# https://github.com/actions/runner/issues/491#issuecomment-850884422
if: |
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Run pre-commit

# yamllint disable-line rule:truthy
on: [push, workflow_dispatch]

# Cancels this run if a new one referring to the same object and same workflow
# is requested
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# The version of caching we are using. This can be upgraded if we
# significantly change CI to the point where old caches become irrelevant.
CACHE_VERSION: 0
# Default Python version. Noetic defaults to 3.8.
DEFAULT_PYTHON: 3.8
# Location of the pre-commit cache. This is set by pre-commit, not us!
PRE_COMMIT_CACHE: ~/.cache/pre-commit

jobs:
pre-commit:
name: Run pre-commit
runs-on:
group: mala-lab-pre-commit
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "pip"
- name: Install pre-commit hooks
run: |
python --version
pip install "$(cat requirements.txt | grep pre-commit)"
- name: Generate pre-commit cache key
id: pre-commit_cache_key
run: >
echo "::set-output
name=key::${{ env.CACHE_VERSION }}-${{ env.DEFAULT_PYTHON }}-${{
hashFiles('.pre-commit-config.yaml') }}"
- name: Restore base pre-commit environment
id: cache-pre-commmit
uses: actions/cache@v4
with:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >
${{ runner.os
}}-pre-commit-${{ steps.pre-commit_cache_key.outputs.key }}
- name: Install pre-commit dependencies if no cache
if: steps.cache-precommit.outputs.cache-hit != 'true'
run: |
pre-commit install-hooks
- name: Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ exclude: ^deprecated/

default_language_version:
python: python3.8
node: lts

ci:
autofix_prs: false
Expand All @@ -19,7 +20,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
rev: v19.1.1
hooks:
- id: clang-format
- repo: https://github.com/PyCQA/autoflake
Expand All @@ -40,7 +41,7 @@ repos:
exclude: ^docker|deprecated|NaviGator/simulation/VRX
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.6.3'
rev: 'v0.6.9'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -50,7 +51,7 @@ repos:
hooks:
- id: codespell
args:
- --ignore-words-list=fpr,ser,wan,te,wan,ba,ned,ans,hist,nd,wronly,Voight,assertIn
- --ignore-words-list=fpr,ser,wan,te,wan,ba,ned,ans,hist,nd,wronly,Voight,assertIn,flor
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
Expand All @@ -74,7 +75,7 @@ repos:
- id: prettier-package-xml
- id: sort-package-xml
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, port: str):
self.heard_nack = False
self.drops = 0
self.temp_timer = None
print("done init")
rospy.loginfo("Ball launcher device initialized")

def get_drop_count(self) -> int:
return self.drops
Expand All @@ -51,10 +51,10 @@ def _check_for_valid_response(self, event: str):
elif not self.heard_ack:
rospy.logerr(f"Failed to {event} (no response from board)")

def _check_for_dropped_ball(self):
def _check_for_dropped_ball(self, _):
self._check_for_valid_response("drop ball")

def _check_for_spun(self):
def _check_for_spun(self, _):
self._check_for_valid_response("set spin")

def drop_ball(self, _: EmptyRequest):
Expand Down Expand Up @@ -84,7 +84,6 @@ def spin(self, request: SetBoolRequest):
return {}

def on_packet_received(self, packet: AckPacket | NackPacket) -> None:
print("inc packet", packet)
if isinstance(packet, AckPacket):
self.heard_ack = True
elif isinstance(packet, NackPacket):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

if __name__ == "__main__":
rospy.init_node("ball_launcher")
port = "/dev/serial/by-id/usb-Raspberry_Pi_Pico_E6635C08CB65BC36-if00"
port = str(rospy.get_param("~port"))
device = BallLauncherDevice(port)
rospy.spin()
14 changes: 14 additions & 0 deletions NaviGator/hardware_drivers/navigator_drone_comm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.0.2)
project(navigator_drone_comm)

find_package(catkin REQUIRED COMPONENTS
rospy
)

catkin_python_setup()
catkin_package()

include_directories(
# include
${catkin_INCLUDE_DIRS}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .packets import (
Color,
EStopPacket,
GPSDronePacket,
HeartbeatReceivePacket,
HeartbeatSetPacket,
StartPacket,
StopPacket,
TargetPacket,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from dataclasses import dataclass
from enum import Enum

from electrical_protocol import Packet


@dataclass
class HeartbeatReceivePacket(
Packet,
class_id=0x20,
subclass_id=0x00,
payload_format="",
):
"""
Heartbeat packet sent from the drone.
"""


@dataclass
class HeartbeatSetPacket(Packet, class_id=0x20, subclass_id=0x01, payload_format=""):
"""
Heartbeat packet sent from the boat.
"""


@dataclass
class GPSDronePacket(Packet, class_id=0x20, subclass_id=0x02, payload_format="<fff"):
"""
GPS location of drone packet.
Attributes:
lat (float): The latitude of the drone.
lon (float): The longitude of the drone.
alt (float): The altitude of the drone.
"""

lat: float
lon: float
alt: float


@dataclass
class EStopPacket(Packet, class_id=0x20, subclass_id=0x03, payload_format=""):
"""
Emergency stop drone packet.
"""


@dataclass
class StartPacket(Packet, class_id=0x20, subclass_id=0x04, payload_format="<20s"):
"""
Start drone mission packet.
Attributes:
name (str): The name of the mission to run on the drone. Limited to 20 characters.
"""

name: str


@dataclass
class StopPacket(Packet, class_id=0x20, subclass_id=0x05, payload_format=""):
"""
Stop drone and return packet.
"""


class Color(Enum):
"""
Enum to represent the color of a target.
"""

BLUE = "b"
GREEN = "g"
RED = "r"


@dataclass
class TargetPacket(Packet, class_id=0x20, subclass_id=0x06, payload_format="<ffc"):
"""
GPS of drone-identified target packet.
Attributes:
lat (float): The latitude of the target.
lon (float): The longitude of the target.
color (Color): The color of the target.
"""

lat: float
lon: float
color: Color
15 changes: 15 additions & 0 deletions NaviGator/hardware_drivers/navigator_drone_comm/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<package format="2">
<name>navigator_drone_comm</name>
<version>0.0.0</version>
<description>The navigator_drone_comm package</description>

<maintainer email="[email protected]">Alex Johnson</maintainer>

<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>rospy</exec_depend>
</package>
11 changes: 11 additions & 0 deletions NaviGator/hardware_drivers/navigator_drone_comm/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from catkin_pkg.python_setup import generate_distutils_setup
from setuptools import setup

# Fetch values from package.xml
setup_args = generate_distutils_setup(
packages=["navigator_drone_comm"],
)

setup(**setup_args)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
!!python/object/new:dynamic_reconfigure.encoding.Config
dictitems:
frame: ecef
groups: !!python/object/new:dynamic_reconfigure.encoding.Config
dictitems:
frame: ecef
groups: !!python/object/new:dynamic_reconfigure.encoding.Config
state: []
id: 0
name: Default
parameters: !!python/object/new:dynamic_reconfigure.encoding.Config
state: []
parent: 0
state: true
type: ''
x1: 744450.0
x2: 744336.0
x3: 744342.0
x4: 744456.0
y1: -5618775.0
y2: -5618790.0
y3: -5618835.0
y4: -5618820.0
z1: 2915236.0
z2: 2915236.0
z3: 2915150.0
z4: 2915150.0
state: []
x1: 744450.0
x2: 744336.0
x3: 744342.0
x4: 744456.0
y1: -5618775.0
y2: -5618790.0
y3: -5618835.0
y4: -5618820.0
z1: 2915236.0
z2: 2915236.0
z3: 2915150.0
z4: 2915150.0
state: []
Loading

0 comments on commit 8ca9a24

Please sign in to comment.