diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b0b873b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ca334b8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..b643029 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..c5bb340 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 197058f..436356b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: pretty-format-json args: [--autofix] - id: trailing-whitespace -- repo: https://github.com/team5499/pre-commit-hooks +- repo: https://github.com/team5419/pre-commit-hooks rev: v0.3.2 hooks: - id: ktlint-wrapper diff --git a/.travis.yml b/.travis.yml index 343d492..986497f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,19 @@ sudo: required services: - docker script: -- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) -- docker run -t -d -v $(pwd):/code:rw --name frc-testing-image team5499/frc-testing-image:frc2019; docker exec frc-testing-image /code/gradlew -p /code test jacocoTestReport +- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; + else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) +- docker run -t -d -v $(pwd):/code:rw --name frc-testing-image team5419/frc-testing-image; + docker exec frc-testing-image /code/gradlew -p /code test jacocoTestReport after_success: -- if [ "$BRANCH" == "master" ]; then docker run -t -d -v $(pwd):/code:rw --name frc-testing-image-java8 team5499/frc-testing-image; docker exec frc-testing-image-java8 /code/gradlew -p /code dokkaJavadoc; fi -- if [ "$BRANCH" == "master" ]; then docker exec frc-testing-image /code/gradlew -p /code publishToTeamRepo --username=$USERNAME --password=$PASSWORD --url=$URL; fi +- if [ "$BRANCH" == "master" ]; then docker run -t -d -v $(pwd):/code:rw --name frc-testing-image-java8 + team5419/frc-testing-image:version-2018.1.0; docker exec frc-testing-image-java8 + /code/gradlew -p /code dokkaJavadoc; fi +- if [ "$BRANCH" == "master" ]; then docker exec frc-testing-image /code/gradlew -p + /code publishToTeamRepo --username=$USERNAME --password=$PASSWORD --url=$URL; fi - bash <(curl -s https://codecov.io/bash) env: global: - - secure: i11zToxl8eKnEHrMyrL17VAk38Mv4o1YAky5b2hg03eSX5qD5q+oFlnCi3WpK8oro0LAinESlTCgIETbnv3qM79RVC+FkfgrUKEitUPvTFS1zkRUlT+dgco3sD7fYZX7IOQ25T3uFIc1F4aXkIGSor/E+5pZU0wmTH0vFoTeyuX9Oo4zGOQi3UmccE3hkzkoKVIhyU+RLUp6aCylMnuLiMbUNDijMNhYqU5Zm+/gN9qmZiHJsst7Vkc+oobnpbdOmZoDNaw53a1D3y0+jlwriQe4Bk/lKMxbWWungpO6KIcV0JLiv/lDmMYX/tnL4xPq6/EecoDNLDWNWNVWcyYjgOpafdjEJ6h/mzvJxUv27bXM57FGzBXA+fy2PT4+tQvkimDeb3Y+YTbohs26cpImRCP148colyjy8aQPWW4BkQieiSZDSEmfhNyDXLXxRfBRx5jj0zSkUtVClabHrFzsJ4lZOqaucRLNKWs7VF0PxE8vFNQHliUhyXZkwrob8xB+lrB0ekI1rrDkCIxzdf5J+r+2bpUuXqv4SiNNVWBgasc7d+ye6UV9el2u6ItRhhVHItFPhnYYFTv3QtZ44mSbjlCU2dRkSPR71cd+Csn3edCjrOwHPd35GgIGrHnIv7/NQetvqtMdfg/+6WMzt3WPkzLgMTEOJY0t1TVvitNV3YA= - - secure: wXy6aDSe9nfd1KjnBBzBG5X4PTIhpVStdvEs5Y/vA8zEWuszf4P2YDzIjf0lKL+K/Ed9GLeaKFdXac1i9VG3mChOxVWQ3kd5Mp5mNm/3iGEQ3OHJ43q9uKJTsSZOuuTHBHfJmLUwxk3Dnz7on3XU0XZKODuIxY0iqEIZ0RFcryIo0VE5glDfAvoqJRkbs56ruBMcZfh3Xx9NdebQN9rglT3w/WEeb7TLgECKkF5ic8wB4YEpEvJm1UvlqtT8TZjpsgmSUxbagTAyy9dIXHAIaksXNHaRBhgs7D0a4xlf6MExp2sp75qBK/5lGqGG+RR8PcYlisw+nH/vnP1AQm3ujP5rL4vkCoLFk4+DVMlnScpiBDI482UM581YnCOlotXF2Oh34QEMVn0SQ0w6yNghLhMhlVk1EDjy/msttvAEef15Xm3f5njIQuzDljvigWRTAPE81peDY6EAXQAsNE3C29N6XLMVFgiefI5NF+PZ+Tu0geYOhP1r3GBixj6W+w3NfC/ZwzapVoA+6OimhYDNOETVLrrIkln4FtU+/RrCtqk1zZhLg22JkxHCNU5NuIiwC8sQcd+hquw63tZVc9vFXFdcVLJZLa/mgtFWUfVKOIQSjua18H4VqZAUP2p9EPcMYJgHRDh2P47R9zFdRdnD7CdNel8uWtdT4P4UFTytnuk= - - secure: H4xBumrS4Z8OXqW+evg/iczS0kRaK7g/HAn7g+a4bwxfHYME6CN7hvwy9MY+McidDcXz/BD88eJnZ4/SyKUdlFFd5PqN5tiUGkHsY9QcQjRTw5alNgONk8S5vHDXqlRizF5EKUm7yBC4DRgFlmhF4TJybxwjI3dSFrKYakvEEtlCC6O3JuXq/PYdoz95AbmoxVrqkGwAojDZdhZ6UggeN+IJYi1h1FZGA0mD5PMKUKAHKxl5WVy9cQYV/+cc4Qy4c/0mrPBZ4KRbHA+UWxEnA/H9DARWLSQsDMZy7QCcQ0OXuM21kVVPt2qNE8wZQ074oX+MKcJbnvGT+AJpDPJwL+iRjch8SuDVpLOWE/LDcNE+r3PjUuL6HdA7/NBN0jhOsKTB3N/D3ehRGpkWlwXnK3zw9/P7HJ6I9MXPf4hq89B+Rg9vRdLAhVxFIuTOLMONVJyALrzX4sm7TaJAdfNC0NIBZpwWKmHzN3eVQovapUfEPo+no2cMXOxwyV/tKXeg6Hf+u4PvHNcmmyCnEDLNd4syayYHWExh4nHkGQPAa6fpQ7FNUdo0AkvwK6lU5ylpHsbsjcWOgWQ7vjbuu08mJ3JsNgb3Lo3kNSm9PXECC9M4rIjyUzTGrFZsS2GbtaS9M0txO1B8Ysv59Y3wruMZ89vpeOoZI6gJoHkLvU7FvYo= + - secure: kOC0dbgpMXULsMY9rUXM+p4gsORHa/nLzVGO3DjGASo9V9aLDTcIH1FrxDmmXlT7yq6wCaQ6Qag+9ORQyYYNIozvNFE5Bu6cvKtUEQL1ejGUdstPMf1dCzxAv8L1IAzVhuszwVKbkAWCIPfnk+HOBeTt+JTPcU3XRZ1h8pT8K7OUlVTq+YExz6ba+R9slgsy/zhzkT3a9LTXjaI+FMcRXiX5GTAf4D4rhspVrls7rJ9TayM3tDdOA7+E3KiINFArIiR55rPweMYzq4EepwF1y28UKwACDCF9G17rlZUWQd1/FlUaRRH7Raqfe8M1pzPAjsJ3pY45ymuSCt+23LXtI273x3Fx3wcZyWsHtbUtSGaSyEVXG10uATk0YYnZmIpjGgci2H+p96tw9Q/uHT0zbfgXdGN717Cwzwn4ywBmzMPxDtwNJBzAM27qUI/wzOTrGwpUxetLqdWHe5vPDMskxi7YkLOH9Tyi9L6fY2PLztLN3FwSBaH0o9MDCca5iFdPQKnut8+jtLKc2NlcQe76HGNuk4pSDeEanK1zk2ac2Qo/FSQ4luHZOFa+r6aEHABK3EpfMQ8z9681Z4jY/TmLaGtFFv4kYxGvO4zkHoJcQcFpT8mRWxL8tDg8KyW228VNkucBVHSLzyddEi+0VcanAju7UNFMNyaDwPqG/hGqW0o= + - secure: pVcUGU+vNcilbe5y3+g0l173j0KW+/PVrVJE97k471jRgLkEH8W9nRWw0rcZmOEfSM+p5a1l8ubzqzriiJKIexVXkGfrL8k6tSibUY2HCcFG9RZPvCyqZvPqBFSpf11xQ/iKlGzjRKHmc39P4+jLUkVWIQYS496pLx/bzKBWYzUwTXOrHq9a26mBJ3Ud4iLK/Ztq06u1cZ1IE7Vo1x4f20+uF0ZKnhhLT1jDxS2W5mT3XGQWatlnLdhSy6qKOpdld1O4961hh9XrNvvAtqIZqWbfWLwMQ1y4c9oxhuon2e8/r6eovdess9d/bziqzadtimvmVVR8zHhKRx5F0G9ZqnmR5vnhL82hVKKYZmP4WNZvMJhdKmxtgiEWn5Idf/QqHpYCzPscEUqpfNNAzd5EA07UoRfExantO5QaI4IK6AOvy3J8RoG+ajbnwVFK6F+xahavOTAmV+LkRQbzN10srXpv1YsE0Y7L/R/RtThfzXI1Cq8+A5iItZb703VxAHaqVgFeL/VEDEaN31/ytxzQJ/dI33BrGAM+tM4LNe1H5CnvDzrHWy+a8jWXpUbrupi4Nk1plX+zE3uqjK/M2Wm8/IupVO9Euv7vme3uPkw+tSssnZQLvQE+AlbeaFjfaynCjkrTvj7AfBFmfU+L4EJDFVi9/ojwScWGwe5CaXvixAE= + - secure: QXqmDtpf4J4g33LQT/zUVlkQ+3+9Xsy6LwqTSi2aKbfQkBKKzvHhCVRqpudedgjtXyQmU4WK6LXRpyFGAL6BLeOY1eRzCVxfhIw4c3HTxwUlfx40kl/BTT/nyKzg2rZxf5+IIvejWRZQ+59+M/RClzv5gWD4WDW6wwvEfRbZ30rTgHIjvNZ2W/mrvuQcDNTps/HkJmbbS/oUP76sgKDEo4DL1qAVNsFrNpLa8p6gPzzLqevZcpW2RBtvEvpZ5SKoHs5SeKryWnq0shBsb0skuRV35HNhOvcLPWBYTPzxp5LjxN5EF+1akrAWMB38GHSbOAyZVH4sbupU928gK1Gyzs+zDP7ZKcAMcrwqGZcTBSbcUq0vVYNg+LRTORJ+jmcDwBSaGntpqUcKBXmyB1SGq9f79qCmGSJTBM5VLXcKPApT+hdx1p/B3F9NUNie/wcM7qOwsH3ROLryPwf+FmYlFxnZ5gHAt5nVWhXQDVijWBpnCIeHkoiI6eUMt4+feaifi+y1BwQyPpmZAsxfqvXrQm6M1UmBqNzaupc/ss/VRE0K1ExnXb5mNMl4m2V8TN7d/PgKmlwG9J4mA+C5hpcx7qHbno/rCJmWMqKk00KFB55MzdXyw3x2t2cxmf3ryy+qE7Y9Vp/7T3vdW94zh/zFsV7fZBfE4UPigbNKQ0kgzrs= diff --git a/MonkeyLib.iml b/MonkeyLib.iml new file mode 100644 index 0000000..339a443 --- /dev/null +++ b/MonkeyLib.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 755878e..505973a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MonkeyLib +# fault -[![Build Status](https://travis-ci.org/team5499/MonkeyLib.svg?branch=master)](https://travis-ci.org/team5499/MonkeyLib) -[![Code Coverage](https://codecov.io/gh/team5499/MonkeyLib/branch/master/graph/badge.svg)](https://codecov.io/gh/team5499/MonkeyLib) +[![Build Status](https://travis-ci.org/team5419/fault.svg?branch=master)](https://travis-ci.org/team5419/fault) +[![Code Coverage](https://codecov.io/gh/team5419/fault/branch/master/graph/badge.svg)](https://codecov.io/gh/team5419/fault) -MonkeyLib is team 5499's base kotlin code used in all of our robots. Mostly contains math and utilities +fault is team 5419's base kotlin code used in all of our robots. Mostly contains math and utilities diff --git a/build.gradle b/build.gradle index cc267dd..48b6412 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import org.gradle.api.tasks.options.Option plugins { id 'org.jetbrains.kotlin.jvm' version '1.3.20' - id "edu.wpi.first.GradleRIO" version "2019.3.2" + id "edu.wpi.first.GradleRIO" version "2019.4.1" id 'java-library' id 'maven-publish' id 'jacoco' @@ -34,7 +34,7 @@ dependencies { } -group = 'org.team5499' +group = 'org.team5419' version = '2.11.0' @@ -106,14 +106,14 @@ task install_hooks(dependsOn: 'tox') publishing { publications { library(MavenPublication) { - artifactId = 'monkey-lib' + artifactId = 'fault' from components.java artifact sourcesJar artifact javadocJar pom { - name = 'MonkeyLib' - description = 'Commonly used utilities in FRC Team 5499\'s codebase' - url = 'https://github.com/team5499/MonkeyLib' + name = 'fault' + description = 'Commonly used utilities in FRC Team 5419\'s codebase' + url = 'https://github.com/team5419/fault' } } } diff --git a/src/main/kotlin/org/team5499/monkeyLib/Controller.kt b/src/main/kotlin/org/team5419/fault/Controller.kt similarity index 63% rename from src/main/kotlin/org/team5499/monkeyLib/Controller.kt rename to src/main/kotlin/org/team5419/fault/Controller.kt index 4d337ca..00dc424 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/Controller.kt +++ b/src/main/kotlin/org/team5419/fault/Controller.kt @@ -1,7 +1,7 @@ -package org.team5499.monkeyLib +package org.team5419.fault -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer public abstract class Controller(timer: ITimer = WPITimer()) { diff --git a/src/main/kotlin/org/team5499/monkeyLib/Subsystem.kt b/src/main/kotlin/org/team5419/fault/Subsystem.kt similarity index 62% rename from src/main/kotlin/org/team5499/monkeyLib/Subsystem.kt rename to src/main/kotlin/org/team5419/fault/Subsystem.kt index b736591..2424bba 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/Subsystem.kt +++ b/src/main/kotlin/org/team5419/fault/Subsystem.kt @@ -1,7 +1,7 @@ -package org.team5499.monkeyLib +package org.team5419.fault -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer abstract class Subsystem(timer: ITimer = WPITimer()) { diff --git a/src/main/kotlin/org/team5499/monkeyLib/auto/Action.kt b/src/main/kotlin/org/team5419/fault/auto/Action.kt similarity index 78% rename from src/main/kotlin/org/team5499/monkeyLib/auto/Action.kt rename to src/main/kotlin/org/team5419/fault/auto/Action.kt index 0a1bb93..ea40610 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/auto/Action.kt +++ b/src/main/kotlin/org/team5419/fault/auto/Action.kt @@ -1,34 +1,34 @@ -package org.team5499.monkeyLib.auto - -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer - -public open class Action(timeoutSeconds: Double, timer: ITimer = WPITimer()) { - - private val mTimer: ITimer - private val mTimeoutSeconds: Double - - init { - mTimer = timer - mTimeoutSeconds = timeoutSeconds - } - - public open fun start() { - mTimer.stop() - mTimer.reset() - mTimer.start() - } - - public open fun update() {} - - protected fun timedOut(): Boolean { - val t = mTimer.get() - return (t >= mTimeoutSeconds) - } - - public open fun next(): Boolean { - return timedOut() - } - - public open fun finish() {} -} +package org.team5419.fault.auto + +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer + +public open class Action(timeoutSeconds: Double, timer: ITimer = WPITimer()) { + + private val mTimer: ITimer + private val mTimeoutSeconds: Double + + init { + mTimer = timer + mTimeoutSeconds = timeoutSeconds + } + + public open fun start() { + mTimer.stop() + mTimer.reset() + mTimer.start() + } + + public open fun update() {} + + protected fun timedOut(): Boolean { + val t = mTimer.get() + return (t >= mTimeoutSeconds) + } + + public open fun next(): Boolean { + return timedOut() + } + + public open fun finish() {} +} diff --git a/src/main/kotlin/org/team5419/fault/auto/NothingAction.kt b/src/main/kotlin/org/team5419/fault/auto/NothingAction.kt new file mode 100644 index 0000000..b2d931e --- /dev/null +++ b/src/main/kotlin/org/team5419/fault/auto/NothingAction.kt @@ -0,0 +1,6 @@ +package org.team5419.fault.auto + +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer + +public class NothingAction(timeout: Double, timer: ITimer = WPITimer()) : Action(timeout, timer) diff --git a/src/main/kotlin/org/team5499/monkeyLib/auto/ParallelAction.kt b/src/main/kotlin/org/team5419/fault/auto/ParallelAction.kt similarity index 81% rename from src/main/kotlin/org/team5499/monkeyLib/auto/ParallelAction.kt rename to src/main/kotlin/org/team5419/fault/auto/ParallelAction.kt index 44c1e2e..937a6f4 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/auto/ParallelAction.kt +++ b/src/main/kotlin/org/team5419/fault/auto/ParallelAction.kt @@ -1,44 +1,44 @@ -package org.team5499.monkeyLib.auto - -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer - -class ParallelAction(vararg actions: Action, timer: ITimer = WPITimer()) : Action(0.0, timer) { - - private val mActions: Array - - init { - mActions = actions.copyOf() - } - - override fun start() { - super.start() - for (a: Action in mActions) { - a.start() - } - } - - override fun update() { - super.update() - for (a: Action in mActions) { - a.update() - } - } - - @Suppress("ReturnCount") - override fun next(): Boolean { - for (a: Action in mActions) { - if (!a.next()) { - return false - } - } - return true - } - - override fun finish() { - super.finish() - for (a: Action in mActions) { - a.finish() - } - } -} +package org.team5419.fault.auto + +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer + +class ParallelAction(vararg actions: Action, timer: ITimer = WPITimer()) : Action(0.0, timer) { + + private val mActions: Array + + init { + mActions = actions.copyOf() + } + + override fun start() { + super.start() + for (a: Action in mActions) { + a.start() + } + } + + override fun update() { + super.update() + for (a: Action in mActions) { + a.update() + } + } + + @Suppress("ReturnCount") + override fun next(): Boolean { + for (a: Action in mActions) { + if (!a.next()) { + return false + } + } + return true + } + + override fun finish() { + super.finish() + for (a: Action in mActions) { + a.finish() + } + } +} diff --git a/src/main/kotlin/org/team5419/fault/auto/ParrallelRoutine.kt b/src/main/kotlin/org/team5419/fault/auto/ParrallelRoutine.kt new file mode 100644 index 0000000..957eeb1 --- /dev/null +++ b/src/main/kotlin/org/team5419/fault/auto/ParrallelRoutine.kt @@ -0,0 +1,63 @@ + +package org.team5419.fault.auto + +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Pose2d + +public class ParrallelRoutine(name: String, startPose: Pose2d, vararg routines: Routine) { +/*: Routine(name, startPose, routines) {*/ + + private val routines: Array + var stepNumber: Int + get() = field + val name: String + get() = field + val startPose: Pose2d + get() = field + + @Suppress("SpreadOperator") + public constructor(name: String, vararg routines: Routine) : + this(name, Pose2d(Vector2(0, 0), Rotation2d.fromDegrees(0.0)), *routines) + + init { + this.stepNumber = 0 + this.name = name + this.startPose = startPose + this.routines = routines.copyOf() + } + + // use an array instead? + // returns MutableList of all current Actions + public fun getCurrentActions(): MutableList { + val actions: MutableList = mutableListOf() + for (r: Routine in this.routines) actions.add(r.getCurrentAction()) + return actions + } + + // advance all subroutines + public fun advanceRoutine() { + if (!this.isLastStep()) { + stepNumber++ + for (r: Routine in this.routines) r.advanceRoutine() + } + } + + // returns true if all subroutines are done + public fun isLastStep(): Boolean { + for (r: Routine in this.routines) { + if (!r.isLastStep()) { + return false + } + } + return true + } + + // resets all subroutines + public fun reset() { + this.stepNumber = 0 + for (r: Routine in this.routines) { + r.reset() + } + } +} diff --git a/src/main/kotlin/org/team5499/monkeyLib/auto/Routine.kt b/src/main/kotlin/org/team5419/fault/auto/Routine.kt similarity index 80% rename from src/main/kotlin/org/team5499/monkeyLib/auto/Routine.kt rename to src/main/kotlin/org/team5419/fault/auto/Routine.kt index 319e6da..fac60d5 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/auto/Routine.kt +++ b/src/main/kotlin/org/team5419/fault/auto/Routine.kt @@ -1,47 +1,47 @@ -package org.team5499.monkeyLib.auto - -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Pose2d - -class Routine(name: String, startPose: Pose2d, vararg actions: Action) { - - private val actions: Array - var stepNumber: Int - get() = field - val name: String - get() = field - val startPose: Pose2d - get() = field - - init { - this.stepNumber = 0 - this.name = name - this.startPose = startPose - this.actions = actions.copyOf() - } - - @Suppress("SpreadOperator") - public constructor(name: String, vararg actions: Action) : - this(name, Pose2d(Vector2(0, 0), Rotation2d.fromDegrees(0.0)), *actions) - - public fun getCurrentAction(): Action { - return actions.get(stepNumber) - } - - public fun advanceRoutine(): Boolean { - if (isLastStep()) { - return false - } - stepNumber++ - return true - } - - public fun reset() { - this.stepNumber = 0 - } - - public fun isLastStep(): Boolean { - return (stepNumber >= (actions.size - 1)) - } -} +package org.team5419.fault.auto + +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Pose2d + +class Routine(name: String, startPose: Pose2d, vararg actions: Action) { + + private val actions: Array + var stepNumber: Int + get() = field + val name: String + get() = field + val startPose: Pose2d + get() = field + + init { + this.stepNumber = 0 + this.name = name + this.startPose = startPose + this.actions = actions.copyOf() + } + + @Suppress("SpreadOperator") + public constructor(name: String, vararg actions: Action) : + this(name, Pose2d(Vector2(0, 0), Rotation2d.fromDegrees(0.0)), *actions) + + public fun getCurrentAction(): Action { + return actions.get(stepNumber) + } + + public fun advanceRoutine(): Boolean { + if (isLastStep()) { + return false + } + stepNumber++ + return true + } + + public fun reset() { + this.stepNumber = 0 + } + + public fun isLastStep(): Boolean { + return (stepNumber >= (actions.size - 1)) + } +} diff --git a/src/main/kotlin/org/team5499/monkeyLib/auto/SerialAction.kt b/src/main/kotlin/org/team5419/fault/auto/SerialAction.kt similarity index 91% rename from src/main/kotlin/org/team5499/monkeyLib/auto/SerialAction.kt rename to src/main/kotlin/org/team5419/fault/auto/SerialAction.kt index baa0a55..6c5fbc9 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/auto/SerialAction.kt +++ b/src/main/kotlin/org/team5419/fault/auto/SerialAction.kt @@ -1,36 +1,36 @@ - -package org.team5499.monkeyLib.auto - -public class SerialAction(vararg actions: Action) : Action(0.0) { - - private val childActions: Array - private var index: Int = 0 - - init { - childActions = actions - } - - public override fun start() { - this.index = 0 - super.start() - childActions[index].start() - } - - public override fun update() { - if (index == childActions.size - 1) return - if (childActions[index].next()) { - childActions[index].finish() - index++ - childActions[index].start() - } - childActions[index].update() - } - - public override fun next(): Boolean { - return index == (childActions.size - 1) && childActions[childActions.size - 1].next() - } - - public override fun finish() { - super.finish() - } -} + +package org.team5419.fault.auto + +public class SerialAction(vararg actions: Action) : Action(0.0) { + + private val childActions: Array + private var index: Int = 0 + + init { + childActions = actions + } + + public override fun start() { + this.index = 0 + super.start() + childActions[index].start() + } + + public override fun update() { + if (index == childActions.size - 1) return + if (childActions[index].next()) { + childActions[index].finish() + index++ + childActions[index].start() + } + childActions[index].update() + } + + public override fun next(): Boolean { + return index == (childActions.size - 1) && childActions[childActions.size - 1].next() + } + + public override fun finish() { + super.finish() + } +} diff --git a/src/main/kotlin/org/team5499/monkeyLib/hardware/LazyTalonSRX.kt b/src/main/kotlin/org/team5419/fault/hardware/LazyTalonSRX.kt similarity index 97% rename from src/main/kotlin/org/team5499/monkeyLib/hardware/LazyTalonSRX.kt rename to src/main/kotlin/org/team5419/fault/hardware/LazyTalonSRX.kt index c6562f0..5f656d2 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/hardware/LazyTalonSRX.kt +++ b/src/main/kotlin/org/team5419/fault/hardware/LazyTalonSRX.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.hardware +package org.team5419.fault.hardware import com.ctre.phoenix.motorcontrol.can.TalonSRX import com.ctre.phoenix.motorcontrol.ControlMode diff --git a/src/main/kotlin/org/team5499/monkeyLib/hardware/LazyVictorSPX.kt b/src/main/kotlin/org/team5419/fault/hardware/LazyVictorSPX.kt similarity index 97% rename from src/main/kotlin/org/team5499/monkeyLib/hardware/LazyVictorSPX.kt rename to src/main/kotlin/org/team5419/fault/hardware/LazyVictorSPX.kt index 814cb57..782050b 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/hardware/LazyVictorSPX.kt +++ b/src/main/kotlin/org/team5419/fault/hardware/LazyVictorSPX.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.hardware +package org.team5419.fault.hardware import com.ctre.phoenix.motorcontrol.can.VictorSPX import com.ctre.phoenix.motorcontrol.ControlMode diff --git a/src/main/kotlin/org/team5499/monkeyLib/hardware/XboxControllerPlus.kt b/src/main/kotlin/org/team5419/fault/hardware/XboxControllerPlus.kt similarity index 93% rename from src/main/kotlin/org/team5499/monkeyLib/hardware/XboxControllerPlus.kt rename to src/main/kotlin/org/team5419/fault/hardware/XboxControllerPlus.kt index ebc854b..d0f64d9 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/hardware/XboxControllerPlus.kt +++ b/src/main/kotlin/org/team5419/fault/hardware/XboxControllerPlus.kt @@ -1,9 +1,9 @@ -package org.team5499.monkeyLib.hardware +package org.team5419.fault.hardware import edu.wpi.first.wpilibj.XboxController -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.WPITimer import java.util.concurrent.atomic.AtomicBoolean diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/ButtonState.kt b/src/main/kotlin/org/team5419/fault/input/ButtonState.kt similarity index 71% rename from src/main/kotlin/org/team5499/monkeyLib/input/ButtonState.kt rename to src/main/kotlin/org/team5419/fault/input/ButtonState.kt index faa4c19..13304d2 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/ButtonState.kt +++ b/src/main/kotlin/org/team5419/fault/input/ButtonState.kt @@ -1,3 +1,3 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input public data class ButtonState(val down: Boolean, val pressed: Boolean, val released: Boolean) diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/CheesyDriveHelper.kt b/src/main/kotlin/org/team5419/fault/input/CheesyDriveHelper.kt similarity index 98% rename from src/main/kotlin/org/team5499/monkeyLib/input/CheesyDriveHelper.kt rename to src/main/kotlin/org/team5419/fault/input/CheesyDriveHelper.kt index 84a89f8..f1f5db0 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/CheesyDriveHelper.kt +++ b/src/main/kotlin/org/team5419/fault/input/CheesyDriveHelper.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input -import org.team5499.monkeyLib.util.Utils +import org.team5419.fault.util.Utils public class CheesyDriveHelper(config: CheesyDriveConfig) : DriveHelper() { diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/DriveHelper.kt b/src/main/kotlin/org/team5419/fault/input/DriveHelper.kt similarity index 89% rename from src/main/kotlin/org/team5499/monkeyLib/input/DriveHelper.kt rename to src/main/kotlin/org/team5419/fault/input/DriveHelper.kt index 591f617..d34db1c 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/DriveHelper.kt +++ b/src/main/kotlin/org/team5419/fault/input/DriveHelper.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input abstract class DriveHelper { diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/DriveSignal.kt b/src/main/kotlin/org/team5419/fault/input/DriveSignal.kt similarity index 85% rename from src/main/kotlin/org/team5499/monkeyLib/input/DriveSignal.kt rename to src/main/kotlin/org/team5419/fault/input/DriveSignal.kt index 4ab40c1..ebf10bb 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/DriveSignal.kt +++ b/src/main/kotlin/org/team5419/fault/input/DriveSignal.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input -import org.team5499.monkeyLib.util.CSVWritable +import org.team5419.fault.util.CSVWritable data class DriveSignal(val left: Double, val right: Double, val brakeMode: Boolean) : CSVWritable { diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/SpaceDriveHelper.kt b/src/main/kotlin/org/team5419/fault/input/SpaceDriveHelper.kt similarity index 96% rename from src/main/kotlin/org/team5499/monkeyLib/input/SpaceDriveHelper.kt rename to src/main/kotlin/org/team5419/fault/input/SpaceDriveHelper.kt index 9b6e628..9382b76 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/SpaceDriveHelper.kt +++ b/src/main/kotlin/org/team5419/fault/input/SpaceDriveHelper.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input public class SpaceDriveHelper(deadband: () -> Double, turnMult: () -> Double, slowMult: () -> Double) : DriveHelper() { diff --git a/src/main/kotlin/org/team5499/monkeyLib/input/TankDriveHelper.kt b/src/main/kotlin/org/team5419/fault/input/TankDriveHelper.kt similarity index 94% rename from src/main/kotlin/org/team5499/monkeyLib/input/TankDriveHelper.kt rename to src/main/kotlin/org/team5419/fault/input/TankDriveHelper.kt index f7c2848..ec54554 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/input/TankDriveHelper.kt +++ b/src/main/kotlin/org/team5419/fault/input/TankDriveHelper.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.input +package org.team5419.fault.input public class TankDriveHelper(deadband: Double, slowMultiplier: Double) : DriveHelper() { diff --git a/src/main/kotlin/org/team5419/fault/logging/Logger.kt b/src/main/kotlin/org/team5419/fault/logging/Logger.kt new file mode 100644 index 0000000..e61dded --- /dev/null +++ b/src/main/kotlin/org/team5419/fault/logging/Logger.kt @@ -0,0 +1,3 @@ +package org.team5419.fault.logging + +// main logging class diff --git a/src/main/kotlin/org/team5499/monkeyLib/logging/ReflectingCSVWriter.kt b/src/main/kotlin/org/team5419/fault/logging/ReflectingCSVWriter.kt similarity index 95% rename from src/main/kotlin/org/team5499/monkeyLib/logging/ReflectingCSVWriter.kt rename to src/main/kotlin/org/team5419/fault/logging/ReflectingCSVWriter.kt index 74dc91f..238c438 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/logging/ReflectingCSVWriter.kt +++ b/src/main/kotlin/org/team5419/fault/logging/ReflectingCSVWriter.kt @@ -1,11 +1,11 @@ -package org.team5499.monkeyLib.logging +package org.team5419.fault.logging import java.io.FileNotFoundException import java.io.PrintWriter import java.lang.reflect.Field import java.util.concurrent.ConcurrentLinkedDeque -import org.team5499.monkeyLib.util.CSVWritable +import org.team5419.fault.util.CSVWritable class ReflectingCSVWriter(filename: String, typeClass: Class) { private val mLinesToWrite: ConcurrentLinkedDeque = ConcurrentLinkedDeque() diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/Epsilon.kt b/src/main/kotlin/org/team5419/fault/math/Epsilon.kt similarity index 90% rename from src/main/kotlin/org/team5499/monkeyLib/math/Epsilon.kt rename to src/main/kotlin/org/team5419/fault/math/Epsilon.kt index 9253b49..594deaa 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/Epsilon.kt +++ b/src/main/kotlin/org/team5419/fault/math/Epsilon.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.math +package org.team5419.fault.math object Epsilon { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/Position.kt b/src/main/kotlin/org/team5419/fault/math/Position.kt similarity index 91% rename from src/main/kotlin/org/team5499/monkeyLib/math/Position.kt rename to src/main/kotlin/org/team5419/fault/math/Position.kt index 85270fb..600233a 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/Position.kt +++ b/src/main/kotlin/org/team5419/fault/math/Position.kt @@ -1,7 +1,7 @@ -package org.team5499.monkeyLib.math +package org.team5419.fault.math -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.util.CSVWritable +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.util.CSVWritable class Position : CSVWritable { diff --git a/src/main/kotlin/org/team5419/fault/math/UnitConverter.kt b/src/main/kotlin/org/team5419/fault/math/UnitConverter.kt new file mode 100644 index 0000000..9150569 --- /dev/null +++ b/src/main/kotlin/org/team5419/fault/math/UnitConverter.kt @@ -0,0 +1,44 @@ +package org.team5419.fault.math.units + +// Unit Conversion Code + +public infix fun Double.from(conversion: Double): UnitConverter { + return UnitConverter(this * conversion) +} + +data class UnitConverter internal constructor(internal val value: Double) { + public infix fun to(conversion: Double): Double { + return value / conversion + } +} + +// Distance Units + +public const val CENTIMETERS: Double = 0.01 +public const val DECIMETERS: Double = 0.1 +public const val METERS: Double = 1.0 +public const val KILOMETERS: Double = 1000.0 + +public const val INCHS: Double = 0.0254 +public const val FEET: Double = 12 * INCHS +public const val YARDS: Double = 3 * FEET +public const val MILES: Double = 5280 * FEET + +// Time Units + +public const val MILLISECONDS: Double = 0.001 +public const val SECONDS: Double = 1.0 +public const val MINUTES: Double = 60.0 +public const val HOURS: Double = 60.0 * MINUTES + +// Current Units + +public const val MICROAMPERS: Double = 1 / 1e-6 +public const val MILLIAMPS: Double = 0.001 +public const val AMPS: Double = 1.0 + +// Electrical Potental Units + +public const val MICROVOLTS: Double = 1 / 1e-6 +public const val MILLIVOLTS: Double = 0.001 +public const val VOLTS: Double = 1.0 diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Geometric.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Geometric.kt similarity index 68% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Geometric.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Geometric.kt index 91aaa0c..4630277 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Geometric.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Geometric.kt @@ -1,7 +1,7 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry -import org.team5499.monkeyLib.util.Interpolable -import org.team5499.monkeyLib.util.CSVWritable +import org.team5419.fault.util.Interpolable +import org.team5419.fault.util.CSVWritable interface Geometric : Interpolable, CSVWritable { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2d.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Pose2d.kt similarity index 97% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2d.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Pose2d.kt index d05f0f0..a3c439a 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2d.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Pose2d.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon @Suppress("TooManyFunctions") class Pose2d(translation: Vector2, rotation: Rotation2d) : Geometric { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2dWithCurvature.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Pose2dWithCurvature.kt similarity index 95% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2dWithCurvature.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Pose2dWithCurvature.kt index 16e6995..cf393fe 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Pose2dWithCurvature.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Pose2dWithCurvature.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry -import org.team5499.monkeyLib.util.Utils +import org.team5419.fault.util.Utils class Pose2dWithCurvature( translation: Vector2, diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Rotation2d.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Rotation2d.kt similarity index 97% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Rotation2d.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Rotation2d.kt index eb42561..056e7fe 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Rotation2d.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Rotation2d.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon import java.text.DecimalFormat diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Twist2d.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Twist2d.kt similarity index 94% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Twist2d.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Twist2d.kt index f0e1fea..e765cc7 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Twist2d.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Twist2d.kt @@ -1,8 +1,8 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry import java.text.DecimalFormat -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon class Twist2d(dx: Double, dy: Double, dTheta: Double) : Geometric { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Vector2.kt b/src/main/kotlin/org/team5419/fault/math/geometry/Vector2.kt similarity index 98% rename from src/main/kotlin/org/team5499/monkeyLib/math/geometry/Vector2.kt rename to src/main/kotlin/org/team5419/fault/math/geometry/Vector2.kt index fa3c879..930c560 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/geometry/Vector2.kt +++ b/src/main/kotlin/org/team5419/fault/math/geometry/Vector2.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.math.geometry +package org.team5419.fault.math.geometry @Suppress("TooManyFunctions") class Vector2(val x: Double, val y: Double) : Geometric { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/physics/DCMotorTransmission.kt b/src/main/kotlin/org/team5419/fault/math/physics/DCMotorTransmission.kt similarity index 98% rename from src/main/kotlin/org/team5499/monkeyLib/math/physics/DCMotorTransmission.kt rename to src/main/kotlin/org/team5419/fault/math/physics/DCMotorTransmission.kt index cc92245..6260932 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/physics/DCMotorTransmission.kt +++ b/src/main/kotlin/org/team5419/fault/math/physics/DCMotorTransmission.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.math.physics +package org.team5419.fault.math.physics /** * Model of a DC motor rotating a shaft. All parameters refer to the output (e.g. should already consider gearing diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/pid/PIDF.kt b/src/main/kotlin/org/team5419/fault/math/pid/PIDF.kt similarity index 98% rename from src/main/kotlin/org/team5499/monkeyLib/math/pid/PIDF.kt rename to src/main/kotlin/org/team5419/fault/math/pid/PIDF.kt index c1c5ff2..7a8d03d 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/pid/PIDF.kt +++ b/src/main/kotlin/org/team5419/fault/math/pid/PIDF.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.math.pid +package org.team5419.fault.math.pid import edu.wpi.first.wpilibj.Timer diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/splines/CubicHermiteSpline.kt b/src/main/kotlin/org/team5419/fault/math/splines/CubicHermiteSpline.kt similarity index 90% rename from src/main/kotlin/org/team5499/monkeyLib/math/splines/CubicHermiteSpline.kt rename to src/main/kotlin/org/team5419/fault/math/splines/CubicHermiteSpline.kt index 63b03d8..e52024c 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/splines/CubicHermiteSpline.kt +++ b/src/main/kotlin/org/team5419/fault/math/splines/CubicHermiteSpline.kt @@ -1,8 +1,8 @@ -package org.team5499.monkeyLib.math.splines +package org.team5419.fault.math.splines -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d @SuppressWarnings("MagicNumber") class CubicHermiteSpline(p0: Vector2, h0: Rotation2d, p1: Vector2, h1: Rotation2d) : Spline() { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/splines/QuinticHermiteSpline.kt b/src/main/kotlin/org/team5419/fault/math/splines/QuinticHermiteSpline.kt similarity index 98% rename from src/main/kotlin/org/team5499/monkeyLib/math/splines/QuinticHermiteSpline.kt rename to src/main/kotlin/org/team5419/fault/math/splines/QuinticHermiteSpline.kt index 83b96c7..ad5f57b 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/splines/QuinticHermiteSpline.kt +++ b/src/main/kotlin/org/team5419/fault/math/splines/QuinticHermiteSpline.kt @@ -1,8 +1,8 @@ -package org.team5499.monkeyLib.math.splines +package org.team5419.fault.math.splines -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d // yes external contructors are disgusting. but they work @Suppress("FunctionNaming", "MagicNumber") diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/splines/Spline.kt b/src/main/kotlin/org/team5419/fault/math/splines/Spline.kt similarity index 66% rename from src/main/kotlin/org/team5499/monkeyLib/math/splines/Spline.kt rename to src/main/kotlin/org/team5419/fault/math/splines/Spline.kt index acb4c7f..2afb127 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/splines/Spline.kt +++ b/src/main/kotlin/org/team5419/fault/math/splines/Spline.kt @@ -1,9 +1,9 @@ -package org.team5499.monkeyLib.math.splines +package org.team5419.fault.math.splines -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Pose2dWithCurvature abstract class Spline { diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/splines/SplineGenerator.kt b/src/main/kotlin/org/team5419/fault/math/splines/SplineGenerator.kt similarity index 93% rename from src/main/kotlin/org/team5499/monkeyLib/math/splines/SplineGenerator.kt rename to src/main/kotlin/org/team5419/fault/math/splines/SplineGenerator.kt index da6c4ac..bb83070 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/math/splines/SplineGenerator.kt +++ b/src/main/kotlin/org/team5419/fault/math/splines/SplineGenerator.kt @@ -1,8 +1,8 @@ -package org.team5499.monkeyLib.math.splines +package org.team5419.fault.math.splines -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Pose2dWithCurvature @SuppressWarnings("LongParameterList") object SplineGenerator { diff --git a/src/main/kotlin/org/team5499/monkeyLib/path/MirroredPath.kt b/src/main/kotlin/org/team5419/fault/path/MirroredPath.kt similarity index 84% rename from src/main/kotlin/org/team5499/monkeyLib/path/MirroredPath.kt rename to src/main/kotlin/org/team5419/fault/path/MirroredPath.kt index 9c8de64..204ee0c 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/path/MirroredPath.kt +++ b/src/main/kotlin/org/team5419/fault/path/MirroredPath.kt @@ -1,6 +1,6 @@ -package org.team5499.monkeyLib.path +package org.team5419.fault.path -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature +import org.team5419.fault.math.geometry.Pose2dWithCurvature /** * this class represents a path that can be mirrored over the centerline of the field diff --git a/src/main/kotlin/org/team5499/monkeyLib/path/Path.kt b/src/main/kotlin/org/team5419/fault/path/Path.kt similarity index 89% rename from src/main/kotlin/org/team5499/monkeyLib/path/Path.kt rename to src/main/kotlin/org/team5419/fault/path/Path.kt index e2021fe..00abdc7 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/path/Path.kt +++ b/src/main/kotlin/org/team5419/fault/path/Path.kt @@ -1,96 +1,96 @@ -package org.team5499.monkeyLib.path - -import org.team5499.monkeyLib.util.CSVWritable - -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature - -class Path( - points: MutableList, - velocities: MutableList, - reversed: Boolean = false -) : CSVWritable { - - internal val points: MutableList - internal val velocities: MutableList - - val pathLength: Int - get() = points.size - - val reversed: Boolean - get() = field - - val startPose: Pose2dWithCurvature - get() = Pose2dWithCurvature(points.get(0)) - - val endPose: Pose2dWithCurvature - get() = Pose2dWithCurvature(points.get(pathLength - 1)) - - val startVelocity: Double - get() = velocities.get(0) - - val endVelocity: Double - get() = velocities.get(velocities.size - 1) - - init { - if (points.size != velocities.size) { - println("coords length: ${points.size}, velo length: ${velocities.size}") - throw IllegalArgumentException("Velocity and Coordinate arrays need to be same length.") - } - if (points.size < 2) throw IllegalArgumentException("Needs to be more than 2 points for a path") - this.reversed = reversed - this.points = points.toMutableList() - this.velocities = velocities.toMutableList() - } - - constructor(other: Path): this(other.points.toMutableList(), other.velocities, other.reversed) - - fun getPose(index: Int): Pose2dWithCurvature { - if (index >= points.size || index < 0) { - throw IndexOutOfBoundsException("Point $index not in path") - } - return points.get(index) - } - - fun getVelocity(index: Int): Double { - if (index >= points.size || index < 0) { - throw IndexOutOfBoundsException("Point $index not in velocities") - } - return velocities.get(index) - } - - fun findClosestPointIndex(point: Pose2d, lastIndex: Int): Int { - val lastPose: Vector2 = points.get(lastIndex).translation - var minDistance: Double = Vector2.distanceBetween(point.translation, lastPose) - var index: Int = lastIndex - for (i in lastIndex..points.size - 1) { - val tempDistance: Double = Vector2.distanceBetween(point.translation, points.get(i).translation) - if (tempDistance < minDistance) { - index = i - minDistance = tempDistance - } - } - return index - } - - override fun toString(): String { - val buffer: StringBuilder = StringBuilder() - for (i in 0..points.size - 1) { - buffer.append(points.get(i).toString()) - buffer.append(System.lineSeparator()) - } - return buffer.toString() - } - - override fun toCSV(): String { - val buffer: StringBuilder = StringBuilder() - for (i in 0..points.size - 1) { - buffer.append(points.get(i).pose.toCSV()) - buffer.append(", ") - buffer.append(velocities.get(i)) - buffer.append(System.lineSeparator()) - } - return buffer.toString() - } -} +package org.team5419.fault.path + +import org.team5419.fault.util.CSVWritable + +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Pose2dWithCurvature + +class Path( + points: MutableList, + velocities: MutableList, + reversed: Boolean = false +) : CSVWritable { + + internal val points: MutableList + internal val velocities: MutableList + + val pathLength: Int + get() = points.size + + val reversed: Boolean + get() = field + + val startPose: Pose2dWithCurvature + get() = Pose2dWithCurvature(points.get(0)) + + val endPose: Pose2dWithCurvature + get() = Pose2dWithCurvature(points.get(pathLength - 1)) + + val startVelocity: Double + get() = velocities.get(0) + + val endVelocity: Double + get() = velocities.get(velocities.size - 1) + + init { + if (points.size != velocities.size) { + println("coords length: ${points.size}, velo length: ${velocities.size}") + throw IllegalArgumentException("Velocity and Coordinate arrays need to be same length.") + } + if (points.size < 2) throw IllegalArgumentException("Needs to be more than 2 points for a path") + this.reversed = reversed + this.points = points.toMutableList() + this.velocities = velocities.toMutableList() + } + + constructor(other: Path): this(other.points.toMutableList(), other.velocities, other.reversed) + + fun getPose(index: Int): Pose2dWithCurvature { + if (index >= points.size || index < 0) { + throw IndexOutOfBoundsException("Point $index not in path") + } + return points.get(index) + } + + fun getVelocity(index: Int): Double { + if (index >= points.size || index < 0) { + throw IndexOutOfBoundsException("Point $index not in velocities") + } + return velocities.get(index) + } + + fun findClosestPointIndex(point: Pose2d, lastIndex: Int): Int { + val lastPose: Vector2 = points.get(lastIndex).translation + var minDistance: Double = Vector2.distanceBetween(point.translation, lastPose) + var index: Int = lastIndex + for (i in lastIndex..points.size - 1) { + val tempDistance: Double = Vector2.distanceBetween(point.translation, points.get(i).translation) + if (tempDistance < minDistance) { + index = i + minDistance = tempDistance + } + } + return index + } + + override fun toString(): String { + val buffer: StringBuilder = StringBuilder() + for (i in 0..points.size - 1) { + buffer.append(points.get(i).toString()) + buffer.append(System.lineSeparator()) + } + return buffer.toString() + } + + override fun toCSV(): String { + val buffer: StringBuilder = StringBuilder() + for (i in 0..points.size - 1) { + buffer.append(points.get(i).pose.toCSV()) + buffer.append(", ") + buffer.append(velocities.get(i)) + buffer.append(System.lineSeparator()) + } + return buffer.toString() + } +} diff --git a/src/main/kotlin/org/team5499/monkeyLib/path/PathFollower.kt b/src/main/kotlin/org/team5419/fault/path/PathFollower.kt similarity index 94% rename from src/main/kotlin/org/team5499/monkeyLib/path/PathFollower.kt rename to src/main/kotlin/org/team5419/fault/path/PathFollower.kt index 9cf1795..59a2c2c 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/path/PathFollower.kt +++ b/src/main/kotlin/org/team5419/fault/path/PathFollower.kt @@ -1,139 +1,139 @@ -package org.team5499.monkeyLib.path - -import org.team5499.monkeyLib.math.Epsilon - -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Pose2d - -/** -* class that contains methods to follow a list of coordinates -* used during autonomous -* @property path the path the follower will follow -*/ -@SuppressWarnings("MagicNumber") -class PathFollower(path: Path, trackWidth: Double, initLookaheadDistance: Double) { - - private val mPath: Path - private var mLastClosestPointIndex: Int - - private val mTrackWidth: Double - public var lookaheadDistance: Double - - init { - mPath = path - mLastClosestPointIndex = 0 - - mTrackWidth = trackWidth - lookaheadDistance = initLookaheadDistance - } - - /** - * Function used by path follower to be run in every periodic tick to calculate - * velocities based on current path, robot location, robot angle, and target velocities - * @param currentRobotPose the current position and rotation of the drivetrain - * @return velocities for the left and right sides of the drivetrain - */ - fun update(currentRobotPose: Pose2d): PathFollowerOutput { - var robotAngle = currentRobotPose.rotation.radians - if (robotAngle == 0.0) robotAngle = Epsilon.EPSILON - val lookahead = calculateLookahead(currentRobotPose) - val curvature = calculateCurvature(currentRobotPose, lookahead, robotAngle) - val velocityTarget = mPath.getVelocity(mLastClosestPointIndex) - val negate = if (mPath.reversed) -1.0 else 1.0 - val leftVelo = negate * (velocityTarget * (2.0 + (curvature * mTrackWidth)) / 2.0) - val rightVelo = negate * (velocityTarget * (2.0 - (curvature * mTrackWidth)) / 2.0) - return PathFollowerOutput(leftVelo, rightVelo) - } - - /** - * Calcuates the lookahead point based on robot position and desired lookahead distance. - * Algorithm basically creates a circle around the robot with radius = lookahead distance - * then finds the intersection point with the path line. It then chooses the most suitable point. - * If it doesnt find a lookahead point, it sets the lookahead to the last point in the path - * @param robotPose current pose of the robot - * @return calculated lookahead of the robot as a Vector2 - */ - @Suppress("ComplexMethod") - private fun calculateLookahead(robotPose: Pose2d): Vector2 { - mLastClosestPointIndex = mPath.findClosestPointIndex(robotPose, mLastClosestPointIndex) - var lookahead: Vector2? = null - for (i in mLastClosestPointIndex..mPath.pathLength - 2) { - val begin = mPath.getPose(i) - val end = mPath.getPose(i + 1) - val d = end.translation - begin.translation - val f = begin.translation - robotPose.translation - - val a = d.dot(d) - val b = 2.0 * f.dot(d) - val c = f.dot(f) - Math.pow(lookaheadDistance, 2.0) - var dis = (b * b) - (4.0 * a * c) - if (dis < 0.0) { - continue - } else { - dis = Math.sqrt(dis) - val t1 = (-b - dis) / (2.0 * a) - val t2 = (-b + dis) / (2.0 * a) - if (t1 >= 0 && t1 <= 1) { - val temp: Vector2 = d * t1 - lookahead = begin.translation + temp - break - } else if (t2 >= 0 && t2 <= 1) { - val temp = d * t2 - lookahead = begin.translation + temp - break - } - } - } - if (lookahead == null) { - lookahead = mPath.endPose.translation - } else { - val distanceToEnd = robotPose.translation.distanceTo(mPath.endPose.translation) - if (distanceToEnd < lookaheadDistance) { - lookahead = mPath.endPose.translation - } - } - return lookahead - } - - /** - * calculates curvature between robot point and lookahead point - * @param robotPose current pose of the robot - * @param lookahead lookahead point - * @param robotAngle the modified robot angle to prevent undefined curvatures - * @return the curvature of the arc that the robot must follow to reach the lookahead point - */ - private fun calculateCurvature(robotPose: Pose2d, lookahead: Vector2, robotAngle: Double): Double { - val a = (1 / Math.tan(robotAngle)) - val b = -1 - val c = -(1 / Math.tan(robotAngle)) * robotPose.translation.y + robotPose.translation.x - val x = Math.abs(a * lookahead.y + b * lookahead.x + c) / ((Math.sqrt(a * a + b * b))) - val curvature = (2.0 * x) / (Math.pow(lookaheadDistance, 2.0)) - val side = Math.signum( - Math.sin(robotAngle) * (lookahead.x - robotPose.translation.x) - - Math.cos(robotAngle) * (lookahead.y - robotPose.translation.y) - ) - return curvature * side - } - /** - * @param robotPos position of the robot - * @return whether the robot is done with the the designated path based on robot location - */ - fun doneWithPath(robotPose: Pose2d): Boolean { - val distance = robotPose.translation.distanceTo(mPath.endPose.translation) - val done = distance < PATH_EXTENSION_LENGTH - return done - } - - /** - * resets follower to first point - */ - fun reset() { - mLastClosestPointIndex = 0 - } - - /** - * @property leftVelocity target velocity of the right side of the drivetrain - * @property rightVelocity target velocity of the right side of the drivetrain - */ - public data class PathFollowerOutput(val leftVelocity: Double = 0.0, val rightVelocity: Double = 0.0) -} +package org.team5419.fault.path + +import org.team5419.fault.math.Epsilon + +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Pose2d + +/** +* class that contains methods to follow a list of coordinates +* used during autonomous +* @property path the path the follower will follow +*/ +@SuppressWarnings("MagicNumber") +class PathFollower(path: Path, trackWidth: Double, initLookaheadDistance: Double) { + + private val mPath: Path + private var mLastClosestPointIndex: Int + + private val mTrackWidth: Double + public var lookaheadDistance: Double + + init { + mPath = path + mLastClosestPointIndex = 0 + + mTrackWidth = trackWidth + lookaheadDistance = initLookaheadDistance + } + + /** + * Function used by path follower to be run in every periodic tick to calculate + * velocities based on current path, robot location, robot angle, and target velocities + * @param currentRobotPose the current position and rotation of the drivetrain + * @return velocities for the left and right sides of the drivetrain + */ + fun update(currentRobotPose: Pose2d): PathFollowerOutput { + var robotAngle = currentRobotPose.rotation.radians + if (robotAngle == 0.0) robotAngle = Epsilon.EPSILON + val lookahead = calculateLookahead(currentRobotPose) + val curvature = calculateCurvature(currentRobotPose, lookahead, robotAngle) + val velocityTarget = mPath.getVelocity(mLastClosestPointIndex) + val negate = if (mPath.reversed) -1.0 else 1.0 + val leftVelo = negate * (velocityTarget * (2.0 + (curvature * mTrackWidth)) / 2.0) + val rightVelo = negate * (velocityTarget * (2.0 - (curvature * mTrackWidth)) / 2.0) + return PathFollowerOutput(leftVelo, rightVelo) + } + + /** + * Calcuates the lookahead point based on robot position and desired lookahead distance. + * Algorithm basically creates a circle around the robot with radius = lookahead distance + * then finds the intersection point with the path line. It then chooses the most suitable point. + * If it doesnt find a lookahead point, it sets the lookahead to the last point in the path + * @param robotPose current pose of the robot + * @return calculated lookahead of the robot as a Vector2 + */ + @Suppress("ComplexMethod") + private fun calculateLookahead(robotPose: Pose2d): Vector2 { + mLastClosestPointIndex = mPath.findClosestPointIndex(robotPose, mLastClosestPointIndex) + var lookahead: Vector2? = null + for (i in mLastClosestPointIndex..mPath.pathLength - 2) { + val begin = mPath.getPose(i) + val end = mPath.getPose(i + 1) + val d = end.translation - begin.translation + val f = begin.translation - robotPose.translation + + val a = d.dot(d) + val b = 2.0 * f.dot(d) + val c = f.dot(f) - Math.pow(lookaheadDistance, 2.0) + var dis = (b * b) - (4.0 * a * c) + if (dis < 0.0) { + continue + } else { + dis = Math.sqrt(dis) + val t1 = (-b - dis) / (2.0 * a) + val t2 = (-b + dis) / (2.0 * a) + if (t1 >= 0 && t1 <= 1) { + val temp: Vector2 = d * t1 + lookahead = begin.translation + temp + break + } else if (t2 >= 0 && t2 <= 1) { + val temp = d * t2 + lookahead = begin.translation + temp + break + } + } + } + if (lookahead == null) { + lookahead = mPath.endPose.translation + } else { + val distanceToEnd = robotPose.translation.distanceTo(mPath.endPose.translation) + if (distanceToEnd < lookaheadDistance) { + lookahead = mPath.endPose.translation + } + } + return lookahead + } + + /** + * calculates curvature between robot point and lookahead point + * @param robotPose current pose of the robot + * @param lookahead lookahead point + * @param robotAngle the modified robot angle to prevent undefined curvatures + * @return the curvature of the arc that the robot must follow to reach the lookahead point + */ + private fun calculateCurvature(robotPose: Pose2d, lookahead: Vector2, robotAngle: Double): Double { + val a = (1 / Math.tan(robotAngle)) + val b = -1 + val c = -(1 / Math.tan(robotAngle)) * robotPose.translation.y + robotPose.translation.x + val x = Math.abs(a * lookahead.y + b * lookahead.x + c) / ((Math.sqrt(a * a + b * b))) + val curvature = (2.0 * x) / (Math.pow(lookaheadDistance, 2.0)) + val side = Math.signum( + Math.sin(robotAngle) * (lookahead.x - robotPose.translation.x) - + Math.cos(robotAngle) * (lookahead.y - robotPose.translation.y) + ) + return curvature * side + } + /** + * @param robotPos position of the robot + * @return whether the robot is done with the the designated path based on robot location + */ + fun doneWithPath(robotPose: Pose2d): Boolean { + val distance = robotPose.translation.distanceTo(mPath.endPose.translation) + val done = distance < PATH_EXTENSION_LENGTH + return done + } + + /** + * resets follower to first point + */ + fun reset() { + mLastClosestPointIndex = 0 + } + + /** + * @property leftVelocity target velocity of the right side of the drivetrain + * @property rightVelocity target velocity of the right side of the drivetrain + */ + public data class PathFollowerOutput(val leftVelocity: Double = 0.0, val rightVelocity: Double = 0.0) +} diff --git a/src/main/kotlin/org/team5499/monkeyLib/path/PathGenerator.kt b/src/main/kotlin/org/team5419/fault/path/PathGenerator.kt similarity index 94% rename from src/main/kotlin/org/team5499/monkeyLib/path/PathGenerator.kt rename to src/main/kotlin/org/team5419/fault/path/PathGenerator.kt index a81d52d..02d6aef 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/path/PathGenerator.kt +++ b/src/main/kotlin/org/team5419/fault/path/PathGenerator.kt @@ -1,10 +1,10 @@ -package org.team5499.monkeyLib.path +package org.team5419.fault.path -import org.team5499.monkeyLib.math.splines.QuinticHermiteSpline -import org.team5499.monkeyLib.math.splines.SplineGenerator -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature +import org.team5419.fault.math.splines.QuinticHermiteSpline +import org.team5419.fault.math.splines.SplineGenerator +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2dWithCurvature // length added to end of path to allow easier path following const val PATH_EXTENSION_LENGTH = 12.0 // inches diff --git a/src/main/kotlin/org/team5499/monkeyLib/path/PathUtils.kt b/src/main/kotlin/org/team5419/fault/path/PathUtils.kt similarity index 92% rename from src/main/kotlin/org/team5499/monkeyLib/path/PathUtils.kt rename to src/main/kotlin/org/team5419/fault/path/PathUtils.kt index f7c12d2..ade3bbe 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/path/PathUtils.kt +++ b/src/main/kotlin/org/team5419/fault/path/PathUtils.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.path +package org.team5419.fault.path typealias PathSet = MutableList diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/CSVWritable.kt b/src/main/kotlin/org/team5419/fault/util/CSVWritable.kt similarity index 61% rename from src/main/kotlin/org/team5499/monkeyLib/util/CSVWritable.kt rename to src/main/kotlin/org/team5419/fault/util/CSVWritable.kt index e2c2789..e06ff2d 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/CSVWritable.kt +++ b/src/main/kotlin/org/team5419/fault/util/CSVWritable.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util interface CSVWritable { public fun toCSV(): String diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/CircularBuffer.kt b/src/main/kotlin/org/team5419/fault/util/CircularBuffer.kt similarity index 94% rename from src/main/kotlin/org/team5499/monkeyLib/util/CircularBuffer.kt rename to src/main/kotlin/org/team5419/fault/util/CircularBuffer.kt index f4cd0d6..9916e87 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/CircularBuffer.kt +++ b/src/main/kotlin/org/team5419/fault/util/CircularBuffer.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util public open class CircularBuffer(maxSize: Int) { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/CircularDoubleBuffer.kt b/src/main/kotlin/org/team5419/fault/util/CircularDoubleBuffer.kt similarity index 91% rename from src/main/kotlin/org/team5499/monkeyLib/util/CircularDoubleBuffer.kt rename to src/main/kotlin/org/team5419/fault/util/CircularDoubleBuffer.kt index c5a244d..b4f77b0 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/CircularDoubleBuffer.kt +++ b/src/main/kotlin/org/team5419/fault/util/CircularDoubleBuffer.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util public class CircularDoubleBuffer(maxSize: Int) : CircularBuffer(maxSize) { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/Interpolable.kt b/src/main/kotlin/org/team5419/fault/util/Interpolable.kt similarity index 69% rename from src/main/kotlin/org/team5499/monkeyLib/util/Interpolable.kt rename to src/main/kotlin/org/team5419/fault/util/Interpolable.kt index 5ea6f7f..54e2f75 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/Interpolable.kt +++ b/src/main/kotlin/org/team5419/fault/util/Interpolable.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util interface Interpolable { public fun interpolate(other: T, x: Double): T diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/Oof.kt b/src/main/kotlin/org/team5419/fault/util/Oof.kt similarity index 78% rename from src/main/kotlin/org/team5499/monkeyLib/util/Oof.kt rename to src/main/kotlin/org/team5419/fault/util/Oof.kt index 8954310..5d9e695 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/Oof.kt +++ b/src/main/kotlin/org/team5419/fault/util/Oof.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util /* Thanks 1323! diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/Utils.kt b/src/main/kotlin/org/team5419/fault/util/Utils.kt similarity index 99% rename from src/main/kotlin/org/team5499/monkeyLib/util/Utils.kt rename to src/main/kotlin/org/team5419/fault/util/Utils.kt index f522bcb..f7de832 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/Utils.kt +++ b/src/main/kotlin/org/team5419/fault/util/Utils.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util +package org.team5419.fault.util @SuppressWarnings("MagicNumber") object Utils { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/loops/ILooper.kt b/src/main/kotlin/org/team5419/fault/util/loops/ILooper.kt similarity index 58% rename from src/main/kotlin/org/team5499/monkeyLib/util/loops/ILooper.kt rename to src/main/kotlin/org/team5419/fault/util/loops/ILooper.kt index fdc75ed..8744c69 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/loops/ILooper.kt +++ b/src/main/kotlin/org/team5419/fault/util/loops/ILooper.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.loops +package org.team5419.fault.util.loops public interface ILooper { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/loops/Loop.kt b/src/main/kotlin/org/team5419/fault/util/loops/Loop.kt similarity index 78% rename from src/main/kotlin/org/team5499/monkeyLib/util/loops/Loop.kt rename to src/main/kotlin/org/team5419/fault/util/loops/Loop.kt index 5be980c..16d779c 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/loops/Loop.kt +++ b/src/main/kotlin/org/team5419/fault/util/loops/Loop.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.loops +package org.team5419.fault.util.loops public interface Loop { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/loops/Looper.kt b/src/main/kotlin/org/team5419/fault/util/loops/Looper.kt similarity index 97% rename from src/main/kotlin/org/team5499/monkeyLib/util/loops/Looper.kt rename to src/main/kotlin/org/team5419/fault/util/loops/Looper.kt index 8e0cbe0..e3cab32 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/loops/Looper.kt +++ b/src/main/kotlin/org/team5419/fault/util/loops/Looper.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.loops +package org.team5419.fault.util.loops import edu.wpi.first.wpilibj.Notifier import edu.wpi.first.wpilibj.Timer diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/time/ITimer.kt b/src/main/kotlin/org/team5419/fault/util/time/ITimer.kt similarity index 91% rename from src/main/kotlin/org/team5499/monkeyLib/util/time/ITimer.kt rename to src/main/kotlin/org/team5419/fault/util/time/ITimer.kt index 2446377..ebf52e0 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/time/ITimer.kt +++ b/src/main/kotlin/org/team5419/fault/util/time/ITimer.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.time +package org.team5419.fault.util.time /** * Timer abstraction layer to allow unit testing diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/time/SystemTimer.kt b/src/main/kotlin/org/team5419/fault/util/time/SystemTimer.kt similarity index 96% rename from src/main/kotlin/org/team5499/monkeyLib/util/time/SystemTimer.kt rename to src/main/kotlin/org/team5419/fault/util/time/SystemTimer.kt index 2bada95..694dee0 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/time/SystemTimer.kt +++ b/src/main/kotlin/org/team5419/fault/util/time/SystemTimer.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.time +package org.team5419.fault.util.time public class SystemTimer : ITimer { diff --git a/src/main/kotlin/org/team5499/monkeyLib/util/time/WPITimer.kt b/src/main/kotlin/org/team5419/fault/util/time/WPITimer.kt similarity index 89% rename from src/main/kotlin/org/team5499/monkeyLib/util/time/WPITimer.kt rename to src/main/kotlin/org/team5419/fault/util/time/WPITimer.kt index 5717678..eed8353 100644 --- a/src/main/kotlin/org/team5499/monkeyLib/util/time/WPITimer.kt +++ b/src/main/kotlin/org/team5419/fault/util/time/WPITimer.kt @@ -1,4 +1,4 @@ -package org.team5499.monkeyLib.util.time +package org.team5419.fault.util.time import edu.wpi.first.wpilibj.Timer diff --git a/src/main/kotlin/org/team5499/monkeyLib/auto/NothingAction.kt b/src/main/kotlin/org/team5499/monkeyLib/auto/NothingAction.kt deleted file mode 100644 index 16be064..0000000 --- a/src/main/kotlin/org/team5499/monkeyLib/auto/NothingAction.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.team5499.monkeyLib.auto - -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.WPITimer - -public class NothingAction(timeout: Double, timer: ITimer = WPITimer()) : Action(timeout, timer) diff --git a/src/main/kotlin/org/team5499/monkeyLib/logging/Logger.kt b/src/main/kotlin/org/team5499/monkeyLib/logging/Logger.kt deleted file mode 100644 index 1947d0c..0000000 --- a/src/main/kotlin/org/team5499/monkeyLib/logging/Logger.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.team5499.monkeyLib.logging - -// main logging class diff --git a/src/main/kotlin/org/team5499/monkeyLib/math/UnitConversion.kt b/src/main/kotlin/org/team5499/monkeyLib/math/UnitConversion.kt deleted file mode 100644 index 209a32c..0000000 --- a/src/main/kotlin/org/team5499/monkeyLib/math/UnitConversion.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.team5499.monkeyLib.math - -// public object UnitConversion { -// // functions that convert between units -// } diff --git a/src/test/kotlin/tests/input/DriveHelperTest.kt b/src/test/kotlin/tests/input/DriveHelperTest.kt index d0c1824..24ab30e 100644 --- a/src/test/kotlin/tests/input/DriveHelperTest.kt +++ b/src/test/kotlin/tests/input/DriveHelperTest.kt @@ -1,11 +1,11 @@ package tests.input -import org.team5499.monkeyLib.input.DriveSignal -import org.team5499.monkeyLib.input.TankDriveHelper -import org.team5499.monkeyLib.input.SpaceDriveHelper -import org.team5499.monkeyLib.input.CheesyDriveHelper +import org.team5419.fault.input.DriveSignal +import org.team5419.fault.input.TankDriveHelper +import org.team5419.fault.input.SpaceDriveHelper +import org.team5419.fault.input.CheesyDriveHelper -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon import org.junit.Test import org.junit.Assert.assertEquals diff --git a/src/test/kotlin/tests/math/EpsilonTest.kt b/src/test/kotlin/tests/math/EpsilonTest.kt index 137a89b..111b27a 100644 --- a/src/test/kotlin/tests/math/EpsilonTest.kt +++ b/src/test/kotlin/tests/math/EpsilonTest.kt @@ -1,6 +1,6 @@ package tests.math -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon import org.junit.Test import org.junit.Assert.assertTrue diff --git a/src/test/kotlin/tests/math/GeometryTests.kt b/src/test/kotlin/tests/math/GeometryTests.kt index 69cadea..678426d 100644 --- a/src/test/kotlin/tests/math/GeometryTests.kt +++ b/src/test/kotlin/tests/math/GeometryTests.kt @@ -1,11 +1,11 @@ package tests.math -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Twist2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Twist2d -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon import org.junit.Test import org.junit.Assert.assertEquals diff --git a/src/test/kotlin/tests/math/UnitConverterTests.kt b/src/test/kotlin/tests/math/UnitConverterTests.kt new file mode 100644 index 0000000..da43458 --- /dev/null +++ b/src/test/kotlin/tests/math/UnitConverterTests.kt @@ -0,0 +1,29 @@ +package tests.math + +import org.junit.Test +import org.junit.Assert.assertTrue + +import org.team5419.fault.math.units.from +import org.team5419.fault.math.units.INCHS +import org.team5419.fault.math.units.CENTIMETERS +import org.team5419.fault.math.units.MILES +import org.team5419.fault.math.units.HOURS +import org.team5419.fault.math.units.FEET +import org.team5419.fault.math.units.SECONDS + +public class UnitConverterTests { + @Test + fun testInchToInch() { + assertTrue(1.0 from INCHS to INCHS == 1.0) + } + + @Test + fun testCentimeterToInch() { + assertTrue(254.0 from CENTIMETERS to INCHS == 100.0) + } + + @Test + fun testMilesPerHouresToFeetPerSeconds() { + assertTrue(15.0 from MILES / HOURS to FEET / SECONDS == 22.0) + } +} diff --git a/src/test/kotlin/tests/math/physics/DCMotorTransmissionTest.kt b/src/test/kotlin/tests/math/physics/DCMotorTransmissionTest.kt index e62edc3..f7f6268 100644 --- a/src/test/kotlin/tests/math/physics/DCMotorTransmissionTest.kt +++ b/src/test/kotlin/tests/math/physics/DCMotorTransmissionTest.kt @@ -3,7 +3,7 @@ package tests.math.physics import org.junit.Test import org.junit.Assert.assertEquals -import org.team5499.monkeyLib.math.physics.DCMotorTransmission +import org.team5419.fault.math.physics.DCMotorTransmission class DCMotorTransmissionTest { val motor = DCMotorTransmission(1000.0, 0.5, 1.0, 120.0) diff --git a/src/test/kotlin/tests/math/splines/QuinticHermiteOptimizerTest.kt b/src/test/kotlin/tests/math/splines/QuinticHermiteOptimizerTest.kt index aea1573..c635d54 100644 --- a/src/test/kotlin/tests/math/splines/QuinticHermiteOptimizerTest.kt +++ b/src/test/kotlin/tests/math/splines/QuinticHermiteOptimizerTest.kt @@ -4,11 +4,11 @@ import org.junit.Test import org.junit.Assert.assertTrue import org.junit.Assert.assertEquals -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d -import org.team5499.monkeyLib.math.splines.QuinticHermiteSpline +import org.team5419.fault.math.splines.QuinticHermiteSpline class QuinticHermiteOptimizerTest { diff --git a/src/test/kotlin/tests/math/splines/SplineGeneratorTest.kt b/src/test/kotlin/tests/math/splines/SplineGeneratorTest.kt index 25ad71e..deb0194 100644 --- a/src/test/kotlin/tests/math/splines/SplineGeneratorTest.kt +++ b/src/test/kotlin/tests/math/splines/SplineGeneratorTest.kt @@ -3,15 +3,15 @@ package tests.math.splines import org.junit.Test import org.junit.Assert.assertEquals -import org.team5499.monkeyLib.math.Epsilon +import org.team5419.fault.math.Epsilon -import org.team5499.monkeyLib.math.geometry.Vector2 -import org.team5499.monkeyLib.math.geometry.Rotation2d -import org.team5499.monkeyLib.math.geometry.Pose2d -import org.team5499.monkeyLib.math.geometry.Pose2dWithCurvature +import org.team5419.fault.math.geometry.Vector2 +import org.team5419.fault.math.geometry.Rotation2d +import org.team5419.fault.math.geometry.Pose2d +import org.team5419.fault.math.geometry.Pose2dWithCurvature -import org.team5499.monkeyLib.math.splines.SplineGenerator -import org.team5499.monkeyLib.math.splines.QuinticHermiteSpline +import org.team5419.fault.math.splines.SplineGenerator +import org.team5419.fault.math.splines.QuinticHermiteSpline class SplineGeneratorTest { diff --git a/src/test/kotlin/tests/util/TimerTest.kt b/src/test/kotlin/tests/util/TimerTest.kt index e3dd49c..757a09a 100644 --- a/src/test/kotlin/tests/util/TimerTest.kt +++ b/src/test/kotlin/tests/util/TimerTest.kt @@ -3,8 +3,8 @@ package tests.utils import org.junit.Test import org.junit.Assert.assertEquals -import org.team5499.monkeyLib.util.time.ITimer -import org.team5499.monkeyLib.util.time.SystemTimer +import org.team5419.fault.util.time.ITimer +import org.team5419.fault.util.time.SystemTimer public class TimerTest { diff --git a/src/test/kotlin/tests/util/UtilTest.kt b/src/test/kotlin/tests/util/UtilTest.kt index 2352dd6..b3dff42 100644 --- a/src/test/kotlin/tests/util/UtilTest.kt +++ b/src/test/kotlin/tests/util/UtilTest.kt @@ -1,6 +1,6 @@ package tests.utils -import org.team5499.monkeyLib.util.Utils +import org.team5419.fault.util.Utils import org.junit.Test import org.junit.Assert.assertTrue