Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/content/docs/hardware/actuators/feedback-servos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All of these below are interchangeable with `NextFeedbackCRServo`.
val armServo = NextFeedbackServo("armServo", NextAnalogInput("armEncoder"))

// By Lynx Module and port
val armServo = NextFeedbackServo(RobotController.expansionHub, 0, NextAnalogInput(RobotController.expansionHub, 0))
val armServo = NextFeedbackServo(RobotController.controlHub, 0, NextAnalogInput(RobotController.controlHub, 0))
```

</TabItem>
Expand All @@ -32,7 +32,7 @@ val armServo = NextFeedbackServo(RobotController.expansionHub, 0, NextAnalogInpu
NextFeedbackServo armServo = new NextFeedbackServo("armServo", new NextAnalogInput("armEncoder"));

// By Lynx Module and port
NextFeedbackServo armServo = new NextFeedbackServo(RobotController.getExpansionHub(), 0, new NextAnalogInput(RobotController.getExpansionHub(), 0));
NextFeedbackServo armServo = new NextFeedbackServo(RobotController.controlHub(), 0, new NextAnalogInput(RobotController.controlHub(), 0));
```

</TabItem>
Expand Down
79 changes: 79 additions & 0 deletions src/content/docs/robot/command-gamepad.mdx
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>
2 changes: 1 addition & 1 deletion src/content/docs/robot/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Commands
description: How NextFTC schedules commands, and where to find the full command API.
sidebar:
order: 1
order: 5
---

import { Tabs, TabItem } from "@astrojs/starlight/components";
Expand Down
113 changes: 113 additions & 0 deletions src/content/docs/robot/telemetry.mdx
Comment thread
zachwaffle4 marked this conversation as resolved.
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.
Loading