-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccca65b
commit 36eefd5
Showing
10 changed files
with
100 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
plugins { | ||
kotlin("jvm") version "1.9.20" | ||
} | ||
|
||
hydrozoa { | ||
entrypoint = "dev.vexide.hydrozoa.clawbotkt.Main" | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(21) | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/clawbot-kotlin/src/main/kotlin/dev/vexide/hydrozoa/clawbotkt/Main.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,9 @@ | ||
@file:JvmName("Main") | ||
|
||
package dev.vexide.hydrozoa.clawbotkt | ||
|
||
import dev.vexide.hydrozoa.CompetitionRuntime | ||
|
||
fun main() { | ||
CompetitionRuntime.start(::Robot) | ||
} |
31 changes: 31 additions & 0 deletions
31
examples/clawbot-kotlin/src/main/kotlin/dev/vexide/hydrozoa/clawbotkt/Robot.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,31 @@ | ||
package dev.vexide.hydrozoa.clawbotkt | ||
|
||
import dev.vexide.hydrozoa.CompetitionRobot | ||
import dev.vexide.hydrozoa.Controller | ||
import dev.vexide.hydrozoa.Peripherals | ||
import dev.vexide.hydrozoa.devices.DeviceException | ||
import dev.vexide.hydrozoa.devices.smart.Motor | ||
|
||
class Robot(peripherals: Peripherals) : CompetitionRobot { | ||
private val leftMotor = Motor(peripherals.takePort(2), Motor.Gearset.Green, Motor.Direction.Forward) | ||
private val rightMotor = Motor(peripherals.takePort(8), Motor.Gearset.Green, Motor.Direction.Reverse) | ||
|
||
private val controller = peripherals.takeController(Controller.Id.Primary) | ||
|
||
override fun driverPeriodic() { | ||
val input = controller.state.orElseGet(Controller.State::empty) | ||
|
||
try { | ||
val forward = input.leftStick.y | ||
val turn = input.rightStick.x | ||
|
||
val leftVoltage = (forward + turn) * Motor.V5_MAX_VOLTAGE | ||
val rightVoltage = (forward - turn) * Motor.V5_MAX_VOLTAGE | ||
|
||
leftMotor.setVoltage(leftVoltage) | ||
rightMotor.setVoltage(rightVoltage) | ||
} catch (err: DeviceException) { | ||
throw RuntimeException(err) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
hydrozoa { | ||
entrypoint = "dev.vexide.hydrozoa.clawbot.Main" | ||
runtime = project.parent!!.parent!!.layout.projectDirectory.file("runtime.bin") | ||
} |
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 |
---|---|---|
@@ -1,18 +1,36 @@ | ||
package dev.vexide.hydrozoa; | ||
|
||
public abstract class CompetitionRobot { | ||
public void connected() {} | ||
public void disconnected() {} | ||
public interface CompetitionRobot { | ||
default void connected() { | ||
} | ||
|
||
public void disabledInit() {} | ||
public void disabledPeriodic() {} | ||
public void disabledExit() {} | ||
default void disconnected() { | ||
} | ||
|
||
public void autonomousInit() {} | ||
public void autonomousPeriodic() {} | ||
public void autonomousExit() {} | ||
default void disabledInit() { | ||
} | ||
|
||
public void driverInit() {} | ||
public void driverPeriodic() {} | ||
public void driverExit() {} | ||
default void disabledPeriodic() { | ||
} | ||
|
||
default void disabledExit() { | ||
} | ||
|
||
default void autonomousInit() { | ||
} | ||
|
||
default void autonomousPeriodic() { | ||
} | ||
|
||
default void autonomousExit() { | ||
} | ||
|
||
default void driverInit() { | ||
} | ||
|
||
default void driverPeriodic() { | ||
} | ||
|
||
default void driverExit() { | ||
} | ||
} |