Robot Simülasyonuna Giriş
Genellikle bir takım, gerçek bir robotu olmadan kodunu test etmek isteyebilir. WPILib, ekiplere basit derecelendirme komutlarını kullanarak çeşitli robot özelliklerini simüle etme yeteneği sağlar.
Masaüstü Desteğini Etkinleştirme
Masaüstü Simülatörünün kullanılması Masaüstü Desteğinin etkinleştirilmesini gerektirir. Bu, robot projenizi oluştururken “Enable Desktop Support Checkbox” işaretleyerek veya Visual Studio Code komut paletinden “WPILib: Change Desktop Support Enabled Setting” i çalıştırarak yapılabilir.
Masaüstü desteği, robot projenizin kök dizininde bulunan build.gradle
dosyanızı manuel olarak düzenleyerek de etkinleştirilebilir. Basitçe includeDesktopSupport = false
u includeDesktopSupport = true
olarak değiştirin
def includeDesktopSupport = true
Önemli
Masaüstü/simülasyon desteğinin etkinleştirilmesinin istenmeyen sonuçlara yol açabileceğine dikkat etmek önemlidir. Tüm üreticiler bu seçeneği desteklemez ve kitaplıklarını kullanan kod, simülasyonu çalıştırmaya çalışırken bile çökebilir!
Herhangi bir anda Desktop Support Desteğini devre dışı bırakmak isterseniz, komut paletinden “WPILib: Change Desktop Support Enabled Setting” i yeniden çalıştırın.
Ek C++ Bağımlılığı
C++ robot simulation requires that a native compiler to be installed. For Windows, this would be Visual Studio 2022 (not VS Code), macOS requires Xcode 13 or later, and Linux (Ubuntu) requires the build-essential
package.
Ensure the Desktop Development with C++ option is checked in the Visual Studio installer for simulation support.
Robot Simülasyonunu Çalıştırma
Temel robot simülasyonu VS Code kullanılarak çalıştırılabilir. Bu, VS Code’un komut paleti kullanılarak herhangi bir komut kullanılmadan yapılabilir.
Visual Studio Code’daki konsol çıktınız aşağıdaki gibi görünmelidir. Ancak, takımlar muhtemelen simülasyonu çalıştırmak yerine kodlarını gerçekten test etmek isteyeceklerdir. Bu, aşağıdakiler kullanılarak yapılabilir WPILib’in Simülasyon GUI.
********** Robot program starting **********
Default disabledInit() method... Override me!
Default disabledPeriodic() method... Override me!
Default robotPeriodic() method... Override me!
Önemli
Simulation can also be run outside of VS Code using ./gradlew simulateJava
for Java or ./gradlew simulateNative
for C++.
Robot Gösterge Panellerini Çalıştırma
Hem Shuffleboard hem de SmartDashboard, WPILib simülasyonu ile kullanılabilir.
Shuffleboard-Karıştırma panosu
Shuffleboard is automatically configured to look for a NetworkTables instance from the robotRIO but not from other sources. To connect to a simulation, open Shuffleboard preferences from the File menu and select NetworkTables under Plugins on the left navigation bar. In the Server field, type in the IP address or hostname of the NetworkTables host. For a standard simulation configuration, use localhost
.
SmartDashboard
SmartDashboard is automatically configured to look for a NetworkTables instance from the roboRIO, but not from other sources. To connect to a simulation, open SmartDashboard preferences under the File menu and in the Team Number field, enter the IP address or hostname of the NetworkTables host. For a standard simulation configuration, use localhost
.
Glass
Glass is automatically configured to look for a NetworkTables instance from the roboRIO, but not from other sources. To connect to a simulation, open NetworkTables Settings under the NetworkTables menu and in the Team/IP field, enter the IP address or hostname of the NetworkTables host. For a standard simulation configuration, use localhost
.