Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
changeset for 2019.9.0 (#16)
Browse files Browse the repository at this point in the history
* fix a whole bunch of bugs in the quick turn generator

* add equals() and hashCode() to TrajectoryState

* add path planner 2 project

* add status bars

* add some buttons

* add State.kt

* commit

* revert to Kotlin 1.3.50 to fix extension functions

* add spline drawing

* add arrow drawing

* add good path

* add simulation support

* add graphing support

* refactor

* add sampling function with reverse

* add save configuration

* add angular values to TrajectoryState inversion

* remove Path2D and move extension functions

* move dt calculations into accumulativePass

* add docs and remove scaling from Pose2D and Rotation2D

* convert defaultstate to metres

* remove save config and add Klaxon

* update default.json

* add a part of the fx-utils library

* add selection calculations

* add ControlPoint.kt and basic selection

* add license

* add hostServices reference

* add java generator

* add new commands

* add transforms and fix selection logic

* remake arrow math

* add PathWizard

* add wpi equality test

* add ComputeTime

* implement equality tests and improve parameterizer
  • Loading branch information
yuliu2016 authored Dec 31, 2019
1 parent 21f5b88 commit d65cc67
Show file tree
Hide file tree
Showing 63 changed files with 2,258 additions and 326 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2019 Team 865 WARP7

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Copy this code into `Commons.json` in the `vendordeps` folder of a robot project
{
"fileName": "Commons.json",
"name": "FRC-Commons-Kotlin",
"version": "2019.8.0",
"version": "2019.9.0",
"uuid": "ab676553-b602-441f-a38d-f1296eff6538",
"mavenUrls": [
"https://jitpack.io"
Expand All @@ -25,7 +25,7 @@ Copy this code into `Commons.json` in the `vendordeps` folder of a robot project
{
"groupId": "com.github.Team865",
"artifactId": "FRC-Commons-Kotlin",
"version": "2019.8.0"
"version": "2019.9.0"
}
],
"jniDependencies": [],
Expand All @@ -45,6 +45,6 @@ repositories {
}

dependencies {
implementation(group="com.github.Team865", name="FRC-Commons-Kotlin", version="2019.8.0")
implementation(group="com.github.Team865", name="FRC-Commons-Kotlin", version="2019.9.0")
}
```
27 changes: 16 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
@file:Suppress("UnusedImport", "SpellCheckingInspection")

import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.javamodularity.moduleplugin.extensions.TestModuleOptions
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
kotlin("jvm") version "1.3.60"
kotlin("jvm") version "1.3.50"
`maven-publish`
id("org.jetbrains.dokka") version "0.10.0"
id("org.javamodularity.moduleplugin") version "1.6.0"
id("edu.wpi.first.GradleRIO") version "2020.1.1-beta-4"
id("org.openjfx.javafxplugin") version "0.0.9-SNAPSHOT" apply false
id("org.beryx.jlink") version "2.16.4" apply false
}

repositories {
Expand All @@ -17,7 +21,7 @@ repositories {
}

group = "ca.warp7.frc"
version = "2019.8.0"
version = "2019.9.0"

tasks.withType<KotlinCompile> {
kotlinOptions {
Expand All @@ -30,6 +34,9 @@ tasks.withType<KotlinCompile> {
}

tasks.withType<Test> {
extensions.configure(TestModuleOptions::class.java) {
runOnClasspath = true
}
useJUnitPlatform {
}
}
Expand All @@ -39,18 +46,16 @@ dependencies {

testImplementation(kotlin("test"))
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter-api", version = "5.5.1")
testImplementation("edu.wpi.first.wpilibj:wpilibj-java:${wpi.wpilibVersion}")
testImplementation("edu.wpi.first.wpiutil:wpiutil-java:${wpi.wpilibVersion}")
testImplementation("org.ejml:ejml-simple:${wpi.ejmlVersion}")
testImplementation("com.fasterxml.jackson.core:jackson-annotations:${wpi.jacksonVersion}")
testImplementation("com.fasterxml.jackson.core:jackson-core:${wpi.jacksonVersion}")
testImplementation("com.fasterxml.jackson.core:jackson-databind:${wpi.jacksonVersion}")
testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = "5.5.1")
testRuntimeOnly(group = "org.junit.platform", name = "junit-platform-launcher", version = "1.5.1")
}


tasks.jar {
manifest {
attributes("Automatic-Module-Name" to "ca.warp_seven.frc")
}
}


val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
Expand Down
43 changes: 43 additions & 0 deletions path-planner-2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
kotlin("jvm")
id("application")
id("org.javamodularity.moduleplugin")
id("org.openjfx.javafxplugin")
id ("org.beryx.jlink")
// id("edu.wpi.first.GradleRIO")
}

repositories {
mavenCentral()
jcenter()
}

buildDir = File(rootProject.projectDir, "build/" + project.name)

application {
mainClassName = "path.planner/ca.warp7.planner2.MainKt"
}

javafx {
modules("javafx.controls")
}

jlink {
options.addAll("--strip-debug", "--no-header-files",
"--no-man-pages", "--strip-native-commands")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
kotlinOptions.jvmTarget = "11"
}
}

dependencies {
implementation(rootProject)
implementation("com.beust:klaxon:5.2")
implementation(kotlin("stdlib"))
}
7 changes: 7 additions & 0 deletions path-planner-2/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module path.planner {
requires kotlin.stdlib;
requires javafx.controls;
requires frc.commons.kotlin;
requires klaxon;
exports ca.warp7.planner2;
}
113 changes: 113 additions & 0 deletions path-planner-2/src/main/kotlin/ca/warp7/planner2/Configuration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package ca.warp7.planner2

import javafx.scene.control.*
import javafx.scene.image.Image
import javafx.scene.layout.GridPane
import javafx.stage.FileChooser
import javafx.stage.Window

/**
* The part of the State that the user sets in a
* dialog box
*/
class Configuration {
var wheelbaseRadius = 0.0
var maxVelocity = 0.0
var maxAcceleration = 0.0
var maxCentripetalAcceleration = 0.0
var maxJerk = Double.POSITIVE_INFINITY
var robotWidth = 0.0
var robotLength = 0.0
var background: Image? = null

private fun validate(str: String, old: Double): Double {
return try {
str.trim().toDouble()
} catch (e: NumberFormatException) {
val dialog = Dialog<ButtonType>()
dialog.title = "Settings Error"
dialog.dialogPane.buttonTypes.add(ButtonType.OK)
dialog.dialogPane.contentText = "Cannot parse $str as a number, reverting to $old"
dialog.showAndWait()
old
}
}

fun showSettings(owner: Window) {
val dialog = Dialog<ButtonType>()
dialog.title = "Configure Path"
dialog.initOwner(owner)
dialog.dialogPane.buttonTypes.addAll(ButtonType.CANCEL, ButtonType.OK)


val wheelbase = TextField(wheelbaseRadius.toString())
val maxVel = TextField(maxVelocity.toString())
val maxAcc = TextField(maxAcceleration.toString())
val maxCA = TextField(maxCentripetalAcceleration.toString())
val maxJ = TextField(maxJerk.toString())
val botWidth = TextField(robotWidth.toString())
val botLength = TextField(robotLength.toString())

val choose = Button("Choose")

choose.setOnAction {
val chooser = FileChooser()
chooser.title = "Choose Half Field Background"
chooser.extensionFilters.add(FileChooser.ExtensionFilter("PNG", "*.png"))
val f = chooser.showOpenDialog(null)

if (f != null && f.name.endsWith("png")) {
try {
val image = Image(f.inputStream())
background = image
choose.text = f.name
} catch (e: Exception) {
}
}
}

val f2020 = Button("Load 2020 Blue")
val f20202 = Button("Load 2020 Red")

dialog.dialogPane.content = GridPane().apply {
hgap = 8.0
vgap = 8.0
add(Label("Effective Wheelbase Radius"), 0, 0)
add(wheelbase, 1, 0)

add(Label("Max Velocity"), 0, 1)
add(maxVel, 1, 1)

add(Label("Max Acceleration"), 0, 2)
add(maxAcc, 1, 2)

add(Label("Max Centripetal Acceleration"), 0, 3)
add(maxCA, 1, 3)

add(Label("Max Jerk"), 0, 4)
add(maxJ, 1, 4)

add(Label("Robot Width (for graphics)"), 0, 5)
add(botWidth, 1, 5)

add(Label("Robot Length (for graphics)"), 0, 6)
add(botLength, 1, 6)

add(Label("Half Field Background"), 2, 0)
add(choose, 3, 0)

add(f2020, 3, 1)
add(f20202, 3, 2)
}

dialog.showAndWait()

wheelbaseRadius = validate(wheelbase.text, wheelbaseRadius)
maxVelocity = validate(maxVel.text, maxVelocity)
maxAcceleration = validate(maxAcc.text, maxAcceleration)
maxCentripetalAcceleration = validate(maxCA.text, maxCentripetalAcceleration)
maxJerk = validate(maxJ.text, maxJerk)
robotWidth = validate(botWidth.text, robotWidth)
robotLength = validate(botLength.text, robotLength)
}
}
19 changes: 19 additions & 0 deletions path-planner-2/src/main/kotlin/ca/warp7/planner2/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ca.warp7.planner2

object Constants {
const val kFieldSize = 8.2296 // metres; equals 27 ft

const val kHalfFieldSize = kFieldSize / 2

const val kTranslationStep = 0.1 // m
const val kRotationStep = 1.0 // deg


const val kControlPointCircleSize = 0.2 // m

const val kArrowLength = 0.5 // m

const val k60DegreesRatio = 0.5773502691896258 // 1/sqrt(3)

const val kArrowTipLength = 0.15
}
28 changes: 28 additions & 0 deletions path-planner-2/src/main/kotlin/ca/warp7/planner2/ControlPoint.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ca.warp7.planner2

import ca.warp7.frc.geometry.Pose2D

/**
* Bridge between user and the segment interface
*/
class ControlPoint(
val segment: Segment,
var pose: Pose2D,
val indexInState: Int,
val indexInSegment: Int
) {
var isSelected = false

override fun equals(other: Any?): Boolean {
if (other is ControlPoint) return other.pose === pose && other.segment === segment &&
other.indexInState == indexInState && other.indexInSegment == indexInSegment
return false
}

override fun hashCode(): Int {
var result = pose.hashCode()
result = 31 * result + indexInState
result = 31 * result + indexInSegment
return result
}
}
Loading

0 comments on commit d65cc67

Please sign in to comment.