撰寫程式
建立專案
- 在WPIlib Vscode裡,按下Ctrl+Shift+P,輸入
Create a new project
- 填入專案需要的資訊([ ]為通常輸入內容)
- 輸入 Example (範例程式) 或 Template (只提供模板)
[Template]
- 選擇程式語言 (Java或Cpp)
[Java]
- 選擇專案控制方式 (Time Robot、 Command Robot等)
[Command Robot]
- 選擇檔案存放目錄
- 專案名稱
- 是否以資料夾方式儲存?
[勾選]
- 隊號
[8725]
- 確認第三方軟件是否全部支援 WPILib 的相關物件(由於可能有部分軟件無法支援,會造成崩潰,因此此區請勿勾選)
- 填寫完成後,點選
Generate Project
、Yes(New Window)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
函式庫安裝
- 在WPIlib Vscode裡,按下Ctrl+Shift+P,輸入
Manage Vendor Libraries
- 選擇
Install new libraries(online)
- 輸入函式庫網址
- 點擊
Yes
函式庫網址
NavX2(陀螺儀)
https://dev.studica.com/releases/2024/NavX.json
REVLib(Neo)
https://software-metadata.revrobotics.com/REVLib-2024.json
Phoenix(CIM & TalonFX)
https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2024-latest.json
Path Planner
https://3015rangerrobotics.github.io/pathplannerlib/PathplannerLib.json
PhotonVision
https://maven.photonvision.org/repository/internal/org/photonvision/photonlib-json/1.0/photonlib-json-1.0.json
WPIlib 3rd Party Libraries
https://docs.wpilib.org/en/stable/docs/software/vscode-overview/3rd-party-libraries.html#
Command robot
檔案之間關係
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
檔案樹狀圖
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
常數設置
- 於
src\main\java\frc\robot\
創建DeviceId.java
,用於紀錄馬達ID(編號)
- 於
src\main\java\frc\robot\
創建GamepadJoystick.java
,用於搖桿操作
- 於
src\main\java\frc\robot\Constants.java
中寫入馬達輸出最大值
馬達控制(僅一顆)
CIM馬達
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorModule.java
用於控制馬達
- 引入函式庫
- 創建
DriveMotorModule
類別,以VictorSPX宣告一顆CIM馬達
- 於
DriveMotorModule
類別內新增控制速度和停止轉動的方法(Method)
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorSubsystem.java
用於宣告馬達
- 引入函式庫
- 宣告馬達和撰寫控制系統
Talon馬達
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorModule.java
用於控制馬達
- 引入函式庫
- 創建
DriveMotorModule
類別,以TalonFX宣告一顆Talon馬達
- 於
DriveMotorModule
類別內新增控制速度和停止轉動的方法(Method)
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorSubsystem.java
用於宣告馬達
- 引入函式庫
- 宣告馬達和撰寫控制系統
Neo馬達
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorModule.java
用於控制馬達
- 引入函式庫
- 創建
DriveMotorModule
類別,CANSparkMax宣告一顆Neo馬達
- 於
DriveMotorModule
類別內新增控制速度和停止轉動的方法(Method)
- 於
src\main\java\frc\robot\subsystems
創建 DriveMotorSubsystem.java
用於宣告馬達
- 引入函式庫
- 宣告馬達和撰寫控制系統
搖桿控制
- 於
src\main\java\frc\robot\commands
創建 DriveJoystickCmd.java
- 引入函式庫
- 宣告subsystem和搖桿函式庫
- 讀取搖桿值和寫入控制馬達的方法(Method)
- 查看
RobotContainer.java
並先刪除全部程式
- 引入函式庫
- 創建搖桿、馬達系統的物件
上傳程式
- 確定無報錯
- CAN接線無誤, Roborio 連接正常
- 關閉防火牆
- Shift + F5 上傳程式,出現
BUILD SUCCESSFUL
代表上傳完成
- 連接搖桿進行測試
關閉防火牆
使用Cmd
- 在隨意路徑下創建一個資料夾
- 創建並編輯兩個bat檔,負責開和關防火牆
開啟防火牆:netsh advfirewall set allprofile state on
關閉防火牆:netsh advfirewall set allprofile state off

- 在桌面創建兩個捷徑並指向兩個bat檔
- 完成後右鍵捷徑,點擊內容
- 選擇
捷徑
標籤,點擊進階,勾選 以系統管理員身分執行
,套用後完成設定
使用 Windows Defender 防火牆內容
- 點擊
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
搜尋 防火牆

- 點擊
Windows Defender 防火牆內容
,將網域、私人、公用設定檔
防火牆狀態皆切換為關閉

Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
為保護電腦安全,在結束活動或測試完後必須打開防火牆