forked from NextFTC/NextFTC-Docs
-
Notifications
You must be signed in to change notification settings - Fork 1
Gamepad and telemetry docs #12
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
Open
28shettr
wants to merge
17
commits into
NextFTC:main
Choose a base branch
from
28shettr:gamepad-telemetry-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
52ca48f
a
28shettr 67501ff
gamepad and telemetry moved to this branch
28shettr 0bc3c3f
prettier
28shettr 2b70aa5
prettier
28shettr 681f722
Merge branch 'main' into gamepad-telemetry-docs
zachwaffle4 5b3322c
fixed
28shettr 390eeee
Merge remote-tracking branch 'origin/gamepad-telemetry-docs' into gam…
28shettr 74eebed
shush small fix
28shettr a783785
shush small fix
28shettr 7170828
Merge branch 'main' into gamepad-telemetry-docs
zachwaffle4 18ea5a7
fixed suggestions
28shettr be39ae4
Merge remote-tracking branch 'origin/gamepad-telemetry-docs' into gam…
28shettr 0365aa5
Merge branch 'main' into gamepad-telemetry-docs
zachwaffle4 6623e4b
fix wording
28shettr ff67b89
Restore deviceStreaming.xml
28shettr b0fa4e0
ordering
28shettr b1249aa
Merge branch 'NextFTC:main' into gamepad-telemetry-docs
28shettr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,79 @@ | ||
| --- | ||
| title: Command Gamepad | ||
| description: Mapping gamepad buttons to Triggers with CommandGamepad | ||
| sidebar: | ||
| order: 1 | ||
| --- | ||
|
|
||
| import { Tabs, TabItem } from "@astrojs/starlight/components"; | ||
|
|
||
| `CommandGamepad` wraps the standard FTC `Gamepad` and exposes its buttons and sticks as command-based `Trigger`s. | ||
| This lets you map controller inputs directly to commands using the WPILib-style Trigger API. | ||
|
|
||
| ## Creating a CommandGamepad | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| val gp1 = CommandGamepad(gamepad1) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| CommandGamepad gp1 = new CommandGamepad(gamepad1); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| `CommandGamepad` accepts an optional `eventLoop` parameter, defaulting to `Trigger.defaultEventLoop`. | ||
| You generally won't need to override it unless you're managing multiple event loops. | ||
|
|
||
| ## Usage | ||
|
|
||
| Every `button` is exposed as a `Trigger`, which you can bind to commands with methods like `onTrue()` or `onFalse()` etc. | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| gp1.circle.onTrue(robot.intake.on()) | ||
| gp1.circle.onFalse(robot.intake.off()) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| gp1.circle().onTrue(robot.intake.on()); | ||
| gp1.circle().onFalse(robot.intake.off()); | ||
|
|
||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### Sticks and Triggers | ||
|
|
||
| Joysticks and gamepad triggers are exposed as `RangeTrigger`s instead of regular `Trigger`s, | ||
| since they report an analog value rather than a boolean value, letting you | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| gp1.rightTrigger.isOver(0.2).onTrue(robot.launcher.launch()) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| gp1.rightTrigger().isOver(0.2).onTrue(robot.launcher.launch()); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> |
This file contains hidden or 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 hidden or 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 @@ | ||
| --- | ||
| title: Telemetry | ||
| description: Broadcasting telemetry to multiple destinations with Telemetry | ||
| sidebar: | ||
| order: 6 | ||
| --- | ||
|
|
||
| import { Tabs, TabItem } from "@astrojs/starlight/components"; | ||
|
|
||
| `Telemetry` lets you send data to the Driver Station, FTC Dashboard, or anywhere else, all at once. | ||
| The `Telemetry` functions are all static; you don't need to create your own telemetry instances. | ||
| By default, everything goes to the Driver Station. | ||
| If you want it to also show up somewhere else, register another backend. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### `log(key, value)` / `log(line)` | ||
|
|
||
| Logs a data pair, or a raw string, to every registered backend. | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| Telemetry.log("Arm Position", arm.position) | ||
| Telemetry.log("Ready") | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| Telemetry.log("Arm Position", arm.getPosition()); | ||
| Telemetry.log("Ready"); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### `update()` | ||
|
|
||
| Sends everything you've logged out to all your backends. `TelemetryHook` already calls this for you every loop, so you usually won't need to call it yourself. | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| Telemetry.update() | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| Telemetry.update(); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### `addBackend(backend)` | ||
|
|
||
| Adds another place for your telemetry to go. | ||
| You can pass in a `TelemetryBackend`, or a regular FTC SDK `Telemetry` instance (like the one from FTC Dashboard) and it'll be wrapped for you automatically. | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| Telemetry.addBackend(FtcDashboard.getInstance().telemetry) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| Telemetry.addBackend(FtcDashboard.getInstance().getTelemetry()); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Logging with FateWeaver | ||
|
|
||
| [FateWeaver](https://github.com/HermesFTC/FateWeaver#usage) is a RoadRunner-log based data logging library for FTC. | ||
| Its `FlightRecorder` implements the standard FTC SDK `Telemetry` interface, so you can register it directly as a backend using the `addBackend(SdkTelemetry)` overload | ||
|
|
||
| <Tabs syncKey="language"> | ||
| <TabItem label="Kotlin"> | ||
|
|
||
| ```kotlin | ||
| Telemetry.addBackend(FlightRecorder) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem label="Java"> | ||
|
|
||
| ```java | ||
| Telemetry.addBackend(FlightRecorder.INSTANCE); | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| Once registered, every `Telemetry.log()` call also gets written to your FateWeaver logs, which is viewable and downloadable from the robot's web dashboard using either [`http://192.168.43.1:8080/fate`](http://192.168.43.1:8080/fate) (Control Hub) or [`http://192.168.49.1:8080/fate`](http://192.168.49.1:8080/fate) (RC phone), and openable in [AdvantageScope](https://docs.advantagescope.org/overview/installation/). | ||
|
|
||
| A couple of things to know about logging through `Telemetry` this way: | ||
|
|
||
| - All data is logged as strings, to stay compatible with `Telemetry`. | ||
| - Each new caption you log automatically creates its own log channel in FateWeaver. | ||
|
|
||
| If you want typed channels, custom schemas, or other FateWeaver-specific features (`FlightRecorder.createChannel()`, `CustomStructSchema`, etc.), use the FateWeaver API directly. | ||
| See the [FateWeaver documentation](https://github.com/HermesFTC/FateWeaver#usage) for details. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.