This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
63 changed files
with
2,258 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
113
path-planner-2/src/main/kotlin/ca/warp7/planner2/Configuration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
path-planner-2/src/main/kotlin/ca/warp7/planner2/Constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
path-planner-2/src/main/kotlin/ca/warp7/planner2/ControlPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.