Skip to content

Commit 15abdd3

Browse files
committed
full rework
1 parent ab68cfe commit 15abdd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1201
-888
lines changed

Writerside/redirection-rules.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@
1414
<description>Created after removal of "Import" from Code Training Module</description>
1515
<accepts>Import.html</accepts>
1616
</rule>
17+
<rule id="3d8043e7">
18+
<description>Created after removal of "VelocityVision" from Code Training Module</description>
19+
<accepts>velocityvision.html</accepts>
20+
</rule>
21+
<rule id="78781f68">
22+
<description>Created after removal of "StateMachine" from Code Training Module</description>
23+
<accepts>statemachine.html</accepts>
24+
</rule>
25+
<rule id="1233e87c">
26+
<description>Created after removal of "Servo" from Code Training Module</description>
27+
<accepts>Servo.html</accepts>
28+
</rule>
1729
</rules>

Writerside/topics/.etc/code-review.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
---
2-
description: >-
3-
Code reviews are a handy way of making sure all your code works by asking
4-
alumni to "approve" and comment on it with little overhead.
5-
---
6-
71
# Code Review
82

3+
Code reviews are a handy way of making sure all your code works by asking
4+
alumni to "approve" and comment on it with little overhead.
5+
96
If you want to do code reviews with me, please DM me over Discord or email.
107

118

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
1-
# linksAndAcknowledgements
1+
# Acknowledgements
22

3-
### Useful Links
4-
5-
* My [user page](https://github.com/GramGra07) (GramGra07)
6-
* FTC Official GitHub [user page](https://github.com/FIRST-Tech-Challenge)
7-
* Team Resources [folder](https://github.com/WindsorHSRobotics/Team\_Resources)
8-
* [Rev Hardware Client](https://docs.revrobotics.com/rev-hardware-client/getting-started/installation-instructions)
9-
* [FTC Sample OpModes](https://github.com/FIRST-Tech-Challenge/FtcRobotController)
10-
* [FTC BasicOpModeLinear (21-22)](https://github.com/FIRST-Tech-Challenge/FtcRobotController/blob/master/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode\_Linear.java)
11-
* [Game Manual 0](https://gm0.org/en/latest/)
12-
* [FTC Resource Library](https://www.firstinspires.org/resource-library/ftc/game-and-season-info)
13-
* [Github -> Discord Web Hooks](https://gist.github.com/jagrosh/5b1761213e33fc5b54ec7f6379034a22)
14-
* [3D Printing Basics by my Dad](https://docs.google.com/presentation/d/1MeLkA9mCI4vZMiejlqMZpAhZvbV2ThvSf6oZBzhQGdo/edit?usp=sharing)
15-
* [Mecanum Drivetrain QuickStart](https://gm0.org/en/latest/docs/software/tutorials/mecanum-drive.html)
16-
* [TankDrive Drivetrain Quickstart](https://docs.revrobotics.com/kickoff-concepts/freight-frenzy-2021-2022/programming-teleoperated)
17-
* [Very good overall tutorial on the basics of blocks](https://www.firstinspires.org/sites/default/files/uploads/resource\_library/ftc/blocks-programming-guide.pdf)
18-
19-
### Acknowledgements
20-
21-
* [Google](https://www.google.com/)
223
* [Mr Cline](https://github.com/stcline)
234
* [Mr Mayfield](https://github.com/JohnMayfield)
24-
* [FTC User Page](https://github.com/FIRST-Tech-Challenge/FtcRobotController)
25-
* [Rev Robotics](https://www.revrobotics.com/)
26-
* [Android Studio](https://developer.android.com/studio)
27-
28-
**Proofreaders**
29-
305
* [C Timmons](https://github.com/ctimmons25)
316
* [B Sanger](https://github.com/sangerb19)
7+

Writerside/topics/Basics.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Basics
2+
3+
To get started with GitHub, Android Studio, and Java Programming, you will need to follow these steps:
4+
5+
1. Create a GitHub account if you haven't already
6+
2. Fork the [FTC Robot Controller](https://github.com/FIRST-Tech-Challenge/FtcRobotController) repository
7+
3. Download Android Studio
8+
4. Clone your forked repository
9+
5. Open the project in Android Studio
10+
6. Code
11+
7. Send the robot your updated code
12+
8. Set up a config on your robot
13+
9. Start controlling your robot!
14+
15+
### Android Studio Tutorial
16+
17+
#### Android Studio Setup
18+
19+
Android Studio Setup Video Tutorial:
20+
21+
<video src="../../images/mov/Android Studio Setup Tutorial.mp4" />
22+
23+
Android studio is one of the easier IDEs in terms of setup and usability. There are a lot of things that you can get lost with easily though.
24+
25+
**Gradle** - The gradle is the way your app (robot) will run
26+
27+
**ADB** - Android Debug Bridge is the way your computer will connect to the control hub and build the application
28+
29+
#### How does everything work?
30+
31+
* Basically, when you hit upload, it runs and installs an app to the robot's control hub. What this does is allow it to run effectively while connected to the driver station. The **gradle** is the way that this app gets built. This is also why it is so important to fork the FTC Robot Controller. They make the onboarding steps so much easier just because all the work for setup is done for you.
32+
33+
#### Plugins
34+
35+
I have encountered a bunch of plugins for AS that make the experience so much better. None of these are mandatory but may improve your experience. You access this page in the settings for AS.
36+
37+
* ADB Idea - Allows you to effectively use ADB with your computer to make sure everything is working properly.
38+
* Better Comments - Changes your comments to different colors with different tags. This is extremely beneficial because it catches your eye more so you can leave notes for yourself.
39+
* CodeGlance Pro - This improves the normal sidebar you will see when scrolling, it shows you the color of all of your code so you can easily see where you might need to be looking.
40+
* Discord Integration - Definitely not necessary but very fun to use and show everyone which project you are working on in Discord.
41+
* Dracula Theme - My personal favorite theme for AS because it looks very nice and the color coding makes a lot of sense to me.
42+
* GitHub Copilot - A very useful companion when you are coding. It is a **subscription** that you can get free with GitHub Student Developer but basically allows you to have an AI "copilot" built in to your IDE for code completion and general help.
43+
* Star Wars Progress Bar - My personal favorite plugin I have. All it really does is change your progress bars to Star Wars ships. It adds a lot of fun to the IDE.

Writerside/topics/Classes.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Classes
2+
3+
### Object Oriented Programming
4+
5+
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of classes and objects. It provides a structured way to organize code, making it more modular, reusable, and easier to manage. OOP helps reduce errors by encapsulating data and behavior within classes, reusing code, and minimizing duplication.
6+
7+
In the context of FTC, you might use OOP to create a custom DcMotor class that extends or enhances the built-in DcMotor functionality, allowing for additional features such as preset motor speeds, automated braking, or advanced control algorithms.
8+
9+
For a generic example, if you had a Person class with two parameters and variables, name and age. If you wanted to do this exact thing, you would create the Person class, and then access that property later in the program. Example below
10+
11+
```java
12+
class Person {
13+
String name;
14+
int age;
15+
16+
// constructor
17+
public Person(String name, int age) {
18+
this.name = name;
19+
this.age = age;
20+
}
21+
}
22+
23+
// initialize the class
24+
Person bob = new Person("bob", 29);
25+
// access bob's name
26+
bob.name;
27+
// access his age
28+
bob.age;
29+
```
30+
31+
### State Based Class
32+
33+
See [this](subsystem-control.md)
34+
35+
State based classes and subsystems are a little different from the base level subsystem like above. These are commonly used for servos or other simple classes that have foreseeable states. For instance, my claw subsystem class, included completely below, uses states for the claws and for the flip servo. Then, when it calls the update function, it will move the servos to the correct position based on the state it is in.
36+
37+
Unfortunately, you will not be able to use this code but use it as an **example**
38+
39+
The parts of this code include:
40+
41+
The enums, which control and operate the states
42+
43+
Variables that contain the states
44+
45+
The constructor (including my own initialize function)
46+
47+
Functions that set the variables correctly (these are needed because it could be confusing to just set the variable differently in the program)
48+
49+
The update function which will use a switch statement to control the claw and flip servo using my own commands
50+
51+
### Private Variables/Functions
52+
53+
Private variables are variables that can only be used inside the class they are defined within. This allows for more code security so you don't accidentally mess something up. For instance, if you have a class that is for calculating ticks per inch, you don't want to accidentally change the ticks per inch variable in the main program and instead make that var private.
54+
55+
As for public variables, these are variables that can be used outside the class they are defined within. This allows for more flexibility in the code, but also makes it easier to mess up. For instance, if you have a class that is for calculating ticks per inch, you want to be able to access the variables used for calculating ticks per inch in the main program.
56+
57+
### Static Variables/Functions
58+
59+
Static variables are variables that can be shared and used in different classes at any time. A very good example of when you would use this is if you are using a class to store positions for a servo, you would want `static` variables for the positions so you can access them in the main program. This is also true for functions, if you have a function that is used in multiple classes, you would want to make it static so you can access it in any other program you want to.
60+
61+
When using FTC Dash, the variables must be static, or they will not be able to be accessed in the dashboard.
62+
63+
### Class Functions
64+
65+
Functions inside classes are one of the most important parts of the class. These control the overall function of the class and allow you to call methods using the class.
66+
67+
Example:
68+
69+
```java
70+
class Person {
71+
String name;
72+
int age;
73+
74+
// constructor
75+
public Person(String name, int age) {
76+
this.name = name;
77+
this.age = age;
78+
}
79+
80+
// function to get the name
81+
public String getName() {
82+
return name;
83+
}
84+
85+
// function to get the age
86+
public int getAge() {
87+
return age;
88+
}
89+
}
90+
```
91+
92+
In this example, getName() returns a String of name, and getAge() returns an int of age. In this way, you could also have `void` functions that do not return anything, but instead do something behind the scenes.
93+
94+
### Class Inheritance
95+
96+
Inheritance is a way to create a new class based on an existing class. The new class inherits the properties and methods of the existing class, allowing for code reuse and organization. Inheritance is a key feature of object-oriented programming (OOP) and helps create a hierarchical structure of classes.
97+
98+
In the context of FTC, you might create a base class for a robot, and an inherited class for the autonomous part of it.
99+
100+
For example, you could create a base class called `Robot` that contains common properties and methods for all robots, such as `drive()`, `turn()`, and `stop()`. Then, you could create a subclass called `AutonomousRobot` that inherits from the `Robot` class and adds specific functionality for autonomous operations, such as `followLine()` or `avoidObstacle()`. Inheritance is denoted by the `extends` keyword.
101+
102+
### Class Extension
103+
104+
Class extension is a way to use all functions of one class in another class. This is useful when you are creating complex system architectures and want to use similar functions in multiple classes. This is approximately the same as class inheritance, but is more commonly used in FTC.
105+
106+
Specifically in FTC, every OpMode must `extends OpMode or LinearOpMode` (preference to LinearOpMode). This allows you to use all the functions of the OpMode class in your own OpMode. This is required because the OpMode class contains all the functions needed to run the robot.
107+
108+
### Class Initialization
109+
110+
Class initialization allows you to create a new instance of the class. This is done using the `new` keyword. For example, if you have a class called `Person`, you can create a new instance of the class using `Person bob = new Person("bob", 29);`. This creates a new instance of the `Person` class and assigns it to the variable `bob`.
111+
112+
You need to make sure that the class is initialized before you use it and that you are using the correct class instance when using multiple class instances.
113+
114+
### Class Variables
115+
116+
Class variables are variables that are shared in the instance of the class. This is most useful when you are using classes that contain HardwareDevices. It allows you to call specific motors or servos inside the class without having to create a new instance of the class.
117+
118+
### Abstract Classes
119+
120+
Abstract classes are classes that cannot be instantiated. This means that you cannot create a new instance of the class. This is useful when you want to create a base class that contains common properties and methods, but you do not want to create an instance of the class. Instead, you create a subclass that inherits from the abstract class and implements the abstract methods.
121+
122+
For instance, if you have a class called `Person`, you could create an abstract class called `AbstractPerson` that contains common properties and methods, but cannot be instantiated. Then, you could create a subclass called `Student` that inherits from the `AbstractPerson` class and implements the abstract methods such as `eat` or `sleep`.
123+
124+
#### Overriding Classes/Functions
125+
126+
When you create an abstract class, the functions must be overridden in the subclass. This means that you must create a new implementation of the function in the subclass. This is useful when you want to create a base class that contains common properties and methods, but you want to create a new implementation of the function in the subclass.
127+
128+
For instance, if you had a robot class, you could create a subclass called `AutonomousRobot` that overrides the `drive()` function to create a new (autonomous) implementation of the same function.
129+
130+
### Class Example
131+
132+
```java
133+
abstract class Person{
134+
String name;
135+
int age;
136+
137+
// constructor
138+
public Person(String name, int age) {
139+
this.name = name;
140+
this.age = age;
141+
}
142+
143+
// abstract function
144+
public abstract void eat();
145+
public abstract void sleep();
146+
public abstract void calculateAge();
147+
}
148+
149+
class Student extends Person {
150+
String school;
151+
152+
// Constructor
153+
public Student(String name, int age, String school) {
154+
super(name, age); // Calls the superclass (Person) constructor
155+
this.school = school;
156+
}
157+
158+
// Implementing abstract methods
159+
@Override
160+
public void eat() {
161+
System.out.println(name + " is eating in the cafeteria.");
162+
}
163+
164+
@Override
165+
public void sleep() {
166+
System.out.println(name + " is sleeping after studying.");
167+
}
168+
169+
@Override
170+
public void calculateAge() {
171+
System.out.println(name + " is " + age + " years old.");
172+
}
173+
}
174+
```
175+
176+
FTC example [here](external-hardware-classes.md)

Writerside/topics/Configuration.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Configuration
2+
3+
A configuration on your robot is how your robot will know where all of your devices are hooked up to the control and expansion hub.
4+
5+
1. Press on the three dots in the corner of the driver station or driver phone.
6+
2. Select the configuration option.
7+
3. If this is your first time, hit the **scan** button to find your control and expansion hub, as well as any connected cameras.
8+
4. A warning will appear indicating that it will override anything not saved on the driver station. Proceed if there is nothing saved.
9+
5. Access the control hub or expansion hub portal.
10+
6. Set up all of your hardware devices. These are defined in your code as Strings.
11+
7. Select the type of device for each hardware device.
12+
8. Copy the exact name from the code into the configuration menu.
13+
9. Complete these steps for each device.
14+
10. Save the configuration and give it a name (e.g., your team number).
15+
11. Activate the configuration.
16+
12. Select your opMode.
17+
13. Press the init button.
18+
14. Press the start button to start the robot.
19+
20+
21+
Once you have done this a few times, I would recommend switching to my ConfigCreator, located [here](https://gramgra07.github.io/GentrifiedAppsUtil/config-creator.html)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Driver Station Walkthrough
2+
3+
The driver station is the app that you will use to control your robot. It is a very important part of the robot, as it allows you to control the robot and see the telemetry from the robot.
4+
5+
## What is the Driver Station?
6+
7+
It is an android device that connects to the robot control hub via and allows you to control the robot with gamepads. It also reports telemetry so you can see potential errors with your bot.
8+
9+
![DS+.png](../../images/DSPlus.png)

Writerside/topics/Enums.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Enums
2+
3+
Enums are a way of creating a list of constants that can be used in a program. For example, you could create an Enum of fruits and have it contain apples, oranges, and bananas. Another example could be types of cars, you could have a list of cars that are sedans, trucks, and SUVs.
4+
Enums are a variable that is defined by the user, and has a list of constants the user defines.
5+
In this implementation, we use Enums commonly named states, or autonomousStates.
6+
```java
7+
enum States {
8+
STATE1,
9+
STATE2,
10+
STATE3,
11+
STATE4,
12+
STATE5,
13+
STOP,
14+
}
15+
```
16+
In the case of autonomous, states could be things like drive forward, turn left, turn right, raise arm, etc.
17+
These enums provide an advantage because they are easy to read and understand in comparison to just telling the robot exactly what to do when. It can also wait for specific input from the robot, which might be harder to implement with just hard coding autonomous.
18+

Writerside/topics/Functions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Functions
2+
3+
Functions are statements to make the code run one part when you "call" the function. It is like calling a whole new section of the code. This is useful to have the code execute specific instructions. This is useful to tell the code to update something or to set a value to a variable. You can also set parameters that are localized variables. A local variable can only be used in that function. Parameters are very useful to help us define and change local variables inside the function.
4+
5+
* What does a function look like?
6+
7+
```java
8+
public void imaginaryFunction(){
9+
//code
10+
}
11+
```
12+
13+
* What about parameters?
14+
15+
```java
16+
public void imaginaryFunction2(int hi, boolean hello){
17+
if (hello == true){
18+
//do something
19+
int hi2=hi+1;
20+
}
21+
}
22+
```
23+
24+
* What about calling a function?
25+
26+
```java
27+
imaginaryFunction(6,false);
28+
```
29+
30+
* Returning values?
31+
32+
```java
33+
public int imaginaryFunction3(int hi, boolean hello){
34+
if (hello == true){
35+
//do something
36+
int hi+=1;
37+
return hi;
38+
}
39+
}
40+
```
41+
42+
You will see that this is saying public int, you use void if you are returning nothing, and the proper variable type if you are returning something. This would be called as, `telemetry.addData("Number",String(imaginaryFunction3(9,true)))`
43+
44+
## Why use functions?
45+
46+
Functions are convenient when you are running a code block multiple times, it allows you to condense it and reduce mistakes in the process of copying and pasting.
47+
48+
## What about Override functions?
49+
50+
Override functions are functions that are already defined in the code, and you are changing them to fit your needs. This is useful when you are using a library, and you want to change the way it works.
51+
52+
More on this [later](Classes.md)!

0 commit comments

Comments
 (0)