Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit fefa626

Browse files
committed
Adding a 'learning' bot
1 parent 6b137c7 commit fefa626

File tree

8 files changed

+341
-1
lines changed

8 files changed

+341
-1
lines changed

PhoenixCode/build.gradle

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// build.gradle in TeamCode
3+
//
4+
// Most of the definitions for building your module reside in a common, shared
5+
// file 'build.common.gradle'. Being factored in this way makes it easier to
6+
// integrate updates to the FTC into your code. If you really need to customize
7+
// the build definitions, you can place those customizations in this file, but
8+
// please think carefully as to whether such customizations are really necessary
9+
// before doing so.
10+
11+
12+
// Custom definitions may go here
13+
14+
// Include common definitions from above.
15+
apply from: '../build.common.gradle'
16+
apply from: '../build.dependencies.gradle'
17+
18+
dependencies {
19+
implementation project(':FtcRobotController')
20+
implementation project(':RobotLibrary')
21+
implementation project(':Vision')
22+
implementation project(':Path')
23+
24+
testImplementation(platform('org.junit:junit-bom:5.7.0'))
25+
testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.0')
26+
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
27+
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.0')
28+
testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.0"
29+
// We don't need Team two depending on Team one's code. Bad Things (tm) happen
30+
// implementation project(path: ':TechnoOneCode')
31+
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
32+
implementation 'org.apache.commons:commons-math3:3.6.1'
33+
implementation 'com.acmerobotics.roadrunner:core:0.5.4'
34+
implementation 'org.openftc:easyopencv:1.5.0'
35+
implementation 'com.acmerobotics.dashboard:dashboard:0.4.3'
36+
//implementation 'com.github.technototes:TechnoLib:0.9.11'
37+
}
38+
39+
tasks.withType(Test) {
40+
useJUnitPlatform()
41+
}
5.89 KB
Binary file not shown.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!-- Note: the actual manifest file used in your APK merges this file with contributions
4+
from the modules on which your app depends (such as FtcRobotController, etc).
5+
So it won't ultimately be as empty as it might here appear to be :-) -->
6+
7+
<!-- The package name here determines the package for your R class and your BuildConfig class -->
8+
<manifest
9+
package="org.firstinspires.ftc.teamcode"
10+
xmlns:android="http://schemas.android.com/apk/res/android">
11+
<application/>
12+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
## TeamCode Module
2+
3+
Welcome!
4+
5+
This module, TeamCode, is the place where you will write/paste the code for your team's
6+
robot controller App. This module is currently empty (a clean slate) but the
7+
process for adding OpModes is straightforward.
8+
9+
## Creating your own OpModes
10+
11+
The easiest way to create your own OpMode is to copy a Sample OpMode and make it your own.
12+
13+
Sample opmodes exist in the FtcRobotController module.
14+
To locate these samples, find the FtcRobotController module in the "Project/Android" tab.
15+
16+
Expand the following tree elements:
17+
FtcRobotController / java / org.firstinspires.ftc.robotcontroller / external / samples
18+
19+
A range of different samples classes can be seen in this folder.
20+
The class names follow a naming convention which indicates the purpose of each class.
21+
The full description of this convention is found in the samples/sample_convention.md file.
22+
23+
A brief synopsis of the naming convention is given here:
24+
The prefix of the name will be one of the following:
25+
26+
* Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure
27+
of a particular style of OpMode. These are bare bones examples.
28+
* Sensor: This is a Sample OpMode that shows how to use a specific sensor.
29+
It is not intended as a functioning robot, it is simply showing the minimal code
30+
required to read and display the sensor values.
31+
* Hardware: This is not an actual OpMode, but a helper class that is used to describe
32+
one particular robot's hardware devices: eg: for a Pushbot. Look at any
33+
Pushbot sample to see how this can be used in an OpMode.
34+
Teams can copy one of these to create their own robot definition.
35+
* Pushbot: This is a Sample OpMode that uses the Pushbot robot structure as a base.
36+
* Concept: This is a sample OpMode that illustrates performing a specific function or concept.
37+
These may be complex, but their operation should be explained clearly in the comments,
38+
or the header should reference an external doc, guide or tutorial.
39+
* Library: This is a class, or set of classes used to implement some strategy.
40+
These will typically NOT implement a full OpMode. Instead they will be included
41+
by an OpMode to provide some stand-alone capability.
42+
43+
Once you are familiar with the range of samples available, you can choose one to be the
44+
basis for your own robot. In all cases, the desired sample(s) needs to be copied into
45+
your TeamCode module to be used.
46+
47+
This is done inside Android Studio directly, using the following steps:
48+
49+
1) Locate the desired sample class in the Project/Android tree.
50+
51+
2) Right click on the sample class and select "Copy"
52+
53+
3) Expand the TeamCode / java folder
54+
55+
4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste"
56+
57+
5) You will be prompted for a class name for the copy.
58+
Choose something meaningful based on the purpose of this class.
59+
Start with a capital letter, and remember that there may be more similar classes later.
60+
61+
Once your copy has been created, you should prepare it for use on your robot.
62+
This is done by adjusting the OpMode's name, and enabling it to be displayed on the
63+
Driver Station's OpMode list.
64+
65+
Each OpMode sample class begins with several lines of code like the ones shown below:
66+
67+
```
68+
@TeleOp(name="Template: Linear OpMode", group="Linear Opmode")
69+
@Disabled
70+
```
71+
72+
The name that will appear on the driver station's "opmode list" is defined by the code:
73+
``name="Template: Linear OpMode"``
74+
You can change what appears between the quotes to better describe your opmode.
75+
The "group=" portion of the code can be used to help organize your list of OpModes.
76+
77+
As shown, the current OpMode will NOT appear on the driver station's OpMode list because of the
78+
``@Disabled`` annotation which has been included.
79+
This line can simply be deleted , or commented out, to make the OpMode visible.
80+
81+
82+
83+
## ADVANCED Multi-Team App management: Cloning the TeamCode Module
84+
85+
In some situations, you have multiple teams in your club and you want them to all share
86+
a common code organization, with each being able to *see* the others code but each having
87+
their own team module with their own code that they maintain themselves.
88+
89+
In this situation, you might wish to clone the TeamCode module, once for each of these teams.
90+
Each of the clones would then appear along side each other in the Android Studio module list,
91+
together with the FtcRobotController module (and the original TeamCode module).
92+
93+
Selective Team phones can then be programmed by selecting the desired Module from the pulldown list
94+
prior to clicking to the green Run arrow.
95+
96+
Warning: This is not for the inexperienced Software developer.
97+
You will need to be comfortable with File manipulations and managing Android Studio Modules.
98+
These changes are performed OUTSIDE of Android Studios, so close Android Studios before you do this.
99+
100+
Also.. Make a full project backup before you start this :)
101+
102+
To clone TeamCode, do the following:
103+
104+
Note: Some names start with "Team" and others start with "team". This is intentional.
105+
106+
1) Using your operating system file management tools, copy the whole "TeamCode"
107+
folder to a sibling folder with a corresponding new name, eg: "Team0417".
108+
109+
2) In the new Team0417 folder, delete the TeamCode.iml file.
110+
111+
3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder
112+
to a matching name with a lowercase 'team' eg: "team0417".
113+
114+
4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that contains
115+
package="org.firstinspires.ftc.teamcode"
116+
to be
117+
package="org.firstinspires.ftc.team0417"
118+
119+
5) Add: include ':Team0417' to the "/settings.gradle" file.
120+
121+
6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project""
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Place your sound files in this folder to use them as project resources.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
2+
<!--
3+
This file can provide additional camera calibration settings beyond those built into the SDK itself.
4+
Each calibration is for a particular camera (indicated by USB vid & pid pair) and a particular
5+
capture resolution for the camera. Note: it is very important when capturing images used to calibrate
6+
a camera that the image acquisition tool can actually control this capture resolution within the camera
7+
itself and that you use this setting correctly. Many image acquistion tools do not in fact provide
8+
this level of control.
9+
10+
Beyond simply providing additional, new camera calibrations, calibrations provided herein can
11+
*replace/update* those that are builtin to the SDK. This matching is keyed, of course, by the
12+
(vid, pid, size) triple. Further, if such a calibration has the 'remove' attribute with value 'true',
13+
any existing calibration with that key is removed (and the calibration itself not added).
14+
15+
Calibrations are internally processed according to aspect ratio. If a format is requested in a size
16+
that is not calibrated, but a calibration does exist for the same aspect ratio on the same camera,
17+
then the latter will be scaled to accommodate the request. For example, if a 640x480 calibration
18+
is requested but only a 800x600 calibration exists for that camera, then the 800x600 is scaled
19+
down to service the 640x480 request.
20+
21+
Further, it is important to note that if *no* calibrations exist for a given camera, then Vuforia
22+
is offered the entire range of capture resolutions that the hardware can support (and it does its
23+
best to deal with the lack of calibration). However, if *any* calibrations are provided for a camera,
24+
then capture resolutions in those aspect ratios supported by the camera for which any calibrations
25+
are *not* provided are *not* offered. Thus, if you calibrate a camera but fail to calibrate all
26+
the camera's supported aspect ratios, you limit the choices of capture resolutions that Vuforia can
27+
select from.
28+
29+
One image acquisition program that supports control of camera capture resolution is YouCam 7:
30+
https://www.cyberlink.com/products/youcam/features_en_US.html
31+
32+
Programs that can process acquired images to determine camera calibration settings include:
33+
https://www.3dflow.net/3df-zephyr-free/ (see "Utilities/Images/Launch Camera Calibration" therein)
34+
http://graphics.cs.msu.ru/en/node/909
35+
Note that the type of images that must be acquired in order to calibrate is specific to the
36+
calibration software used.
37+
38+
The required contents are illustrated here by example. Note that for the attribute names, both the
39+
camelCase or the underscore_variations are supported; they are equivalent. The attributes for
40+
each Calibration are as follows:
41+
42+
size (int pair): space separated camera resolution (width, height).
43+
focalLength (float pair): space separated focal length value.
44+
principalPoint (float pair): space separated principal point values (width, height).
45+
distortionCoefficients (an 8-element float array): distortion coefficients in the following form
46+
(r:radial, t:tangential): [r0, r1, t0, t1, r2, r3, r4, r5]
47+
see https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html
48+
49+
The examples here are commented out as the values are built-in to the FTC SDK. They serve instead
50+
here as examples on how make your own.
51+
52+
-->
53+
<Calibrations>
54+
55+
<!-- ======================================================================================= -->
56+
57+
<!-- Microsoft Lifecam HD 3000 v1, Calibrated by PTC using unknown tooling -->
58+
<!-- <Camera vid="Microsoft" pid="0x0779">
59+
<Calibration
60+
size="640 480"
61+
focalLength="678.154f, 678.17f"
62+
principalPoint="318.135f, 228.374f"
63+
distortionCoefficients="0.154576f, -1.19143f, 0f, 0f, 2.06105f, 0f, 0f, 0f"
64+
/>
65+
</Camera> -->
66+
67+
<!-- ======================================================================================= -->
68+
69+
<!-- Microsoft Lifecam HD 3000 v2, Calibrated by PTC using unknown tooling -->
70+
<!-- <Camera vid="Microsoft" pid="0x0810">
71+
<Calibration
72+
size="640 480"
73+
focalLength="678.154f, 678.17f"
74+
principalPoint="318.135f, 228.374f"
75+
distortionCoefficients="0.154576f, -1.19143f, 0f, 0f, 2.06105f, 0f, 0f, 0f"
76+
/>
77+
</Camera> -->
78+
79+
<!-- ======================================================================================= -->
80+
81+
<!-- Logitech HD Webcam C310, Calibrated by by Robert Atkinson, 2018.05.30 using 3DF Zephyr -->
82+
<!-- <Camera vid="Logitech" pid="0x081B">
83+
<Calibration
84+
size="640 480"
85+
focalLength="821.993f, 821.993f"
86+
principalPoint="330.489f, 248.997f"
87+
distortionCoefficients="-0.018522, 1.03979, 0, 0, -3.3171, 0, 0, 0"
88+
/>
89+
90+
<Calibration
91+
size="640 360"
92+
focalLength="715.307f, 715.307f"
93+
principalPoint="319.759f, 188.917f"
94+
distortionCoefficients="-0.0258948, 1.06258, 0, 0, -3.40245, 0, 0, 0"
95+
/>
96+
</Camera> -->
97+
98+
<!-- ======================================================================================= -->
99+
100+
<!-- Logitech HD Pro Webcam C920, Calibrated by Robert Atkinson, 2018.05.30 using 3DF Zephyr -->
101+
<!-- <Camera vid="Logitech" pid="0x082D">
102+
103+
<Calibration
104+
size="640 480"
105+
focalLength="622.001f, 622.001f"
106+
principalPoint="319.803f, 241.251f"
107+
distortionCoefficients="0.1208, -0.261599, 0, 0, 0.10308, 0, 0, 0"
108+
/>
109+
110+
<Calibration
111+
size="800 600"
112+
focalLength="775.79f, 775.79f"
113+
principalPoint="400.898f, 300.79f"
114+
distortionCoefficients="0.112507, -0.272067, 0, 0, 0.15775, 0, 0, 0"
115+
/>
116+
117+
<Calibration
118+
size="640 360"
119+
focalLength="463.566f, 463.566f"
120+
principalPoint="316.402f, 176.412f"
121+
distortionCoefficients="0.111626 , -0.255626, 0, 0, 0.107992, 0, 0, 0"
122+
/>
123+
124+
<Calibration
125+
size="1920, 1080"
126+
focalLength="1385.92f , 1385.92f"
127+
principalPoint="951.982f , 534.084f"
128+
distortionCoefficients="0.117627, -0.248549, 0, 0, 0.107441, 0, 0, 0"
129+
/>
130+
131+
<Calibration
132+
size="800, 448"
133+
focalLength="578.272f , 578.272f"
134+
principalPoint="402.145f , 221.506f"
135+
distortionCoefficients="0.12175, -0.251652 , 0, 0, 0.112142, 0, 0, 0"
136+
/>
137+
138+
<Calibration
139+
size="864, 480"
140+
focalLength="626.909f , 626.909f"
141+
principalPoint="426.007f , 236.834f"
142+
distortionCoefficients="0.120988, -0.253336 , 0, 0, 0.102445, 0, 0, 0"
143+
/>
144+
145+
</Camera> -->
146+
147+
<!-- ======================================================================================= -->
148+
149+
<!-- Logitech HD Webcam C270, Calibrated by Noah Andrews, 2019.03.13 using 3DF Zephyr -->
150+
<!--<Camera vid="Logitech" pid="0x0825">
151+
<Calibration
152+
size="640 480"
153+
focalLength="822.317f, 822.317f"
154+
principalPoint="319.495f, 242.502f"
155+
distortionCoefficients="-0.0449369, 1.17277, 0, 0, -3.63244, 0, 0, 0"
156+
/>
157+
</Camera> -->
158+
159+
<!-- ======================================================================================= -->
160+
161+
</Calibrations>

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include ':FtcRobotController'
2-
include ':OspreyCode', ':SeagullCode'
2+
include ':OspreyCode', ':SeagullCode', ':PhoenixCode'
33
include ':RobotLibrary'
44
include ':Vision'
55
include ':Path'

0 commit comments

Comments
 (0)