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ü 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
Ö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!
If at any point in time you want to disable Desktop Support, simply re-run the “WPILib: Change Desktop Support Enabled Setting” from the command palette or change includeDesktopSupport
to false in build.gradle.
Not
C++ robot simulation requires that a native compiler to be installed. For Windows, this would be Visual Studio 2022 version 17.9 or later (not VS Code), macOS requires Xcode 14 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.
Running Robot Simulation
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++.
Not
Some vendors support attaching hardware to your PC and using the hardware in desktop simulation (e.g. CANivore). See vendor documentation for more information about the command WPILib: Hardware Sim Robot Code.
GUI simulation support is installed by default when you install RobotPy.
There is a robotpy
subcommand that you can execute to run your code in simulation:
py -3 -m robotpy sim
python3 -m robotpy sim
python3 -m robotpy sim
Robot Gösterge Panellerini Çalıştırma
Shuffleboard, SmartDashboard, Glass, and AdvantageScope can be used with WPILib simulation when they are configured to connect to the local computer (i.e. localhost
).
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
.
AdvantageScope
No configuration is required to connect to a NetworkTables instance running on the local computer. To connect to a simulation, click Connect to Simulator under the File menu or press Ctrl+Shift+K.