---
# System prepended metadata

title: 20220221~20220227 程式組
tags: [工作筆記 程式組]

---

# 20220221~20220227 程式組
###### tags: `工作筆記 程式組`

# 20220222

## 魏仁祥

### 程式進度

今天 Albert 請到之前在 VEX 機器人比賽獲獎無數的 Henry，請他看看我們的程式並說明目前遇到的狀況。他分析了很多(他說了快兩個小時...)，但最後簡單來說就是不要用 sysid 測量機器人，最後自己進行測試，我簡單分成幾個步驟

1. 用大約 90% max volt 去跑機器人底盤，並拿取 encoder velocity 的值
2. 將 value print 出來列在 excel 裡，使用趨勢線算出 v、a、jerk 並用成圖表
3. 設定目標為約 80% 的矩形面積
4. 然後就瘋狂測試更改參數

上面有錯再麻煩 Aaron 或 Albert 改一下
 
大概是這樣子，更多詳細的內容還要請 Albert 給我他當下打的資料

然後底盤真的要試，感覺平移還是有問題??

### 心得

認真發現到英文很重要很重要，Aaron、Albert 和 Henry 溝通都是以英文為主要語言，似乎是母語一樣。我在旁邊光是聽就有點吃力了，根本不敢講什麼話...。

除此之外，VEX 似乎不像是 FRC 一樣有著 WPILIB。所以基本上 Henry 的程式都是自己寫的，所有的 feedforward、pid control 他都是自己打，相比之下我們都是直接帶入 function 進去用。

# 20220223

## 王鴻霖 Aaron Wang

### Progress Summary

After several days of struggle with the trajectory tracking without major progress, my teammates and I decided to move on to something else first: auto aiming. 

Today we finished a new auto aim method and improved an auto aim method that I previously wrote. 
1. (new) Limelight auto-aim: Use the limelight camera and its analysis feature to track the reflective stripe. Then use the angle error to correct the aiming direction. Additionally include the ability to auto relocate to the best distance (80cm) from the target. Uses PID for both the relocation and aiming. 
2. (improved) previously called tele-op aim, which I now want to rename to "absolute aim" because it utilizes the robot's absolute position (pose) to aim. It's been improved by adding PID to its aiming motion. 

This entry will be more about the limelight auto-aim. For more information about absolute aim, see [this record](https://hackmd.io/@FRC-7130-4th/H1W54L0CY#%E7%8E%8B%E9%B4%BB%E9%9C%96-Aaron-Wang1). Basically I used simple trigonometry to figure out the angle difference from the pose difference. 

### Progress Details

How the new limelight auto aim works:
see [this repository](https://github.com/FutureShock7130/PrototypeAim/tree/main/src/main/java/frc/robot) for the full code
[this page](https://github.com/FutureShock7130/PrototypeAim/blob/main/src/main/java/frc/robot/subsystems/LimeLightSubsystem.java) for the limelight subsystem
and [this page](https://github.com/FutureShock7130/PrototypeAim/blob/main/src/main/java/frc/robot/commands/LimelightAim.java) for the limelight aim command

In a nutshell:
1. Using the limelight subsystem we get the tx value from the limelight camera. tx value is the difference in angle between the camera crosshair and the target. 
2. tx can be used as the angle error for the PID. We can then use the driveSubsystem.arcadeDrive(0,outputRotation) to power the motor

Very simple
Actually more time is spent adjusting the limelight pipeline, but it isn't hard either. Read the [limelight docs](https://docs.limelightvision.io/en/latest/vision_pipeline_tuning.html) and you should understand how to tune it after familiarizing with all the possible filtering and input options.

### Conclusion
I'm quite happy that we finally made some solid progress. By the way, all of these were tested on the prototype bot, but should be applicable for the new bot too (just need a few variable and function adjustment). 


## 魏仁祥

### 程式進度

今天看到了 [254 有個教導我們如何調整 limelight 中 parameters 的簡報](https://www.team254.com/documents/vision-control/) 然後就

痾

明天再寫

## 吳玠廷

### 今日進度
* 將所有備用的網路盒還有備用的開關阿等等的部分都測試完成，可以用網路額也全部改名+更新到最新版本
### 遇到的困難

* 時間不夠因為要看牙齒
* 筆電沒電
* 有時候會因為不明原因無法更新網路盒

### 解決方法

* 將筆電重新開機跟配電盤重開

# 20220224

## 陳伯豪

### Work Prossing

* Finish watching odometry

[Mecanum Drive Kinematics（My）](https://hackmd.io/@Mo-Yu/HyYwikzg5)
[]

## 吳玠廷

### 今日進度

* 

* 

# 20220225

## 王鴻霖 Aaron Wang

### Progress Summary

Today I mainly helped with finishing the subsystems and teleop commands. This includes:

1. Superstructure (climber) commands
2. Transporter commands

I also made some research about state machine, which is an abstract concept that we can basically implement to enable different additional "modes" for the robot. 

### Progress Details

Superstructure commands: https://github.com/FutureShock7130/2022-Public/tree/main/src/main/java/frc/robot/commands/Superstructure

Transport command: https://github.com/FutureShock7130/2022-Public/blob/main/src/main/java/frc/robot/commands/TransportCmd.java

They are quite basic so I don't think any explanation is really needed.

### Conclusion

Today I have less progress because I only had about 1 hour to work due to another activity that I have called physics debate. However, during the following days I will be able to stay at the FRC lab longer and contribute more. 

## 魏仁祥

今天我完成了大部分的程式的基本架構，包括底盤、射球、輸球、希求、台生五大項，等著晚上 ablert 和 aaron 改我的程式。中午的時候也有是著一連貫吸球、輸球到射球，最後以 2000 rpm 的速度射出真的很爽。

然後我累了，今天就這樣簡單紀錄一夏

我請了六節課我超棒


# 20220226


## 魏仁祥

今天想來打一下英文啦~

展現一下英文小菜雞的實力


### Progress Summary

1. Superstructure command adjustment and mechanism test
2. Transporter test
3. Web cam vision subsystem
4. Filming the the fourth week frc 7130 video
5. Path planner testing


### Progress Details

Today, we finished supersturcture command and tried to run it on the robot. First, we face a question is that the spark max motor controller isn't doing what we asked them to do instead of following another one. Thus, we factory default the spark max motor and run it again, and it works!! Then, we really run it on the robot and the process is really exciting and worrying. We are happy about it really works on the robot but we worried about that the robot may fall down and broker. During the testing process, the steel wire on the left climber was torn again and the mechanism team had to fix it. It was a lot of fun. 

Aaron have pormblem doing the transport command. In `RobotContainer.java` he wrote ` .whenHeld` but it didn't make on the robot. Later I suggest to use `.whenPressed` than it works. Actually, there's no big problems with it. 

I wrote the Web cam vision subsystem. pretty eazy. 

```java=
// Creates UsbCamera and MjpegServer [1] and connects them
UsbCamera camera = CameraServer.startAutomaticCapture();

// Creates the CvSink and connects it to the UsbCamera
CvSink cvSink = CameraServer.getVideo();
// Creates the CvSource and MjpegServer [2] and connects them

CvSource outputStream = CameraServer.putVideo("Blur", 640, 480);
```

i help fimling the video, too. Albert remind me that dont expose too much on our robot, therefore i say it really simple and eazy, as if we are really poor in programming. Below is our speech text. 

> 這個禮拜，我們程式組完成了底盤、收球、和輸球的程式。除此之外，我們也完成了砲台轉盤的部分，讓轉盤自動瞄準hub周圍的反光貼條。目前遇到的問題是砲台的轉速調整，由於PID出了一些問題，暫時還在排錯中。除此之外，抬升也因爲Spark馬達編碼器無法正確的抓取位置和速度，這個部分也還在處理中。

The final thing i did today is try [path planner](https://github.com/RDc12Programming/PathPlanner). Path planner is a motion profile generator for FRC robots created by team 3015. It is a lot useful than the official tool, path weaver, and what stunned me the most is that it is able to run an animation on the path planner. I felt comfortable to watch to robot moving in a curve path and suitable veclocity. It's awesome! I simply draw a path and try to implement to vscode with a json file. 

![](https://i.imgur.com/3KCpVkF.png)

![](https://i.imgur.com/zFxkkdy.png)

Once Albert finish running sysid, i think we are able to run path planner. However, i concerned that the robot still can't translate parallelly. :cry: 


### Conclusion

There's still a lot to do. i made a to-do list below. 
- [ ] drivetrain sysid test
- [ ] drivetrain trajectory and odometry
- [ ] drivetrain path planner
- [ ] superstructure climing test
- [ ] turrent velocity pid adjustment

## 王鴻霖 Aaron Wang

### Progress Summary

We made some huge progress on the superstructure system today and was able to climb to the highest level (although costing almost 4 minutes). 

Besides that, all subsystems are now functional in teleop mode. I'm working on combining them to make them more usable, as well as automating certain process, like climbing, to make the process faster. 

### Progress Details

I mainly worked on the following subsystems:

1. Superstructure
2. Intake
3. Transporter

And their commands.

Additionally, I also assigned them to different buttons on the two controllers.

Although some difficulties, such as unable to control certain motor, happened during the process, they are all fairly basic and were successfully solved. 

If you are interested in the code, please do visit our 2022 Official repository. 

### Conclusion

I think after today's progress means that teleop part of the program is near its conclusion. However, the trajectory tracking / motion profile still need more testing. We must focus on them using our limited time. 

















