---
# System prepended metadata

title: FRC9427工程筆記
tags: [FRC2024]

---


##### tags:`FRC9427`

# FRC9427 Engineering book

## Team introduce
### about us:
![image](https://hackmd.io/_uploads/B1VUcxzha.png =50%x)![image](https://hackmd.io/_uploads/H1NItgM3a.png =50%x)![image](https://hackmd.io/_uploads/HyEKFgGha.png =50%x)![image](https://hackmd.io/_uploads/rkyntlGha.png =50%x)![image](https://hackmd.io/_uploads/r1f1cxf2a.png =50%x)![image](https://hackmd.io/_uploads/BkMGcgf3p.png =50%x)









## Game Field Analyze
### Zone:

![zone](https://hackmd.io/_uploads/Hky1pYdip.png)

Importance Level: :star::star::star: 
reason: Zone is the primary criterion for penalties. Although it is crucial, as long as no rules are violated, there will be no consequences. In the starting area, points are awarded.

:::info
* AMP ZONE: The AMP Zone is an expansive area measuring approximately 10 feet 10 inches in length and 1 foot 5¾ inches in width (approximately 330 centimeters by 45 centimeters). It is characterized by its infinite vertical space and is demarcated by AMP ZONE walls, guardrails, alliance walls, and color tape specific to the affiliated alliance. The AMP ZONE includes the color tape as well.
* ROBOT STARTING ZONE：The Robot Starting Area is an expansive space measuring approximately 6 feet 4 inches in width and 23 feet 8 inches in length (approximately 193 centimeters by 721 centimeters). It is bounded by alliance walls, the AMP ZONE, the opponent’s sound source area, and black tape. The robot starting area includes the black tape but excludes the tape from the AMP ZONE and the sound source area.
* SOURCE AREA：The Sound Source Area is an expansive space measuring approximately 5 feet ¾ inch in width and 15 feet 10½ inches in length (approximately 154 centimeters by 484 centimeters). It is bounded by the sound source area walls, the carpet edge, and color tape specific to the affiliated alliance. The sound source area includes the color tape as well.
* SOURCE ZONE：The Sound Source Area is an expansive space bounded by the sound source area walls, the opponent’s alliance walls, and color tape specific to the affiliated alliance. The sound source area is 1 foot 6¾ inches deep (~48 centimeters) with respect to the sound source wall and includes the alliance-colored tape.
:::

### AMP:
![image](https://hackmd.io/_uploads/BkiseOdja.png)
**score**
auto:2 point
telo:1 point
Importance Level: :star::star::star::star::star:
reason:The reason is that it’s the main way to activate the speaker bonus, as well as the cooperative button and the primary scoring method.
:::info
* 手動時投入兩個note後人類玩家可以決定什麼時候要增加sperker的分數，從2分提高到5分，增加分數只能維持10秒(會延遲3秒)，13秒過後需投入2個note才能再次增加speaker的分數
* 深 3⅞英寸（约 10 厘米）、高 1 英尺 6 英寸（约 46 厘米）、寬 2 英尺（约 61 厘米）的垂直口袋。口袋底部距離地毯 2 英尺 2 英寸（约 66 厘米）。每个擴音器距最近的聯盟牆 4 英尺 1½英寸（约126 厘米）
:::

### speaker:
![image](https://hackmd.io/_uploads/ryvxm_uja.png)

**score**
Importance Level:star::star::star::star::star:
Reason: Regardless of manual or automatic, both have a high score of 5 points. It is very important for teams that are heavy on manual or automatic.
Auto: 5 points
telo: 2 or 5 points
:::info
* 是手動分數的主要來源(從丟note到計算分數會有些許的延遲，大約2秒)
* 揚聲器開口的最低邊緣距離地毯約198公分，開口的最高邊緣距離地毯約21公分。開口寬約105公分，並向場地內延伸約46公分。開口平面與地毯成14度的向上夾角。
* 低音炮是一個 6 面元件，位於每個揚聲器下方的中心位置，並靠著聯盟牆。低音炮高約94公分，垂直面板高約21公分。低音炮伸出聯盟牆約92公分。
:::

### stage:
![image](https://hackmd.io/_uploads/S1WNbd_sp.png)
**score**
into the stage zone: 1 point 
Climbing the chain: 3 points
if there is a note on the microphone above: 4 points (an extra +2 points if there is a teammate on the chain) 
Importance Level: :star::star: 
Reason: Although the score is high, there is a limit and the uncertainty is high, so the ranking will be behind the amp and speaker.
:::info
* 每个舞台都是三腳支撐結構，距離相應的聯盟牆 10 英尺 1 英寸（约 307 厘米）。每个舞台由桁架脚、桁架段、桁架連接處、鋁框架和 PC 板組成。舞台的中央核心懸掛在桁架上，鋁製表面距離地毯2 英尺4¼英寸（约72厘米）。不過，某些特徵會减少舞台核心下的有效間隙。間隙最小的地方是桁架腳上方的聚碳酸酯墊板，實際間隙為 2 英尺 3⅞英寸（約 71 厘米）

* 如圖 Figure 5- 9 所示，3 條鍊條分别稱為「舞台左」(STAGE Left)、「舞台右」(STAGE Right)和「中央舞台」(CenterSTAGE)，横跨了每个舞台桁架支柱之間的空間。鍊條通過一個扣環、吊環螺栓和地毯上方4 英尺（约122厘米）處的墊板連接到每個支柱上。鍊條下垂使其最低點距離地毯 2 英尺 4¼英寸（約72 厘米），鍊條距離舞台核心面 1 英尺 4⅝英寸（約 42 厘米）。

:::

### trap:
![image](https://hackmd.io/_uploads/rJYLbd_op.png)
**score**
Throwing note into the trap: 5 points
Importance Level: :star:
Reason: It’s too difficult. It’s only worth five points, but it requires the creation of an additional mechanism to deal with its uncertainty. The cost-effectiveness is not high.
* 每個trap只能有一個note
::: info
* 舞台陷阱區(TRAP)每个開口的底部距離地毯 4 英尺 8½英寸（约 144 厘米）。陷阱區是由圖Figure5- 10中突出顯示的 4 個方形管段和覆蓋該空间前后的塑料板所圍成的空间

:::
### source:
![image](https://hackmd.io/_uploads/HJXG-dusT.png)

Importance Level: :star: :star: :star: :star: :star: 
Reason: It’s too difficult. It only has five points, but it requires an additional mechanism to deal with its uncertainty. The cost-effectiveness is not high.
:::info
* 音源區域墙，即音源面向場地的一面，將音源區域與音源區隔開。每个音源都有一个寬 6 英尺 3¼英寸（约 191 厘米）、高 6 英寸（约15 厘米）的開口，音符通過該开開口進入場内；開口底部距離地毯 3 英尺¾英寸（约 93 厘米）。一个 50 度傾斜的通道，稱為滑道(CHUTE)，通向音源區域牆上的開口。滑道延伸至音源區域，其在音源區域開口的底邊距離地毯4 英尺4¾英寸（约134厘米）。
:::
### map note
![image](https://hackmd.io/_uploads/ryzHG_uip.png)
Importance Level: :star: :star:
Reason: The note on the map is the main source of automatic scores, but in a 2:30 match, it only accounts for 15 seconds. 
The score is also limited, so we think its importance is lower than manual.
### completion
* Make a ranking based on the above analysis
1. AMP
1. source
1. speaker
---
4. zone
---
5. stage
6. map note
---
7. trap
---
We have taken the above 7 items into consideration.
We should prioritize AMP, Speaker, and Source for prototyping.


## note Analyze:

### Compression amount:
* We measured that the maximum compression amount that note can pass is 0.5in
 ![38704](https://hackmd.io/_uploads/H1rTc-C9a.jpg =80%x)


### inner and outer diameter:
* Note: The NOTE is an orange foam ring, with an inner diameter of 10 inches (about 25 cm), an outer diameter of 1 foot 2 inches (about 36 cm), and a thickness of 2 inches (about 5 cm). The weight of one note is 8.3±0.2 ounces (about 235.3±6 grams).
![螢幕擷取畫面 2024-02-13 160803](https://hackmd.io/_uploads/SkYYmo_j6.png)

## robot Analyze

### car size:
* The initial height of the vehicle must not exceed 48 inches.
* The extension of the vehicle must not exceed 12 inches.
* The vehicle body must reserve a 14*14 inch space for the note.
* The weight must not exceed 125 pounds.
* The initial width of the vehicle must not exceed 120 inches.





After analysis, we decided to design the vehicle width to 25*25in
reason: 
1. Can accommodate the next note.
1. The mechanism can be made to match the width of the AMP.
2. The smaller the car, the higher the mobility on the field.


### decision making body
* Because we mentioned earlier that there are three most important gamefiled in the entire game
1. speaker
2. amp
3. source

Due to limited time, we plan to build a robot around the goal of a cycle from source --> amp --> speaker. Therefore, our robot should have two elements:
1.Shooter
2.Arm
We will build the robot prototype around these two elements.



## shooter update (before the Simulation Race)
### 1st update
2024/1/20:
:::success
design
:::
design: We use the onshape to design the shooter  the first generation utilized vertically aligned rubber wheels to launch musical notes. 
This design had two primary advantages: 
1. firstly, the vertical arrangement of the wheels allowed for greater compression of the notes, resulting in longer range 
2. secondly, having both upper and lower wheels facilitated better chain connection.

![image](https://hackmd.io/_uploads/SJEKixAqT.png =40%x)+![image](https://hackmd.io/_uploads/rkInkWC5T.png =40%x)==
![LINE_ALBUM_shooter_240205_3](https://hackmd.io/_uploads/rkQ_gWRcp.jpg =500x)
* test video
{%youtube PO3Iq1R3pPI %}

problem:
1. It just can shoot 
2. Insufficient compression

### 2nd update
### 2024/1/25:
:::info
test
:::
#### design: 
We made two changes in the second generation:
1. We first tested the compression amount with a dense board that has multiple compression amounts. We finally determined the upper and lower compression amount to be 0.5in. We used this compression amount for testing, and the results met our expectations.
2. We added a board machine above the trigger to collect notes. We set the position of the board machine parallel to the rubber wheel for easy note collection.

![38704](https://hackmd.io/_uploads/H1rTc-C9a.jpg =80%x)
* After multiple tests, we finally determined that after deducting the compression amount of the rubber wheel width, there are 0.5 inches left.
![image](https://hackmd.io/_uploads/HkolkfRc6.png =40%x)------------------------>![LINE_ALBUM_2024.2.5_240205_1](https://hackmd.io/_uploads/HyqxUzC5p.jpg =40%x)
* After testing many compression amounts, we determined that it is 0.5 inches, and using larger rubber wheels will shoot the furthest.


* And the final we can shoot further
{%youtube _jM67115kIs %}


* another one
{%youtube 8kX1T-yvIoo %}

* the others
{%youtube AAvec6jCMTM %}

* ==and the four larger rubber wheels are the furthest==

problem:It cant shoot on the speaker and it is too heavy


### 3rd update:
2024/2/1:
:::warning
important update
:::
design: 
We have decided not to use the second-generation model and have made the following changes.
1. First, we moved the rubber wheel to the base plate in order to increase its compression amount.
2. Secondly, this design can significantly reduce the weight of the mechanism itself.
3. Next, it solves our motor connection problem. This design can directly use a direct-drive motor
![image](https://hackmd.io/_uploads/rkiAMgzi6.png =30%x)+![image](https://hackmd.io/_uploads/SJ5f7xfjT.png =30%x)+![image](https://hackmd.io/_uploads/BkoLXlGj6.png =30%x)==
![LINE_ALBUM_2024130 （工程筆記製作，shooter三代改版，BP製作，程式測試）_240130_1](https://hackmd.io/_uploads/BJXpQgGsp.jpg)

* Under the shooter we contact them for NEO motor
![37853](https://hackmd.io/_uploads/H13i-xzsp.jpg)

* We have added a trigger to it and the production is completed. 
![image](https://hackmd.io/_uploads/S19_PgfiT.png)

* shooter test video 
{%youtube 6TbmeD52mkc %}
* We found that relying solely on the power of four NEO motors was insufficient. Therefore, we added a trigger to increase the initial velocity of the note.
* Elevation Angle Test Video
{%youtube  zbIOlHrxoxQ %}
* ==Finally we can shoot into the speaker==


     
### 4th update:
2024/2/3
Due to significant updates to Swerve, we can mount our shooter on the machine and add a baffle. 
![LINE_ALBUM_shooter_240205_1](https://hackmd.io/_uploads/r1EjYpSoa.jpg)



### 5th update:
2024/2/5
:::danger
debug
:::

* In the testing process, we found that the note cannot enter Shooter as expected 

* problem: The upper trigger will stick the note on the top of the trigger during the collection process.
* test bug video
{%youtube KJqtsJULXUQ%}


* Solution : After our discussion, we came up with two solutions.

- [x] Extend the length of the existing base plate so that there is space for the note to be collected without being compressed. 
- [x]  Add a wooden board on top of the machine so that when the note comes in, it can be compressed by the upper wooden board to the size of the rear space.
* cause: After considering many factors, we chose the latter.
1. The process of the former is too long, which would waste a lot of time.
1. The former would consume more materials than the latter.
1. The former would obstruct the operation of the arm.
* But actually, the latter also has corresponding disadvantages.
1. The force exerted when the note is ejected will be smaller after it is compressed.
1. The area for collecting notes becomes smaller.

* However after various analyses, we still chose the latter, which has a higher cost-performance ratio.

---------------------------befor -----------------------------------------------------------------after
![LINE_ALBUM_shooter_240205_2](https://hackmd.io/_uploads/Skhkphrip.jpg =40%x)----->![S__10559740](https://hackmd.io/_uploads/HJDb6nrsT.jpg =40%x)

### 6th update
2024/2/13
:::info
upgrade
:::
* During testing, we found that the position of the trigger was still too far forward, so we moved the trigger back one grid and replaced it with a harder rubber wheel.
* Reason for modification : the current position of the trigger tends to reduce the force of the note being shot out after compression. Therefore, we moved the position of the trigger back to one grid to give the note a space to shoot 
![39521](https://hackmd.io/_uploads/SJVM4FOoa.jpg)
* Next, we removed the direct-drive motor and used a 1:4 NEO motor instead. This can make the initial speed of our shooter faster and shoot the note further.
![39528](https://hackmd.io/_uploads/H1J9PFuoa.jpg)

---
## arm update (before Simulation Race)

### 1st update:
2024/1/23
:::success
design
:::
* After the design process, we plan to mount the shooter on an arm with a pivot. After measurement, we set the arm width to 17.5 inches and processed the aluminum square tube.
![39499](https://hackmd.io/_uploads/SJsLUUOja.jpg)



### 2nd update:
2024/1/25
:::info
PID test
:::
* After deciding on the width, we can proceed to install the motor and gears. (The shooter is not yet installed; this is just a temporary prototype for testing.)
 **For the motor, we chose a 3:4:5 neo motor.**
 **As for the gears, we first used a 16:38 small gear and a medium gear.**
 **After calculations, the current gear ratio is 1:142.5.**
![螢幕擷取畫面 2024-02-13 105453](https://hackmd.io/_uploads/rko6qIdjT.png )

* PID test video 
{%youtube b5y5Ry0SJnw %}

* During the PID testing, we encountered some difficulties:
1. Unable to locate the setpoint.
1. The values were erratic.
In the process of solving these issues, we discovered that the NEO Encoder has a range limit of 360 degrees. If the value exceeds 360 degrees, it starts to revert back from 360, which did not meet our expectations. So, we came up with a solution: we set a dead zone at the two extreme values of the 90-degree angle we move, preventing it from exceeding the limit.
* design diagram 
![39502](https://hackmd.io/_uploads/BkODUD_jp.jpg)
* fail PID video
{%youtube NklxKzlXZ1g %}



### 3rd update:
2024/2/3
:::warning
important update
:::
Due to significant updates to Swerve, we can put the arm on our robot

* First Because the original placement method could not support the weight of the shooter with the arm, we added an oblique aluminum square tube on the side to support the entire arm like an arm.

**Diagram**
![39507](https://hackmd.io/_uploads/H1zIgu_j6.jpg)
* Next, we raised the pivot point for two reasons:

1. This allows us to turn a smaller angle to reach the source zone and pick up the note.
2. This allows us to package all the mechanisms into our vehicle body to prevent impact.

![39510](https://hackmd.io/_uploads/r1TNQOOo6.jpg =40%x) --------------->![39511](https://hackmd.io/_uploads/r1_j7uOj6.jpg =40%x)


### 4th update:
2024/2/6
:::info
translates to changing the gear ratio
:::
For the motor, we chose a 4:5:5 neo motor.
As for the gears, we  used a 16:68 small gear and a big gear.
After calculations, the current gear ratio is 1:425.
![39512](https://hackmd.io/_uploads/HysOUu_sT.jpg)



## intake update
### 1st update
2024/12/29-12/31
**After referring to the intake of other teams, we found that this intake can pick up the note on the ground, and this intake will not affect the operation of the shooter.**
https://cad.onshape.com/documents/96f96d068e394fcbe8f6d548/w/ab5f542db5df8c6b2a0ff0c4/e/62887e2c1be3652e6ba45731
**Finally, we use the above CAD file as the prototype to make an institution that can send notes on the ground to the shooter.**
![image](https://hackmd.io/_uploads/rJFtb4w9p.png)
![image](https://hackmd.io/_uploads/r17nEIOj6.png)



### 2nd update
After discussion, we decided not to use intake.
There are two reasons:
1. time
We found that there was not much difference between the time of picking up and shooting the note and going directly to the source.
2. Quantity
There are not many opportunities to use intake. Only when teammates make mistakes in shooting AMP or SPEAKER will they use intake.


## swerve update
### How does we use swerve
In the 2024 FRC season, we chose Swerve drive over tank drive because of its clear advantages in maneuverability. Swerve can quickly adapt to different field layouts, regardless of how they are set up. Compared to tank drive, Swerve has a gentler learning curve as it doesn’t require dealing with the limitations of the drivetrain. Swerve’s agility allows for continuous purposeful movement, whereas tank drive systems might find themselves facing the wrong direction, wasting valuable time. That’s why we chose the Swerve chassis; it allows us to be more agile in the competition.

### 1st update:
 2024/12/15
first swerve Assembly
{%youtube 1h2Cm5swcs4 %}


### 2nd update:
2024/2/3

The processed aluminum cubes arrived today. We also followed the previous analysis to widen the width of the car to 25*25.
**drilling**
![37961](https://hackmd.io/_uploads/B1ToZtPq6.jpg =70%x)
**Assemble**
![37972](https://hackmd.io/_uploads/SyXgQKv96.jpg)
**Finished product**
![38843](https://hackmd.io/_uploads/ryd9XKv9a.jpg =40%x)First generation----->Second generation
 ![37960](https://hackmd.io/_uploads/r1DjXKPca.jpg =40%x)
Change
1. The original chassis is 23 x 23in ------> 25 x 25in
2. Drilled the hole



## programming test


### limelight pid
![40321](https://hackmd.io/_uploads/Skv5WMf36.jpg)
* We found that when shooting the speaker, the robot’s elevation angle will vary with the distance. So, we came up with a calculation method:
By using the absolute coordinates of the limelight + the remaining body and the triangle formed by the shoot points, we can take the tangent to know the elevation angle (the obtained elevation angle still needs to add the angle when the axis returns to zero).

mathematical:<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>θ</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mtext>height</mtext><mtext>distance</mtext></mfrac></mrow><annotation encoding="application/x-tex"></math>
    
    
### Shooter shaft PID

PID Controller Testing and Adjustment Procedure
Objective:
To enable the shaft to reach the target point as quickly as possible while ensuring safety.

#### Procedure Overview:

1. Set the target point to 51.5 degrees with an initial angle of approximately 15 degrees.
2. Begin by adjusting the proportional gain (kp). When close to the target but unable to reach it, introduce integral gain (ki).
3.After accurately reaching the target point, adjust the output range to ensure safety.
#### Testing Process:

1. Initial error is approximately 36.5 degrees. Set kp to 0.01 with a maximum output range of 0.35 to -0.35.
    
2. Test results show reaching around 47 degrees. Due to external conditions unrelated to PID control, adjusting kp alone does not achieve perfect targeting.
    
3. Introduce integral gain ki, initially set to 0.001. However, overshooting occurs due to excessive gain, promptly disabled to prevent machine damage.
    
4. Reduce ki to 0.0001, successfully reaching the target point but with slower speed.
    
5. Gradually increase the output range. Speed does not significantly improve when increased to 4.5, indicating the PID controller's maximum output is not reached.
    
6. Use a dashboard to observe the motor's maximum output, confirming it does not reach the set value.
    
7. Continuously increase kp and ki to ensure maximum output range, eventually setting the maximum output range to 1.
    
#### Conclusion:
Although the test successfully achieved a maximum speed of 1 at the set point, there is room for improvement. Subsequent adjustments to kp may enhance speed.    

## Ultimately generation robot
* this is our last generation robot
![LINE_ALBUM_202426_240223_2](https://hackmd.io/_uploads/HkJzMMI3p.jpg)
    
![LINE_ALBUM_202426_240223_1](https://hackmd.io/_uploads/ryTmzM8np.jpg)
    
* train video 
{%youtube RQZ9WOSUsTA %}


## New Taipei City Simulation Race
### 2024/2/17




## shooter update (after the Simulation Race)


## arm update (after the Simulation Race)
    

    
## Swerve drive
   
In the 2024 FRC season, we chose Swerve drive over tank drive due to its clear advantages, especially in maneuverability and defense. Particularly in the FRC 2024 field, there were many repeated paths for both alliances, necessitating a strategy to counter defense. When facing off against tank drive systems, Swerve robots typically gain the upper hand unless the tank driver possesses significantly higher skills. Compared to tank drive, Swerve has a gentler learning curve as it does not require dealing with the limitations of the drivetrain. Additionally, Swerve's ability to rotate while engaging in defense allows us to simultaneously face opponents and shoot out Notes with our Speaker, which is advantageous against machines without rotating turrets.

In terms of movement, Swerve's flexibility enables continuous purposeful movement, while tank drive systems may find themselves facing the wrong direction, wasting valuable time and rotating to slow down again. Swerve changes this equation, allowing robots to reduce time by swiftly executing the necessary maneuvers.
    

* Because Swerve utilizes 8 motors, the decision on how to structure it is crucial. Here is our architecture:
![41638](https://hackmd.io/_uploads/BkiaSQ326.jpg)
 
* This is our physical Swerve architecture:
![41636](https://hackmd.io/_uploads/SJe2TS72n6.jpg)
    
* We use absolute encoders to record the position of the Swerve and calculate deviations:
![41634](https://hackmd.io/_uploads/H12aH723p.jpg)
```java
    private double m_currentRotation = 0.0;// 當前的旋轉值
    private double m_currentTranslationDir = 0.0;// 當前的平移方向
    private double m_currentTranslationMag = 0.0; // 當前的平移幅度
```
* To avoid unnecessary paths with Swerve's steering wheels, we optimized it to prevent turning beyond 90 degrees, as 135 and 45 are equivalent for Swerve
![41637](https://hackmd.io/_uploads/BkipSQn2a.jpg)
    

* We calculate the resultant force of Swerve and analyze its displacement direction.
![41633](https://hackmd.io/_uploads/BynTBm3nT.jpg)
![41632](https://hackmd.io/_uploads/rk3pSQ3hT.jpg)


* We use a slope filter to ensure smoother motion of the robot, avoiding instability or oscillations caused by rapid changes.
![41635](https://hackmd.io/_uploads/SJh6r72na.jpg)

```java
    /**
     * @param SlewRateLimiter SlewRateLimiter類別是用來實現斜率濾波的功能，主要用於控制機器人運動時的速率或電壓，以實現平滑的變化
     */
    private SlewRateLimiter m_magLimiter = new SlewRateLimiter(DriveConstants.kMagnitudeSlewRate);// 設定平移幅度的斜率限制值
    private SlewRateLimiter m_rotLimiter = new SlewRateLimiter(DriveConstants.kRotationalSlewRate);// 設定旋轉速率的斜率限制值
    private double m_prevTime = WPIUtilJNI.now() * 1e-6;// 前一次更新的時間，用於計算時間差
```
    