Skip to content

Commit

Permalink
Combined Configuration (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Aug 9, 2024
2 parents 5d4e5e4 + ff07568 commit 1a171c5
Show file tree
Hide file tree
Showing 37 changed files with 2,317 additions and 1,234 deletions.
32 changes: 19 additions & 13 deletions fission/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6XNCRD7QNC"></script>
<link rel="icon" type="image/svg+xml" href="/synthesis-logo.svg" />
<link rel='stylesheet' href='https://static-dc.autodesk.net/etc/designs/v201808022224/templates-general/structure/fonts/artifakt/clientlibs/artifakt.css'/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fission | Synthesis</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<head>
<meta charset="UTF-8" />
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6XNCRD7QNC"></script>
<link rel="icon" type="image/svg+xml" href="/synthesis-logo.svg" />
<link
rel="stylesheet"
href="https://static-dc.autodesk.net/etc/designs/v201808022224/templates-general/structure/fonts/artifakt/clientlibs/artifakt.css"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>Fission | Synthesis</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
34 changes: 10 additions & 24 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import UpdateAvailableModal from "@/modals/UpdateAvailableModal"
import ViewModal from "@/modals/ViewModal"
import ConnectToMultiplayerModal from "@/modals/aether/ConnectToMultiplayerModal"
import ServerHostingModal from "@/modals/aether/ServerHostingModal"
import ChangeInputsModal from "@/ui/modals/configuring/inputs/ChangeInputsModal.tsx"
import ChooseMultiplayerModeModal from "@/modals/configuring/ChooseMultiplayerModeModal"
import ChooseSingleplayerModeModal from "@/modals/configuring/ChooseSingleplayerModeModal"
import ConfigMotorModal from "@/modals/configuring/ConfigMotorModal"
Expand All @@ -37,36 +36,33 @@ import ThemeEditorModal from "@/modals/configuring/theme-editor/ThemeEditorModal
import MatchModeModal from "@/modals/spawning/MatchModeModal"
import RobotSwitchPanel from "@/panels/RobotSwitchPanel"
import SpawnLocationsPanel from "@/panels/SpawnLocationPanel"
import ConfigureGamepiecePickupPanel from "@/panels/configuring/ConfigureGamepiecePickupPanel"
import ConfigureShotTrajectoryPanel from "@/panels/configuring/ConfigureShotTrajectoryPanel"
import ScoringZonesPanel from "@/panels/configuring/scoring/ScoringZonesPanel"
import ScoreboardPanel from "@/panels/information/ScoreboardPanel"
import DriverStationPanel from "@/panels/simulation/DriverStationPanel"
import PokerPanel from "@/panels/PokerPanel.tsx"
import ManageAssembliesModal from "@/modals/spawning/ManageAssembliesModal.tsx"
import World from "@/systems/World.ts"
import { AddRobotsModal, AddFieldsModal, SpawningModal } from "@/modals/spawning/SpawningModals.tsx"
import ImportLocalMirabufModal from "@/modals/mirabuf/ImportLocalMirabufModal.tsx"
import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel.tsx"
import Skybox from "./ui/components/Skybox.tsx"
import ChooseInputSchemePanel from "./ui/panels/configuring/ChooseInputSchemePanel.tsx"
import ProgressNotifications from "./ui/components/ProgressNotification.tsx"
import ConfigureRobotModal from "./ui/modals/configuring/ConfigureRobotModal.tsx"
import ResetAllInputsModal from "./ui/modals/configuring/inputs/ResetAllInputsModal.tsx"
import ZoneConfigPanel from "./ui/panels/configuring/scoring/ZoneConfigPanel.tsx"
import ConfigureRobotBrainPanel from "./ui/panels/configuring/ConfigureRobotBrainPanel.tsx"
import SceneOverlay from "./ui/components/SceneOverlay.tsx"

import WPILibWSWorker from "@/systems/simulation/wpilib_brain/WPILibWSWorker.ts?worker"
import WSViewPanel from "./ui/panels/WSViewPanel.tsx"
import Lazy from "./util/Lazy.ts"

import RCConfigPWMGroupModal from "@/modals/configuring/rio-config/RCConfigPWMGroupModal.tsx"
import RCConfigCANGroupModal from "@/modals/configuring/rio-config/RCConfigCANGroupModal.tsx"
import DebugPanel from "./ui/panels/DebugPanel.tsx"
import NewInputSchemeModal from "./ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx"
import AssignNewSchemeModal from "./ui/modals/configuring/theme-editor/AssignNewSchemeModal.tsx"
import AnalyticsConsent from "./ui/components/AnalyticsConsent.tsx"
import PreferencesSystem from "./systems/preferences/PreferencesSystem.ts"
import ResetAllInputsModal from "./ui/modals/configuring/inputs/ResetAllInputsModal.tsx"
import APSManagementModal from "./ui/modals/APSManagementModal.tsx"
import ConfigurePanel from "./ui/panels/configuring/assembly-config/ConfigurePanel.tsx"

const worker = new Lazy<Worker>(() => new WPILibWSWorker())

Expand Down Expand Up @@ -209,7 +205,6 @@ const initialModals = [
<UpdateAvailableModal key="update-available" modalId="update-available" />,
<ConnectToMultiplayerModal key="connect-to-multiplayer" modalId="connect-to-multiplayer" />,
<ServerHostingModal key="server-hosting" modalId="server-hosting" />,
<ChangeInputsModal key="change-inputs" modalId="change-inputs" />,
<ChooseMultiplayerModeModal key="multiplayer-mode" modalId="multiplayer-mode" />,
<ChooseSingleplayerModeModal key="singleplayer-mode" modalId="singleplayer-mode" />,
<PracticeSettingsModal key="practice-settings" modalId="practice-settings" />,
Expand All @@ -224,9 +219,7 @@ const initialModals = [
<RCConfigEncoderModal key="config-encoder" modalId="config-encoder" />,
<MatchModeModal key="match-mode" modalId="match-mode" />,
<ConfigMotorModal key="config-motor" modalId="config-motor" />,
<ManageAssembliesModal key="manage-assemblies" modalId="manage-assemblies" />,
<ImportLocalMirabufModal key="import-local-mirabuf" modalId="import-local-mirabuf" />,
<ConfigureRobotModal key="config-robot" modalId="config-robot" />,
<ResetAllInputsModal key="reset-inputs" modalId="reset-inputs" />,
<APSManagementModal key="aps-management" modalId="aps-management" />,
]
Expand All @@ -236,25 +229,18 @@ const initialPanels: ReactElement[] = [
<DriverStationPanel key="driver-station" panelId="driver-station" />,
<SpawnLocationsPanel key="spawn-locations" panelId="spawn-locations" />,
<ScoreboardPanel key="scoreboard" panelId="scoreboard" openLocation="top" sidePadding={8} />,
<ConfigureGamepiecePickupPanel
key="config-gamepiece-pickup"
panelId="config-gamepiece-pickup"
openLocation="right"
sidePadding={8}
/>,
<ConfigureShotTrajectoryPanel
key="config-shot-trajectory"
panelId="config-shot-trajectory"
<ImportMirabufPanel key="import-mirabuf" panelId="import-mirabuf" />,
<PokerPanel key="poker" panelId="poker" />,
<ConfigureRobotBrainPanel
key="config-robot-brain"
panelId="config-robot-brain"
openLocation="right"
sidePadding={8}
/>,
<ScoringZonesPanel key="scoring-zones" panelId="scoring-zones" openLocation="right" sidePadding={8} />,
<ZoneConfigPanel key="zone-config" panelId="zone-config" openLocation="right" sidePadding={8} />,
<ImportMirabufPanel key="import-mirabuf" panelId="import-mirabuf" />,
<PokerPanel key="poker" panelId="poker" />,
<ChooseInputSchemePanel key="choose-scheme" panelId="choose-scheme" />,
<WSViewPanel key="ws-view" panelId="ws-view" />,
<DebugPanel key="debug" panelId="debug" />,
<ConfigurePanel key="configure" panelId="configure" />,
]

export default Synthesis
4 changes: 2 additions & 2 deletions fission/src/systems/input/DefaultInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class DefaultInputs {
shift: false,
meta: false,
}),
new AxisInput("joint 5", "KeyN", "true", -1, false, false, -1, -1, EmptyModifierState, {
ctrl: false,
new AxisInput("joint 5", "KeyN", "KeyN", -1, false, false, -1, -1, EmptyModifierState, {
ctrl: true,
alt: false,
shift: false,
meta: false,
Expand Down
3 changes: 0 additions & 3 deletions fission/src/systems/input/InputSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ class InputSystem extends WorldSystem {
private static _gpIndex: number | null
public static gamepad: Gamepad | null

// The scheme most recently selected in the controls modal
public static selectedScheme: InputScheme | undefined

// Maps a brain index to a certain input scheme
public static brainIndexSchemeMap: Map<number, InputScheme> = new Map()

Expand Down
19 changes: 19 additions & 0 deletions fission/src/systems/preferences/PreferenceTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,29 @@ export type EjectorPreferences = {
parentNode: string | undefined
}

export type BehaviorType = "Elevator" | "Arm"

export type SequentialBehaviorPreferences = {
jointIndex: number
parentJointIndex: number | undefined
type: BehaviorType
inverted: boolean
}

export function DefaultSequentialConfig(index: number, type: BehaviorType): SequentialBehaviorPreferences {
return {
jointIndex: index,
parentJointIndex: undefined,
type: type,
inverted: false,
}
}

export type RobotPreferences = {
inputsSchemes: InputScheme[]
intake: IntakePreferences
ejector: EjectorPreferences
sequentialConfig?: SequentialBehaviorPreferences[]
}

export type Alliance = "red" | "blue"
Expand Down
4 changes: 2 additions & 2 deletions fission/src/systems/simulation/Brain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Mechanism from "../physics/Mechanism"
abstract class Brain {
protected _mechanism: Mechanism

constructor(mechansim: Mechanism) {
this._mechanism = mechansim
constructor(mechanism: Mechanism) {
this._mechanism = mechanism
}

public abstract Update(deltaT: number): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class ArcadeDriveBehavior extends Behavior {
private _driveSpeed = 30
private _turnSpeed = 30

public get wheels(): WheelDriver[] {
return this.leftWheels.concat(this.rightWheels)
}

constructor(
leftWheels: WheelDriver[],
rightWheels: WheelDriver[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import HingeDriver from "@/systems/simulation/driver/HingeDriver"
import HingeStimulus from "@/systems/simulation/stimulus/HingeStimulus"
import Behavior from "@/systems/simulation/behavior/Behavior"
import InputSystem from "@/systems/input/InputSystem"
import { SequentialBehaviorPreferences } from "@/systems/preferences/PreferenceTypes"
import HingeDriver from "../../driver/HingeDriver"
import HingeStimulus from "../../stimulus/HingeStimulus"
import SequenceableBehavior from "./SequenceableBehavior"

class GenericArmBehavior extends Behavior {
class GenericArmBehavior extends SequenceableBehavior {
private _hingeDriver: HingeDriver
private _inputName: string
private _brainIndex: number

private _rotationalSpeed = 6
public get hingeDriver(): HingeDriver {
return this._hingeDriver
}

constructor(hingeDriver: HingeDriver, hingeStimulus: HingeStimulus, jointIndex: number, brainIndex: number) {
super([hingeDriver], [hingeStimulus])
maxVelocity: number = 6

this._hingeDriver = hingeDriver
this._inputName = "joint " + jointIndex
this._brainIndex = brainIndex
}
constructor(
hingeDriver: HingeDriver,
hingeStimulus: HingeStimulus,
jointIndex: number,
brainIndex: number,
sequentialConfig: SequentialBehaviorPreferences | undefined
) {
super(jointIndex, brainIndex, [hingeDriver], [hingeStimulus], sequentialConfig)

// Sets the arms target rotational velocity
rotateArm(rotationalVelocity: number) {
this._hingeDriver.targetVelocity = rotationalVelocity
this._hingeDriver = hingeDriver
}

public Update(_: number): void {
this.rotateArm(InputSystem.getInput(this._inputName, this._brainIndex) * this._rotationalSpeed)
applyInput = (velocity: number) => {
this._hingeDriver.targetVelocity = velocity
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import SliderDriver from "@/systems/simulation/driver/SliderDriver"
import SliderStimulus from "@/systems/simulation/stimulus/SliderStimulus"
import Behavior from "@/systems/simulation/behavior/Behavior"
import InputSystem from "@/systems/input/InputSystem"
import { SequentialBehaviorPreferences } from "@/systems/preferences/PreferenceTypes"
import SliderDriver from "../../driver/SliderDriver"
import SliderStimulus from "../../stimulus/SliderStimulus"
import SequenceableBehavior from "./SequenceableBehavior"

class GenericElevatorBehavior extends Behavior {
class GenericElevatorBehavior extends SequenceableBehavior {
private _sliderDriver: SliderDriver
private _inputName: string
private _brainIndex: number

private _linearSpeed = 2.5
maxVelocity = 6

constructor(sliderDriver: SliderDriver, sliderStimulus: SliderStimulus, jointIndex: number, brainIndex: number) {
super([sliderDriver], [sliderStimulus])

this._sliderDriver = sliderDriver
this._inputName = "joint " + jointIndex
this._brainIndex = brainIndex
public get sliderDriver(): SliderDriver {
return this._sliderDriver
}

// Changes the elevators target position
moveElevator(linearVelocity: number) {
this._sliderDriver.targetVelocity = linearVelocity
constructor(
sliderDriver: SliderDriver,
sliderStimulus: SliderStimulus,
jointIndex: number,
brainIndex: number,
sequentialConfig: SequentialBehaviorPreferences | undefined
) {
super(jointIndex, brainIndex, [sliderDriver], [sliderStimulus], sequentialConfig)

this._sliderDriver = sliderDriver
}

public Update(_: number): void {
this.moveElevator(InputSystem.getInput(this._inputName, this._brainIndex) * this._linearSpeed)
applyInput = (velocity: number) => {
this._sliderDriver.targetVelocity = velocity
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { SequentialBehaviorPreferences } from "@/systems/preferences/PreferenceTypes"
import Driver from "../../driver/Driver"
import Stimulus from "../../stimulus/Stimulus"
import Behavior from "../Behavior"
import InputSystem from "@/systems/input/InputSystem"

abstract class SequenceableBehavior extends Behavior {
private _jointIndex: number
private _brainIndex: number
private _sequentialConfig: SequentialBehaviorPreferences | undefined

abstract maxVelocity: number

public get jointIndex(): number {
return this._jointIndex
}

constructor(
jointIndex: number,
brainIndex: number,
drivers: Driver[],
stimuli: Stimulus[],
sequentialConfig: SequentialBehaviorPreferences | undefined
) {
super(drivers, stimuli)

this._jointIndex = jointIndex
this._brainIndex = brainIndex
this._sequentialConfig = sequentialConfig
}

abstract applyInput: (velocity: number) => void

public Update(_: number): void {
const inputName = "joint " + (this._sequentialConfig?.parentJointIndex ?? this._jointIndex)
const inverted = this._sequentialConfig?.inverted ?? false

this.applyInput(InputSystem.getInput(inputName, this._brainIndex) * this.maxVelocity * (inverted ? -1 : 1))
}
}

export default SequenceableBehavior
4 changes: 4 additions & 0 deletions fission/src/systems/simulation/driver/HingeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class HingeDriver extends Driver {
private _targetVelocity: number = 0.0
private _targetAngle: number

public get constraint(): Jolt.HingeConstraint {
return this._constraint
}

public get targetVelocity(): number {
return this._targetVelocity
}
Expand Down
4 changes: 4 additions & 0 deletions fission/src/systems/simulation/driver/SliderDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class SliderDriver extends Driver {
private _targetVelocity: number = 0.0
private _targetPosition: number = 0.0

public get constraint(): Jolt.SliderConstraint {
return this._constraint
}

public get targetVelocity(): number {
return this._targetVelocity
}
Expand Down
Loading

0 comments on commit 1a171c5

Please sign in to comment.