Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stall safety #33

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
41671b2
remove outdated comments from Button Mappings
kunalsheth Mar 4, 2018
b3804e5
add StallChecker
kunalsheth Mar 5, 2018
c6ccaf6
add stall check params to drivetrain props
kunalsheth Mar 5, 2018
3662e15
add stall checks to `DrivetrainComponent`
kunalsheth Mar 5, 2018
189b6f8
make stall checker generic
kunalsheth Mar 5, 2018
4b9a7ac
make drivetrain use generic stall checker
kunalsheth Mar 5, 2018
37d654e
add stall check to cube lift
kunalsheth Mar 5, 2018
c9c614a
run scalafmt
kunalsheth Mar 5, 2018
8feb871
add missing params to ConfigGenerator
kunalsheth Mar 5, 2018
d1379be
run scalafmt
kunalsheth Mar 5, 2018
f51b630
add missing params to robot-config.json
kunalsheth Mar 5, 2018
b0b6abf
stream all motor currents from drivetrain hardware
kunalsheth Mar 5, 2018
0ce9cba
log all drivetrain motors' current in funky dash
kunalsheth Mar 5, 2018
d419219
enable slew rate limiting on collector rollers
kunalsheth Mar 5, 2018
6c20f06
add parallel motor current draw alert to drivetrain
kunalsheth Mar 5, 2018
bfd9add
add missing params to robot-config.json and ConfigGenerator
kunalsheth Mar 5, 2018
a963723
run scalafmt
kunalsheth Mar 5, 2018
484f43a
remove parens from speed controller .get method call
kunalsheth Mar 5, 2018
89cb526
add missing params to robot configs
kunalsheth Mar 6, 2018
749cf90
only allow task abortion incase of stall during auto
kunalsheth Mar 8, 2018
94e334d
fix logic error on Drivetrain Stall check
kunalsheth Mar 18, 2018
430208a
rename follower ESCs in DrivetrainHardware
kunalsheth Mar 18, 2018
bd46eac
measure current using PDP instead of Victors & add fudging to drivetr…
kunalsheth Mar 20, 2018
8ddca5a
run scalafix and scalafmt
kunalsheth Apr 4, 2018
b67ba59
Merge branch 'master' into stall-safety
kunalsheth Apr 4, 2018
5d5cd30
add missing params to ConfigGenerator
kunalsheth Apr 4, 2018
49e7213
run scalafix/scalafmt
kunalsheth Apr 5, 2018
aef1aee
fix negative dc/velocity stall case
kunalsheth Apr 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ lazy val robot = crossProject(JVMPlatform, NativePlatform)
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test
)
.nativeSettings(
libraryDependencies += "com.lynbrookrobotics" %%% "wpilib-scala-native" % "0.1.2",
libraryDependencies += "com.lynbrookrobotics" %%% "ntcore-scala-native" % "0.1.2",
libraryDependencies += "com.lynbrookrobotics" %%% "phoenix-scala-native" % "0.1.2",
libraryDependencies += "com.lynbrookrobotics" %%% "wpilib-scala-native" % "0.1.3",
libraryDependencies += "com.lynbrookrobotics" %%% "ntcore-scala-native" % "0.1.3",
libraryDependencies += "com.lynbrookrobotics" %%% "phoenix-scala-native" % "0.1.3",
scalaVersion := "2.11.12",
scalacOptions ++= Seq("-target:jvm-1.8")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.lynbrookrobotics.eighteen

import argonaut.Argonaut._
import com.lynbrookrobotics.eighteen.driver.DriverConfig
import com.lynbrookrobotics.eighteen.drivetrain.{DrivetrainConfig, DrivetrainPorts, DrivetrainProperties}
import com.lynbrookrobotics.eighteen.lift.{CubeLiftConfig, CubeLiftPorts, CubeLiftProperties}
import com.lynbrookrobotics.potassium.control.PIDConfig
import squants.{Each, Percent}
import squants.motion.{DegreesPerSecond, FeetPerSecond, FeetPerSecondSquared}
import squants.space.{Degrees, Feet, Inches, Turns}
import squants.time.Seconds
import com.lynbrookrobotics.potassium.units.GenericValue._
import com.lynbrookrobotics.potassium.units._
import com.lynbrookrobotics.eighteen.lift.{CubeLiftConfig, CubeLiftPorts, CubeLiftProperties}
import squants.electro.{Amperes, Volts}
import argonaut.Argonaut._
import com.lynbrookrobotics.potassium.vision.VisionProperties
import squants.electro.{Amperes, Volts}
import squants.motion.{DegreesPerSecond, FeetPerSecond, FeetPerSecondSquared}
import squants.space.{Degrees, Feet, Inches, Turns}
import squants.time.Seconds
import squants.{Each, Percent}

object ConfigGenerator extends App {
println(
Expand All @@ -37,7 +37,11 @@ object ConfigGenerator extends App {
leftPort = 12,
rightPort = 11,
leftFollowerPort = 14,
rightFollowerPort = 13
rightFollowerPort = 13,
rightFollowerPdpPort = 3,
leftFollowerPdpPort = 1,
rightPdpPort = 2,
leftPdpPort = 0
),
props = DrivetrainProperties(
maxLeftVelocity = FeetPerSecond(18.8),
Expand Down Expand Up @@ -77,7 +81,12 @@ object ConfigGenerator extends App {
wheelOverEncoderGears = Ratio(
Turns(18),
Turns(74)
)
),
leftFudge = 1.0,
rightFudge = 1.0,
parallelMotorCurrentThreshold = Amperes(5),
deltaVelocityStallThreshold = FeetPerSecond(10),
stallTimeout = Seconds(3)
)
)
),
Expand All @@ -103,7 +112,9 @@ object ConfigGenerator extends App {
maxMotorOutput = Percent(20),
maxHeight = Inches(35),
minHeight = Inches(10),
twistyTotalRange = Feet(1)
twistyTotalRange = Feet(1),
maxCurrentDraw = Amperes(20),
stallTimeout = Seconds(3)
)
)
),
Expand Down
10 changes: 10 additions & 0 deletions practice-robot-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
0,
"Inches"
],
"maxCurrentDraw": [
20,
"Amperes"
],
"stallTimeout": [
3,
"Seconds"
],
"twistyTotalRange": [
0.75,
"Feet"
Expand Down Expand Up @@ -209,6 +217,8 @@
"Turns"
]
},
"leftFudge": 1.08,
"rightFudge": 1.08,
"rightVelocityGains": {
"kd": {
"den": [
Expand Down
30 changes: 28 additions & 2 deletions robot-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
"twistyTotalRange": [
0.75,
"Feet"
],
"maxCurrentDraw": [
20,
"Amperes"
],
"stallTimeout": [
3,
"Seconds"
]
},
"ports": {
Expand All @@ -114,7 +122,11 @@
"rightFollowerPort": 13,
"leftFollowerPort": 14,
"rightPort": 11,
"leftPort": 12
"leftPort": 12,
"rightFollowerPdpPort": 3,
"leftFollowerPdpPort": 1,
"rightPdpPort": 2,
"leftPdpPort": 0
},
"props": {
"maxLeftVelocity": [
Expand Down Expand Up @@ -169,6 +181,10 @@
35,
"Amperes"
],
"parallelMotorCurrentThreshold" : [
5,
"Amperes"
],
"maxRightVelocity": [
13.3,
"FeetPerSecond"
Expand All @@ -181,6 +197,8 @@
6,
"Inches"
],
"leftFudge": 1.08,
"rightFudge": 1.08,
"wheelOverEncoderGears": {
"num": [
18,
Expand Down Expand Up @@ -319,7 +337,15 @@
"Percent"
]
}
}
},
"deltaVelocityStallThreshold": [
10,
"FeetPerSecond"
],
"stallTimeout": [
3,
"Seconds"
]
}
},
"driver": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.lynbrookrobotics.eighteen

import com.lynbrookrobotics.potassium.streams._
import squants.time.Seconds
import squants.{Quantity, Time}

class SingleOutputChecker[T](hardwareName: String, get: => T) {
private var lastOutput: Option[T] = None

Expand All @@ -20,3 +24,14 @@ class SingleOutputChecker[T](hardwareName: String, get: => T) {
lastOutput = Some(get)
}
}

object StallChecker {
def timeAboveThreshold[Q <: Quantity[Q]](stream: Stream[Q], threshold: => Q): Stream[Time] =
stream.zipWithDt
.scanLeft(Seconds(0)) {
case (stallTime, (value, dt)) =>
if (value > threshold) {
stallTime + dt
} else Seconds(0)
}
}
74 changes: 35 additions & 39 deletions shared/src/main/scala/com/lynbrookrobotics/eighteen/CoreRobot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,37 +150,37 @@ class CoreRobot(configFileValue: Signal[String], updateConfigFile: String => Uni
cameraHardware <- cameraHardware
} {
// Full 3 cube
// addAutonomousRoutine(1) {
// val switchScalePattern = DriverStation.getInstance().getGameSpecificMessage
// switchScalePattern match {
// case "LLL" | "LLR" =>
// generator.OppositeSideSwitchAndScale
// .scaleSwitch3CubeAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous
// case "RLL" | "RLR" =>
// generator.SameSideSwitchOppositeScale
// .justSwitchAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous // same op
// case "LRL" | "LRR" =>
// generator.OppositeSideSwitchSameSideScale
// .scaleSwitch3CubeAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous // op same
// case "RRL" | "RRR" =>
// generator.SameSideSwitchAndScale
// .scaleSwitch3Cube(
// drivetrain,
// collectorRollers,
// collectorClamp,
// collectorPivot,
// cubeLiftComp,
// cameraHardware
// )
// .toContinuous // same same
// case _ =>
// println(s"Switch scale patter didn't match what was expected. Was $switchScalePattern")
// ContinuousTask.empty
// }
// }
// addAutonomousRoutine(1) {
// val switchScalePattern = DriverStation.getInstance().getGameSpecificMessage
// switchScalePattern match {
// case "LLL" | "LLR" =>
// generator.OppositeSideSwitchAndScale
// .scaleSwitch3CubeAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous
// case "RLL" | "RLR" =>
// generator.SameSideSwitchOppositeScale
// .justSwitchAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous // same op
// case "LRL" | "LRR" =>
// generator.OppositeSideSwitchSameSideScale
// .scaleSwitch3CubeAuto(drivetrain, collectorRollers, collectorClamp, collectorPivot, cubeLiftComp)
// .toContinuous // op same
// case "RRL" | "RRR" =>
// generator.SameSideSwitchAndScale
// .scaleSwitch3Cube(
// drivetrain,
// collectorRollers,
// collectorClamp,
// collectorPivot,
// cubeLiftComp,
// cameraHardware
// )
// .toContinuous // same same
// case _ =>
// println(s"Switch scale patter didn't match what was expected. Was $switchScalePattern")
// ContinuousTask.empty
// }
// }

// 3 cube when switch on our side, 1 cube in switch
// when switch on other side
Expand Down Expand Up @@ -424,29 +424,25 @@ class CoreRobot(configFileValue: Signal[String], updateConfigFile: String => Uni
board
.datasetGroup("Drivetrain/Current")
.addDataset(
coreTicks.map(_ => drivetrainHardware.left.t.getOutputCurrent).toTimeSeriesNumeric("Left master current")
drivetrainHardware.leftMasterCurrent.map(_.toAmperes).toTimeSeriesNumeric("Left master current")
)

board
.datasetGroup("Drivetrain/Current")
.addDataset(
coreTicks
.map(_ => drivetrainHardware.leftFollowerSRX.getOutputCurrent)
.toTimeSeriesNumeric("Left follower current")
drivetrainHardware.leftFollowerCurrent.map(_.toAmperes).toTimeSeriesNumeric("Left follower current")
)

board
.datasetGroup("Drivetrain/Current")
.addDataset(
coreTicks.map(_ => drivetrainHardware.right.t.getOutputCurrent).toTimeSeriesNumeric("Right master current")
drivetrainHardware.rightMasterCurrent.map(_.toAmperes).toTimeSeriesNumeric("Right master current")
)

board
.datasetGroup("Drivetrain/Current")
.addDataset(
coreTicks
.map(_ => drivetrainHardware.rightFollowerSRX.getOutputCurrent)
.toTimeSeriesNumeric("Right follower current")
drivetrainHardware.rightFollowerCurrent.map(_.toAmperes).toTimeSeriesNumeric("Right follower current")
)

board
Expand Down
Loading