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

Commit

Permalink
Add templates for super scouting (#38)
Browse files Browse the repository at this point in the history
* Add super scouting template

* Add Switch Lite

* Fix Buddy Climb

* Add match schedule to super scouting encoder
  • Loading branch information
yuliu2016 committed Feb 3, 2020
1 parent 5f20f7e commit 689d45f
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 11 deletions.
265 changes: 259 additions & 6 deletions app/src/main/assets/Boardfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,22 @@
],
[
{
"name": "balanced_after_climb",
"name": "balanced",
"type": "Checkbox",
"options": []
}
],
[
},
{
"name": "active_movement",
"type": "Checkbox",
"options": []
}
],
[
{
"name": "driver_skill_rating",
"type": "MultiToggle",
"options": ["1", "2", "3", "4", "5"]
}
]
]
}
Expand All @@ -170,7 +175,255 @@
]
},
"super_scout": {
"screens": [],
"tags": []
"screens": [
{
"title": "Robot 1",
"layout": [
[
{
"name": "A1_defends_O1",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A1_defends_O2",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A1_defends_O3",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A1_blocking_shots",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A1_following_team",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A1_defends_cross_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A1_defends_mid_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A1_defends_close_field",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A1_defence_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
],
[
{
"name": "A1_resistance_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
]
]
},
{
"title": "Robot 2",
"layout": [
[
{
"name": "A2_defends_O1",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A2_defends_O2",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A2_defends_O3",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A2_blocking_shots",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A2_following_team",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A2_defends_cross_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A2_defends_mid_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A2_defends_close_field",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A2_defence_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
],
[
{
"name": "A2_resistance_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
]
]
},
{
"title": "Robot 3",
"layout": [
[
{
"name": "A3_defends_O1",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A3_defends_O2",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A3_defends_O3",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A3_blocking_shots",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A3_following_team",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A3_defends_cross_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A3_defends_mid_field",
"type": "Switch",
"options": ["lite"]
},
{
"name": "A3_defends_close_field",
"type": "Switch",
"options": ["lite"]
}
],
[
{
"name": "A3_defence_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
],
[
{
"name": "A3_resistance_rating",
"type": "MultiToggle",
"options": ["N/A", "1", "2", "3", "4", "5"]
}
]
]
},
{
"title": "Buddy climb",
"layout": [
[
{
"name": "lifter",
"type":"MultiToggle",
"options": [
"N/A",
"A1",
"A2",
"A3"
]
}
],
[
{
"name": "A1_lifted",
"type": "Switch",
"options": []
},
{
"name": "A2_lifted",
"type": "Switch",
"options": []
},
{
"name": "A3_lifted",
"type": "Switch",
"options": []
}
],
[
{
"name": "Climb_status",
"type": "MultiToggle",
"options": [
"N/A",
"Attempted",
"Success",
"Failed"
]
}
],
[],
[]
]
}
],
"tags": [
"comment_applies_to_A1",
"comment_applies_to_A2",
"comment_applies_to_A3"
]
}
}
12 changes: 10 additions & 2 deletions app/src/main/java/ca/warp7/android/scouting/ScoutingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ScoutingActivity : AppCompatActivity(), BaseScoutingActivity {

for ((index, tag) in tags.withIndex()) {
layout.addView(CheckBox(this).also { cb ->
cb.text = modifyNameForDisplay(tag)
cb.text = modifyName(tag)
cb.textSize = 18f
val typeIndex = template.lookupForTag(index)
val lastValue = entry.lastValue(typeIndex)?.value ?: 0
Expand Down Expand Up @@ -266,8 +266,16 @@ class ScoutingActivity : AppCompatActivity(), BaseScoutingActivity {
RX, BX -> "ALL"
}

// special entry team string to encode match schedule with super scouts
val entryTeam = when(board) {
RX -> teams.joinToString("_")
// invert the list order for the blue alliance
BX -> (teams.subList(3, 6) + teams.subList(0, 3)).joinToString("_")
else -> team
}

this.entryInMatch = entryInMatch
entry = TimedEntry(match, team, scout, board, getCurrentTime().toInt()) { getRelativeTime() }
entry = TimedEntry(match, entryTeam, scout, board, getCurrentTime().toInt()) { getRelativeTime() }

findViewById<TextView>(R.id.toolbar_match).text = match.let {
val split = it.split("_")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ class SwitchField : FrameLayout, BaseFieldWidget {
private val red = ContextCompat.getColor(context, R.color.colorRed)
private val lightGreen = ContextCompat.getColor(context, R.color.colorLightGreen)
private val almostWhite = ContextCompat.getColor(context, R.color.colorAlmostWhite)
private val accent = ContextCompat.getColor(context, R.color.colorAccent)

private var isChecked = false
private var button: Button? = null
private val isLite: Boolean

constructor(context: Context) : super(context) {
fieldData = null
isLite = false
}

internal constructor(data: FieldData) : super(data.context) {
Expand All @@ -42,6 +45,8 @@ class SwitchField : FrameLayout, BaseFieldWidget {
addView(this)
}

isLite = data.templateField.options?.contains("lite") ?: false

updateControlState()
}

Expand Down Expand Up @@ -71,7 +76,11 @@ class SwitchField : FrameLayout, BaseFieldWidget {

if (isChecked) {
button.setTextColor(white)
button.background.setColorFilter(red, PorterDuff.Mode.SRC)
if (isLite) {
button.background.setColorFilter(accent, PorterDuff.Mode.SRC)
} else {
button.background.setColorFilter(red, PorterDuff.Mode.SRC)
}
} else {
button.setTextColor(lightGreen)
button.background.setColorFilter(almostWhite, PorterDuff.Mode.SRC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class ToggleField : LinearLayout, BaseFieldWidget {
data.templateField.options?.forEachIndexed { i, v ->
if (v.startsWith("default:")) {
defaultPosition = i
options.add(v.substring(8))
} else options.add(v)
options.add(data.scoutingActivity.modifyName(v.substring(8)))
} else options.add(data.scoutingActivity.modifyName(v))
}

toggleSwitch = ToggleSwitchCompat(data.context).apply {
Expand Down

0 comments on commit 689d45f

Please sign in to comment.