> For the complete documentation index, see [llms.txt](https://docs.uninterruptedexception.team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uninterruptedexception.team/op-mode/wrappers.md).

# Wrappers

{% hint style="success" %}
Code duplication is a pain, and it is a good programmer's #1 job to avoid it wherever possible.
{% endhint %}

For the 2026 Decoded FTC Season, we have a mirrored field, and that means that if we write our op modes correctly, we can have a master OpMode and wrapper child OpModes to simplify our code and reduce unneeded duplication.

A master OpMode is the OpMode that has the actual content. In other words, it is the code that tells the robot to move and when to move.

A wrapper class is the class that passes an alliance variable into the master OpMode. The master OpMode then uses that alliance variable to determine what action it should do based (for the Decoded season, should the limelight face to the red or the blue goal) on the alliance.

{% hint style="info" %}
This is an example of a wrapper class. This class uses the [alliance variable](https://github.com/Gamemanuel/FTCCodingTemplates/blob/main/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Utils/Alliance.java) and passes it to the Master OpMode (in this case, it is TeleOp.java). In Competition code you would have one file that passes the RED alliance and another that passes the BLUE alliance (like this one).

```java
package org.firstinspires.ftc.teamcode.DriverControl.TeleOp;

import org.firstinspires.ftc.teamcode.Utils.Alliance;

@com.qualcomm.robotcore.eventloop.opmode.TeleOp
public class TeleOpBlue extends TeleOp {
    public TeleOpBlue() {
        super(Alliance.BLUE);
    }
}

```

{% endhint %}

In order to make this work, we also need to use an [alliance variable](https://github.com/Gamemanuel/FTCCodingTemplates/blob/main/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Utils/Alliance.java).

```java
package org.firstinspires.ftc.teamcode.Utils;

public enum Alliance {
    RED, BLUE, ANY
}

```

This Alliance Variable is really simple, and it allows us to create wrappers for the RED alliance, the BLUE alliance and to add wrappers for the ANY alliance (we don't use that one normally, and for years there has been no need for alliance-specific actions, so there is no need for the wrapper).

To use this in your code you need the wrapper files and the master class (explained in the next page)

{% hint style="info" %}
This is a example of the structure that you would use when making your wrapper files

* [x] Create a New folder the name of your master class (does not need to be that name but is nice for code readability).
* [x] Add your master class to this file if it is not already in it.
* [x] Create a new java file (this will be your wrapper file)
* [x] Name it (Preferably) to \[Master name]\[Alliance color] (ex: TeleOpRed).
* [x] follow the following code structure:<br>

  ```
  package.name // (name of the directory that your file and your master file is in)

  import allianceVariable

  @com.qualcomm.robotcore.eventloop.opmode.TeleOp
  public class MasterNameAllianceColor extends MasterName {
      public MasterNameAllianceColor() {
          super(Alliance.AllianceColor);
      }
  }
  ```
* [x] Test and make sure it works!
  {% endhint %}

{% hint style="danger" %}
Make sure that \[Master name]\[Alliance color] is spelled the same in all of the places that you use it or it will break.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.uninterruptedexception.team/op-mode/wrappers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
