重點摘要
學習目標
1.安裝必要軟體
2.建立基礎專案
3.了解比賽需求(規則、硬體、驅動、結構等)
4.第三方驅動下載、安裝
5.使用到的類別(class)有哪些?
6.使用類別建立物件
下面的提醒是從FRC官網節錄,有時連結層數較多,請耐心看完。
軟體安裝
Check1: 軟體安裝是否能順利完成?
→ Installing the FRC Game Tools → Download
→ WPILib Installation Guide → Download
建立測試程式
Check2: 測試程式順利建構出來了?
Creating your Benchtop Test Program (C++/Java)
WPILib: Create a robot project
Project Type: Example
Language: Java
Project Base: Getting Started
Base Folder: 自訂專案存放位置
Project Name: 當Create a New Folder打勾時則依此名稱建立資料夾。
Create a New Folder: 打勾則依上一項Project Name建立資料夾。
Team Number: 8169
Enable Desktop Support: 打勾
Opening The New Project (Trust folder、Robot.java)
Defining the variables for our sample robot 定義變數(物件)
public class Robot extends TimedRobot {
private final PWMSparkMax m_leftDrive = new PWMSparkMax(0);
private final PWMSparkMax m_rightDrive = new PWMSparkMax(1);
private final DifferentialDrive m_robotDrive = new DifferentialDrive(m_leftDrive, m_rightDrive);
private final Joystick m_stick = new Joystick(0);
private final Timer m_timer = new Timer();
Robot Initialization 開機初始化
Simple Autonomous Example 簡易自主模式
Joystick Control for teleoperation 搖桿遙控
Test Mode 測試模式
Deploying the Project to a Robot
Check: 自主、遙控、測試,三種模式切換方式?
Running your Benchtop Test Program
Overview → download a Benchtop Test Program (Creating your Benchtop Test Program)
Tethered Operation (透過Ethernet或USB)
Starting the FRC Driver Station 開啟Driver Station
Setting Up the Driver Station 設定Driver Station
Confirm Connectivity 確認連線
Operate the Robot 操控機器人
Wireless Operation 無線操控
Configuring the Access Point 設定無線基地台
電控元件
Check3: 本次競賽用了哪些元件?
Hardware Component Overview 硬體元件
Overview of Control System
NI roboRIO
CTRE Power Distribution Panel
REV Power Distribution Hub
CTRE Voltage Regulator Module
REV Radio Power Module (小白的電源模組)
OpenMesh OM5P-AN or OM5P-AC Radio (小白)
120A Circuit Breaker (120安培斷路器)
Snap Action Circuit Breakers (速動斷路器)
Robot Battery (機器人電池)
Robot Signal Light
CTRE Pneumatics Control Module
REV Pneumatic Hub (氣動Hub)
Motor Controllers (馬達控制器)
Talon SRX (利爪)
Victor SPX
SPARK MAX Motor Controller
TalonFX Motor Controller
SPARK Motor Controller
Victor SP
Talon Motor Controller
Victor 888 Motor Controller / Victor 884 Motor Controller
Jaguar Motor Controller
DMC-60 and DMC-60C Motor Controller
Venom Motor Controller (猛毒)
Nidec Dynamo BLDC Motor with Controller
SD540B and SD540C Motor Controllers
Spike H-Bridge Relay (H型橋式繼電器)
Servo Power Module (伺服電源模組)
Microsoft Lifecam HD3000
Image Credits
軟體元件
Check4: 專案是否能順利建構出來?
Check5: 會用到的軟體介面操作熟悉了嗎?
Operating System Compatibility
LabVIEW FRC (Windows Only)
Visual Studio Code
FRC Driver Station Powered by NI LabVIEW (Windows Only)
Dashboard Options
LabVIEW Dashboard (Windows Only)
SmartDashboard
Shuffleboard
Glass
LiveWindow
FRC roboRIO Imaging Tool (Windows Only)
FRC Radio Configuration Utility (Windows Only)
FRC Driver Station Log Viewer (Windows Only)
RobotBuilder (Command base專案使用:RobotBuilder連結)
Robot Simulation
FRC LabVIEW Robot Simulator (Windows Only)
PathWeaver (連結)
System Identification
OutlineViewer
Programming Basics 基礎程式設計
Check6: 機器人專案建立了嗎?
Check7: 專案需要引用的類別有哪些?
Supported languages (Labview, C++, Java)
Source code and documentation (WPILib程式公開於GitHub)
→ Visual Studio Code Basics and the WPILib Extension
User Interface
Command Palette
WPILib Extension
→ WPILib Commands in Visual Studio Code
Choosing a Base Class 選定基類
TimedRobot
RobotBase
Command Robot
Romi
Romi - Timed
Romi - Command Bot
Not Using a Base Class 不使用基類
Creating a New WPILib Project
Opening The New Project
C++ Configurations (C++ Only)
The Mechanism
The Mechanism - Java/C++
The Mechanism - LabVIEW
Managing VS Code Libraries
Adding Offline Libraries
VS Code
Command-line
Checking for Updates (Offline)
Checking for Updates (Online)
Removing a Library Dependency
Libraries
Community Libraries
WPILib Command Libraries
Romi Library
→ Building and Deploying Robot Code 編譯(建立)使用於roboRIO上的程式
Opening the Console Viewer
Console Viewer Window
Riolog VS Code Plugin
Opening the RioLog View
Riolog Window
Running the Debugger
Breakpoints
Setting a Breakpoint
Debugging with Print Statements
Debugging with NetworkTables
Automatic Import
Launching the Import Wizard
C++ Configurations (C++ Only)
3rd Party Libraries (有更新時要重新Import)
→ Glass (不在NI Driver Station上)
Telemetry 遙測
→ Sensors
→ → Sensor Overview - Software
→ → Counters
→ → Analog Potentiometers - Software
→ → Programming Limit Switches
→
Motor Controllers
FRC Legal Motor Controllers
Pneumatics
FRC Legal Pneumatics controllers
Relays
FRC Legal Relay Modules
→ Miscellaneous Hardware APIs
→ → Addressable LEDs
→ Pneumatics Control Module 氣動控制模組
Creating a Power Distribution Object
Reading the Bus Voltage
Reading the Temperature
Reading the Total Current, Power, and Energy
Reading Individual Channel Currents
Using the Switchable Channel (PDH)
Cross-the-Road Electronics
CTRE Motor Controllers
Talon FX (with Falcon 500 Motor)
Talon SRX
Victor SPX
CTRE Sensors
CANcoder
Pigeon IMU
CANifier (Java, C++, Hardware User’s Manual, Software Documentation)
REV Robotics
REV Motor Controllers
SPARK MAX (Java, C++, Technical Manual)
Playing With Fusion
PWF Motor Controllers
Venom (Java, C++, Technical Manual)
PWF Sensors
Time of Flight Sensor (Java, C++, Technical Manual)
→ FRC CAN Device Specifications
Addressing
Device Type
Manufacturer
API/Message Identifier
API Class
API Index
Device Number
Protected Frames
Broadcast Messages
Requirements for FRC CAN Nodes
Universal Heartbeat
Basic Programming
→ Git Version Control Introduction 版本控制 (Git website)
Separate testing environments into branches
Ability to navigate to a particular commit without removing history
Ability to manage commits in various ways, including combining them
Various other features, see here
Prerequisites
→ Windows
→ macOS
→ Linux
Driver Station Joysticks
Joystick Class
XboxController Class
PS4Controller Class
POV (十字角度控制鈕)
GenericHID Usage
Button Usage
Initializing Preferences
Reading Preferences
Using Preferences in SmartDashboard
Displaying Preferences in SmartDashboard
Editing Preferences in SmartDashboard
Using Preferences in Shuffleboard
Displaying Preferences in Shuffleboard
Editing Preferences in Shuffleboard
Enabling Test Mode
LiveWindow in Test Mode
Adding Test mode code to your robot code
→ Reading Stacktraces 錯誤發生的例外處置
An unexpected error has occurred.
What’s a “Stack Trace”? (unexpected error has occurred )
What’s an “Unhandled Exception”?
So How Do I Fix My Issue?
Read the Stack Trace
Perform Code Analysis
Run the Single Step Debugger
Search for More Information
Seeking Outside Help
Common Examples & Patterns
Null Pointers and References
Fixing Null Object Issues
Divide by Zero
Fixing Divide By Zero Issues
HAL Resource Already Allocated
Fixing HAL Resource Already Allocated Issues
gradlew is not recognized…
Fixing gradlew is not recognized…
Support Resources