diff --git a/settings.gradle b/settings.gradle index 084cf5e818..e636ec79a2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,13 +26,9 @@ include 'wpilibcIntegrationTests' include 'wpilibjExamples' include 'wpilibjIntegrationTests' include 'wpilibj' -include 'simulation:halsim_print' -include 'simulation:halsim_lowfi' -include 'simulation:halsim_ds_nt' include 'simulation:gz_msgs' include 'simulation:frc_gazebo_plugins' include 'simulation:halsim_gazebo' -include 'simulation:lowfi_simulation' include 'simulation:halsim_ds_socket' include 'simulation:halsim_gui' include 'cameraserver' diff --git a/simulation/CMakeLists.txt b/simulation/CMakeLists.txt index cd3f0fef2b..5137f143eb 100644 --- a/simulation/CMakeLists.txt +++ b/simulation/CMakeLists.txt @@ -1,9 +1,5 @@ add_subdirectory(halsim_gui) -add_subdirectory(halsim_print) -add_subdirectory(halsim_lowfi) -add_subdirectory(halsim_ds_nt) #add_subdirectory(gz_msgs) #add_subdirectory(frc_gazebo_plugins) #add_subdirectory(halsim_gazebo) -#add_subdirectory(lowfi_simulation) add_subdirectory(halsim_ds_socket) diff --git a/simulation/halsim_ds_nt/CMakeLists.txt b/simulation/halsim_ds_nt/CMakeLists.txt deleted file mode 100644 index bfed6ff01e..0000000000 --- a/simulation/halsim_ds_nt/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -project(halsim_ds_nt) - -include(CompileWarnings) - -file(GLOB halsim_ds_nt_src src/main/native/cpp/*.cpp) - -add_library(halsim_ds_nt MODULE ${halsim_ds_nt_src}) -wpilib_target_warnings(halsim_ds_nt) -set_target_properties(halsim_ds_nt PROPERTIES DEBUG_POSTFIX "d") -target_link_libraries(halsim_ds_nt PUBLIC hal ntcore) - -target_include_directories(halsim_ds_nt PRIVATE src/main/native/include) - -set_property(TARGET halsim_ds_nt PROPERTY FOLDER "libraries") - -install(TARGETS halsim_ds_nt EXPORT halsim_ds_nt DESTINATION "${main_lib_dest}") diff --git a/simulation/halsim_ds_nt/build.gradle b/simulation/halsim_ds_nt/build.gradle deleted file mode 100644 index fa02630911..0000000000 --- a/simulation/halsim_ds_nt/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -description = "A simulation shared object that uses NetworkTables to act as a stand-in for the FRC Driver Station" - -ext { - includeNtCore = true - includeWpiutil = true - pluginName = 'halsim_ds_nt' -} - -apply from: "${rootDir}/shared/plugins/setupBuild.gradle" diff --git a/simulation/halsim_ds_nt/src/dev/native/cpp/main.cpp b/simulation/halsim_ds_nt/src/dev/native/cpp/main.cpp deleted file mode 100644 index e324b44c88..0000000000 --- a/simulation/halsim_ds_nt/src/dev/native/cpp/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -int main() {} diff --git a/simulation/halsim_ds_nt/src/main/native/cpp/HALSimDsNt.cpp b/simulation/halsim_ds_nt/src/main/native/cpp/HALSimDsNt.cpp deleted file mode 100644 index d694530906..0000000000 --- a/simulation/halsim_ds_nt/src/main/native/cpp/HALSimDsNt.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "HALSimDsNt.h" - -void HALSimDSNT::Initialize() { - rootTable = - nt::NetworkTableInstance::GetDefault().GetTable("sim")->GetSubTable( - "DS_CONTROL"); // Not to be confused with sim::DriverStation from - // HALSim LowFi - - // LOOP TIMING // - - auto timinghz = rootTable->GetEntry("timing_hz"); - timinghz.ForceSetDouble(50); - timinghz.AddListener( - [this](const nt::EntryNotification& ev) -> void { - double valIn = ev.value->GetDouble(); - double val = 0; - val = (valIn < 1 ? 1 : valIn > 100 ? 100 : valIn); - - if (val != valIn) { - this->rootTable->GetEntry("timing_hz").ForceSetDouble(val); - Flush(); - } - - this->timingHz = val; - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - // MODES // - - modeTable = rootTable->GetSubTable("mode"); - auto mtele = modeTable->GetEntry("teleop?"); - auto mauto = modeTable->GetEntry("auto?"); - auto mtest = modeTable->GetEntry("test?"); - auto enabled = modeTable->GetEntry("enabled?"); - auto estop = modeTable->GetEntry("estop?"); - - mtele.ForceSetBoolean(true); - mauto.ForceSetBoolean(false); - mtest.ForceSetBoolean(false); - enabled.ForceSetBoolean(false); - estop.ForceSetBoolean(false); - - mtele.AddListener( - [this](const nt::EntryNotification& ev) -> void { - this->HandleModePress(HALSimDSNT_Mode::teleop, ev.value->GetBoolean()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - mauto.AddListener( - [this](const nt::EntryNotification& ev) -> void { - this->HandleModePress(HALSimDSNT_Mode::auton, ev.value->GetBoolean()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - mtest.AddListener( - [this](const nt::EntryNotification& ev) -> void { - this->HandleModePress(HALSimDSNT_Mode::test, ev.value->GetBoolean()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - enabled.AddListener( - [this](const nt::EntryNotification& ev) -> void { - std::scoped_lock lock(modeMutex); - if (!this->isEstop) { - this->isEnabled = ev.value->GetBoolean(); - } else { - this->isEnabled = false; - } - this->DoModeUpdate(); - this->UpdateModeButtons(); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - estop.AddListener( - [this](const nt::EntryNotification& ev) -> void { - std::scoped_lock lock(modeMutex); - this->isEstop = ev.value->GetBoolean(); - if (this->isEstop) { - this->isEnabled = false; - } - this->DoModeUpdate(); - this->UpdateModeButtons(); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - // ALLIANCES // - - allianceTable = rootTable->GetSubTable("alliance"); - auto allianceStation = allianceTable->GetEntry("station"); - auto allianceColorRed = allianceTable->GetEntry("red?"); - - allianceStation.ForceSetDouble(1); - allianceColorRed.ForceSetBoolean(true); - - allianceStation.AddListener( - [this](const nt::EntryNotification& ev) -> void { - double stnIn = ev.value->GetDouble(); - double stn = 0; - stn = (stnIn > 3 ? 3 : stnIn < 1 ? 1 : stnIn); - - if (stn != stnIn) { - this->allianceTable->GetEntry("station").ForceSetDouble(stn); - Flush(); - } - - this->allianceStation = stn; - this->DoAllianceUpdate(); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - allianceColorRed.AddListener( - [this](const nt::EntryNotification& ev) -> void { - this->isAllianceRed = ev.value->GetBoolean(); - this->DoAllianceUpdate(); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - // FINAL LOGIC // - - Flush(); - - loopThread = std::thread([this]() -> void { - this->running = true; - this->LoopFunc(); - }); - loopThread.detach(); -} - -void HALSimDSNT::HandleModePress(enum HALSimDSNT_Mode mode, bool isPressed) { - if (isPressed) { - if (mode != currentMode) { - std::scoped_lock lock(modeMutex); - currentMode = mode; - isEnabled = false; - this->DoModeUpdate(); - } - } - - this->UpdateModeButtons(); -} - -void HALSimDSNT::UpdateModeButtons() { - modeTable->GetEntry("teleop?").ForceSetBoolean(currentMode == - HALSimDSNT_Mode::teleop); - modeTable->GetEntry("auto?").ForceSetBoolean(currentMode == - HALSimDSNT_Mode::auton); - modeTable->GetEntry("test?").ForceSetBoolean(currentMode == - HALSimDSNT_Mode::test); - modeTable->GetEntry("enabled?").ForceSetBoolean(isEnabled); - Flush(); -} - -void HALSimDSNT::DoModeUpdate() { - HALSIM_SetDriverStationAutonomous(currentMode == HALSimDSNT_Mode::auton); - HALSIM_SetDriverStationTest(currentMode == HALSimDSNT_Mode::test); - HALSIM_SetDriverStationEnabled(isEnabled); - if (isEnabled && !lastIsEnabled) { - currentMatchTime = 0; - } - lastIsEnabled = isEnabled; - HALSIM_SetDriverStationEStop(isEstop); - HALSIM_SetDriverStationFmsAttached(false); - HALSIM_SetDriverStationDsAttached(true); - HALSIM_NotifyDriverStationNewData(); -} - -void HALSimDSNT::DoAllianceUpdate() { - HALSIM_SetDriverStationAllianceStationId(static_cast( - (isAllianceRed ? HAL_AllianceStationID_kRed1 - : HAL_AllianceStationID_kBlue1) + - (static_cast(allianceStation) - 1))); -} - -void HALSimDSNT::LoopFunc() { - while (running) { - double dt = 1000 / timingHz; - std::this_thread::sleep_for( - std::chrono::milliseconds(static_cast(dt))); - if (isEnabled) { - currentMatchTime = currentMatchTime + dt; - HALSIM_SetDriverStationMatchTime(currentMatchTime); - } - HALSIM_NotifyDriverStationNewData(); - } -} - -void HALSimDSNT::Flush() { rootTable->GetInstance().Flush(); } diff --git a/simulation/halsim_ds_nt/src/main/native/cpp/main.cpp b/simulation/halsim_ds_nt/src/main/native/cpp/main.cpp deleted file mode 100644 index 7090de9c28..0000000000 --- a/simulation/halsim_ds_nt/src/main/native/cpp/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include - -static HALSimDSNT dsnt; - -extern "C" { -#if defined(WIN32) || defined(_WIN32) -__declspec(dllexport) -#endif - int HALSIM_InitExtension(void) { - std::cout << "DriverStationNT Initializing." << std::endl; - - dsnt.Initialize(); - - std::cout << "DriverStationNT Initialized!" << std::endl; - return 0; -} -} // extern "C" diff --git a/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h b/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h deleted file mode 100644 index 21d19ee712..0000000000 --- a/simulation/halsim_ds_nt/src/main/native/include/HALSimDsNt.h +++ /dev/null @@ -1,37 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include -#include -#include - -#include -#include -#include - -enum HALSimDSNT_Mode { teleop, auton, test }; - -class HALSimDSNT { - public: - std::shared_ptr rootTable, modeTable, allianceTable; - enum HALSimDSNT_Mode currentMode; - bool isEnabled, lastIsEnabled, isEstop; - std::atomic isAllianceRed, running; - std::atomic currentMatchTime, timingHz, allianceStation; - std::thread loopThread; - wpi::mutex modeMutex; - - void Initialize(); - void HandleModePress(enum HALSimDSNT_Mode mode, bool isPressed); - void UpdateModeButtons(); - void DoModeUpdate(); - void DoAllianceUpdate(); - void LoopFunc(); - void Flush(); -}; diff --git a/simulation/halsim_lowfi/CMakeLists.txt b/simulation/halsim_lowfi/CMakeLists.txt deleted file mode 100644 index b4ce5617f4..0000000000 --- a/simulation/halsim_lowfi/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -project(halsim_lowfi) - -include(CompileWarnings) - -file(GLOB halsim_lowfi_src src/main/native/cpp/*.cpp) - -add_library(halsim_lowfi MODULE ${halsim_lowfi_src}) -wpilib_target_warnings(halsim_lowfi) -set_target_properties(halsim_lowfi PROPERTIES DEBUG_POSTFIX "d") -target_link_libraries(halsim_lowfi PUBLIC hal ntcore) - -target_include_directories(halsim_lowfi PRIVATE src/main/native/include) - -set_property(TARGET halsim_lowfi PROPERTY FOLDER "libraries") - -install(TARGETS halsim_lowfi EXPORT halsim_lowfi DESTINATION "${main_lib_dest}") diff --git a/simulation/halsim_lowfi/build.gradle b/simulation/halsim_lowfi/build.gradle deleted file mode 100644 index 549a43cf64..0000000000 --- a/simulation/halsim_lowfi/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -description = "A simulation shared object that publishes basic robot I/O to NetworkTables." - -ext { - includeNtCore = true - includeWpiutil = true - pluginName = 'halsim_lowfi' -} - -apply from: "${rootDir}/shared/plugins/setupBuild.gradle" diff --git a/simulation/halsim_lowfi/src/dev/native/cpp/main.cpp b/simulation/halsim_lowfi/src/dev/native/cpp/main.cpp deleted file mode 100644 index e324b44c88..0000000000 --- a/simulation/halsim_lowfi/src/dev/native/cpp/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -int main() {} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp b/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp deleted file mode 100644 index f82efb77b8..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/HALSimLowFi.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "HALSimLowFi.h" - -#include - -void HALSimLowFi::Initialize() { - table = nt::NetworkTableInstance::GetDefault().GetTable("sim"); -} - -void HALSimNTProvider::Inject(std::shared_ptr parentArg, - std::string tableNameArg) { - parent = parentArg; - tableName = std::move(tableNameArg); - table = parent->table->GetSubTable(tableName); - - this->Initialize(); -} - -void NTProviderBaseCallback(const char* name, void* param, - const struct HAL_Value* value) { - auto info = - static_cast(param); - uint32_t chan = static_cast(info->channel); - auto provider = info->provider; - auto table = info->table; - provider->OnCallback(chan, table); -} - -void HALSimNTProvider::InitializeDefault( - int numChannels, HALCbRegisterIndexedFunc registerFunc) { - this->numChannels = numChannels; - cbInfos.reserve(numChannels); - for (int i = 0; i < numChannels; i++) { - struct NTProviderCallbackInfo info = { - this, table->GetSubTable(tableName + wpi::Twine(i)), i}; - cbInfos.emplace_back(info); - } - - for (auto& info : cbInfos) { - registerFunc(info.channel, NTProviderBaseCallback, &info, true); - OnInitializedChannel(info.channel, info.table); - } -} - -void HALSimNTProvider::InitializeDefaultSingle( - HALCbRegisterSingleFunc registerFunc) { - struct NTProviderCallbackInfo info = {this, table, 0}; - cbInfos.push_back(info); - - for (auto& info : cbInfos) { - registerFunc(NTProviderBaseCallback, &info, true); - } -} - -void HALSimNTProvider::OnInitializedChannel( - uint32_t channel, std::shared_ptr table) {} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Analog.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Analog.cpp deleted file mode 100644 index 2d35c571ce..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Analog.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_Analog.h" - -#include -#include -#include - -void HALSimNTProviderAnalogIn::Initialize() { - InitializeDefault(HAL_GetNumAnalogInputs(), - HALSIM_RegisterAnalogInAllCallbacks); -} - -void HALSimNTProviderAnalogIn::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetAnalogInInitialized(chan)); - table->GetEntry("avg_bits").SetDouble(HALSIM_GetAnalogInAverageBits(chan)); - table->GetEntry("oversample_bits") - .SetDouble(HALSIM_GetAnalogInOversampleBits(chan)); - table->GetEntry("voltage").SetDouble(HALSIM_GetAnalogInVoltage(chan)); - - auto accum = table->GetSubTable("accum"); - accum->GetEntry("init?").SetBoolean( - HALSIM_GetAnalogInAccumulatorInitialized(chan)); - accum->GetEntry("value").SetDouble(HALSIM_GetAnalogInAccumulatorValue(chan)); - accum->GetEntry("count").SetDouble(HALSIM_GetAnalogInAccumulatorCount(chan)); - accum->GetEntry("center").SetDouble( - HALSIM_GetAnalogInAccumulatorCenter(chan)); - accum->GetEntry("deadband") - .SetDouble(HALSIM_GetAnalogInAccumulatorDeadband(chan)); -} - -void HALSimNTProviderAnalogIn::OnInitializedChannel( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("voltage").AddListener( - [=](const nt::EntryNotification& ev) -> void { - HALSIM_SetAnalogInVoltage(chan, ev.value->GetDouble()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); -} - -void HALSimNTProviderAnalogOut::Initialize() { - InitializeDefault(HAL_GetNumAnalogOutputs(), - HALSIM_RegisterAnalogOutAllCallbacks); -} - -void HALSimNTProviderAnalogOut::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetAnalogOutInitialized(chan)); - table->GetEntry("voltage").SetDouble(HALSIM_GetAnalogOutVoltage(chan)); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DIO.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DIO.cpp deleted file mode 100644 index f4ed9d61c0..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DIO.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_DIO.h" - -#include -#include - -void HALSimNTProviderDIO::Initialize() { - InitializeDefault(HAL_GetNumDigitalChannels(), - HALSIM_RegisterDIOAllCallbacks); -} - -void HALSimNTProviderDIO::OnCallback(uint32_t chan, - std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetDIOInitialized(chan)); - table->GetEntry("value").SetBoolean(HALSIM_GetDIOValue(chan)); - table->GetEntry("pulse_length").SetDouble(HALSIM_GetDIOPulseLength(chan)); - table->GetEntry("input?").SetBoolean(HALSIM_GetDIOIsInput(chan)); -} - -void HALSimNTProviderDIO::OnInitializedChannel( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("value").AddListener( - [=](const nt::EntryNotification& ev) -> void { - if (HALSIM_GetDIOIsInput(chan)) { - HALSIM_SetDIOValue(chan, ev.value->GetBoolean()); - } - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DriverStation.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DriverStation.cpp deleted file mode 100644 index e02d6462e3..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_DriverStation.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_DriverStation.h" - -#include -#include - -void HALSimNTProviderDriverStation::Initialize() { - InitializeDefaultSingle(HALSIM_RegisterDriverStationAllCallbacks); -} - -void HALSimNTProviderDriverStation::OnCallback( - uint32_t chan, std::shared_ptr table) { - bool auton = HALSIM_GetDriverStationAutonomous(), - test = HALSIM_GetDriverStationTest(), - enabled = HALSIM_GetDriverStationEnabled(); - - bool teleop = (!auton && !test && enabled); - - table->GetEntry("enabled?").SetBoolean(enabled); - table->GetEntry("autonomous?").SetBoolean(auton); - table->GetEntry("test?").SetBoolean(test); - table->GetEntry("teleop?").SetBoolean(teleop); - table->GetEntry("estop?").SetBoolean(HALSIM_GetDriverStationEStop()); - table->GetEntry("fms?").SetBoolean(HALSIM_GetDriverStationFmsAttached()); - table->GetEntry("ds?").SetBoolean(HALSIM_GetDriverStationDsAttached()); - table->GetEntry("match_time").SetDouble(HALSIM_GetDriverStationMatchTime()); - - // TODO: Joysticks - - auto alliance = table->GetSubTable("alliance"); - auto allianceValue = HALSIM_GetDriverStationAllianceStationId(); - alliance->GetEntry("color").SetString( - (allianceValue == HAL_AllianceStationID_kRed1 || - allianceValue == HAL_AllianceStationID_kRed2 || - allianceValue == HAL_AllianceStationID_kRed3) - ? "red" - : "blue"); - int station = 0; - - switch (allianceValue) { - case HAL_AllianceStationID_kRed1: - case HAL_AllianceStationID_kBlue1: - station = 1; - break; - case HAL_AllianceStationID_kRed2: - case HAL_AllianceStationID_kBlue2: - station = 2; - break; - case HAL_AllianceStationID_kRed3: - case HAL_AllianceStationID_kBlue3: - station = 3; - break; - } - alliance->GetEntry("station").SetDouble(station); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Encoder.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Encoder.cpp deleted file mode 100644 index ca012abb52..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Encoder.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_Encoder.h" - -#include -#include - -void HALSimNTProviderEncoder::Initialize() { - InitializeDefault(HAL_GetNumEncoders(), HALSIM_RegisterEncoderAllCallbacks); -} - -void HALSimNTProviderEncoder::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetEncoderInitialized(chan)); - table->GetEntry("count").SetDouble(HALSIM_GetEncoderCount(chan)); - table->GetEntry("period").SetDouble(HALSIM_GetEncoderPeriod(chan)); - table->GetEntry("reset?").SetBoolean(HALSIM_GetEncoderReset(chan)); - table->GetEntry("max_period").SetDouble(HALSIM_GetEncoderMaxPeriod(chan)); - table->GetEntry("direction").SetBoolean(HALSIM_GetEncoderDirection(chan)); - table->GetEntry("reverse_direction?") - .SetBoolean(HALSIM_GetEncoderReverseDirection(chan)); - table->GetEntry("samples_to_avg") - .SetDouble(HALSIM_GetEncoderSamplesToAverage(chan)); -} - -void HALSimNTProviderEncoder::OnInitializedChannel( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("count").AddListener( - [=](const nt::EntryNotification& ev) -> void { - HALSIM_SetEncoderCount(chan, - static_cast(ev.value->GetDouble())); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); - - table->GetEntry("direction") - .AddListener( - [=](const nt::EntryNotification& ev) -> void { - HALSIM_SetEncoderDirection(chan, ev.value->GetBoolean()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_PWM.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_PWM.cpp deleted file mode 100644 index 5786eeec3a..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_PWM.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_PWM.h" - -#include -#include - -void HALSimNTProviderPWM::Initialize() { - InitializeDefault(HAL_GetNumPWMChannels(), HALSIM_RegisterPWMAllCallbacks); -} - -void HALSimNTProviderPWM::OnCallback(uint32_t chan, - std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetPWMInitialized(chan)); - table->GetEntry("speed").SetDouble(HALSIM_GetPWMSpeed(chan)); - table->GetEntry("position").SetDouble(HALSIM_GetPWMPosition(chan)); - table->GetEntry("raw").SetDouble(HALSIM_GetPWMRawValue(chan)); - table->GetEntry("period_scale").SetDouble(HALSIM_GetPWMPeriodScale(chan)); - table->GetEntry("zero_latch?").SetBoolean(HALSIM_GetPWMZeroLatch(chan)); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Relay.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Relay.cpp deleted file mode 100644 index 249a1c3659..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_Relay.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_Relay.h" - -#include -#include - -void HALSimNTProviderRelay::Initialize() { - InitializeDefault(HAL_GetNumRelayHeaders(), HALSIM_RegisterRelayAllCallbacks); -} - -void HALSimNTProviderRelay::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("init_fwd?") - .SetBoolean(HALSIM_GetRelayInitializedForward(chan)); - table->GetEntry("init_rvs?") - .SetBoolean(HALSIM_GetRelayInitializedReverse(chan)); - table->GetEntry("fwd?").SetBoolean(HALSIM_GetRelayForward(chan)); - table->GetEntry("rvs?").SetBoolean(HALSIM_GetRelayReverse(chan)); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_RoboRIO.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_RoboRIO.cpp deleted file mode 100644 index c3eaa25b7f..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_RoboRIO.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_RoboRIO.h" - -#include -#include - -void HALSimNTProviderRoboRIO::Initialize() { - InitializeDefault(1, HALSIM_RegisterRoboRioAllCallbacks); -} - -void HALSimNTProviderRoboRIO::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("fpga_button?").SetBoolean(HALSIM_GetRoboRioFPGAButton(chan)); - - table->GetEntry("vin_voltage").SetDouble(HALSIM_GetRoboRioVInVoltage(chan)); - table->GetEntry("vin_current").SetDouble(HALSIM_GetRoboRioVInCurrent(chan)); - - auto t6v = table->GetSubTable("6V"); - t6v->GetEntry("voltage").SetDouble(HALSIM_GetRoboRioUserVoltage6V(chan)); - t6v->GetEntry("current").SetDouble(HALSIM_GetRoboRioUserCurrent6V(chan)); - t6v->GetEntry("active?").SetBoolean(HALSIM_GetRoboRioUserActive6V(chan)); - t6v->GetEntry("faults").SetDouble(HALSIM_GetRoboRioUserFaults6V(chan)); - - auto t5v = table->GetSubTable("5V"); - t5v->GetEntry("voltage").SetDouble(HALSIM_GetRoboRioUserVoltage5V(chan)); - t5v->GetEntry("current").SetDouble(HALSIM_GetRoboRioUserCurrent5V(chan)); - t5v->GetEntry("active?").SetBoolean(HALSIM_GetRoboRioUserActive5V(chan)); - t5v->GetEntry("faults").SetDouble(HALSIM_GetRoboRioUserFaults5V(chan)); - - auto t3v3 = table->GetSubTable("3V3"); - t3v3->GetEntry("voltage").SetDouble(HALSIM_GetRoboRioUserVoltage3V3(chan)); - t3v3->GetEntry("current").SetDouble(HALSIM_GetRoboRioUserCurrent3V3(chan)); - t3v3->GetEntry("active?").SetBoolean(HALSIM_GetRoboRioUserActive3V3(chan)); - t3v3->GetEntry("faults").SetDouble(HALSIM_GetRoboRioUserFaults3V3(chan)); -} - -void HALSimNTProviderRoboRIO::OnInitializedChannel( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("fpga_button?") - .AddListener( - [=](const nt::EntryNotification& ev) -> void { - HALSIM_SetRoboRioFPGAButton(chan, ev.value->GetBoolean()); - }, - NT_NotifyKind::NT_NOTIFY_UPDATE); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_dPWM.cpp b/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_dPWM.cpp deleted file mode 100644 index e2bb74ae73..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/NTProvider_dPWM.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "NTProvider_dPWM.h" - -#include -#include - -void HALSimNTProviderDigitalPWM::Initialize() { - InitializeDefault(HAL_GetNumDigitalPWMOutputs(), - HALSIM_RegisterDigitalPWMAllCallbacks); -} - -void HALSimNTProviderDigitalPWM::OnCallback( - uint32_t chan, std::shared_ptr table) { - table->GetEntry("init?").SetBoolean(HALSIM_GetDigitalPWMInitialized(chan)); - table->GetEntry("dio_pin").SetDouble(HALSIM_GetDigitalPWMPin(chan)); - table->GetEntry("duty_cycle").SetDouble(HALSIM_GetDigitalPWMDutyCycle(chan)); -} diff --git a/simulation/halsim_lowfi/src/main/native/cpp/main.cpp b/simulation/halsim_lowfi/src/main/native/cpp/main.cpp deleted file mode 100644 index b94a634b6b..0000000000 --- a/simulation/halsim_lowfi/src/main/native/cpp/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static HALSimLowFi halsim_lowfi; - -static HALSimNTProviderPWM pwm_provider; -static HALSimNTProviderDigitalPWM dpwm_provider; -static HALSimNTProviderDIO dio_provider; -static HALSimNTProviderAnalogIn ai_provider; -static HALSimNTProviderAnalogOut ao_provider; -static HALSimNTProviderDriverStation ds_provider; -static HALSimNTProviderEncoder encoder_provider; -static HALSimNTProviderRelay relay_provider; -static HALSimNTProviderRoboRIO roborio_provider; - -extern "C" { -#if defined(WIN32) || defined(_WIN32) -__declspec(dllexport) -#endif - int HALSIM_InitExtension(void) { - std::cout << "NetworkTables LowFi Simulator Initializing." << std::endl; - halsim_lowfi.Initialize(); - halsim_lowfi.table->GetInstance().StartServer("networktables.ini"); - halsim_lowfi.table->GetInstance().SetUpdateRate(0.05); - auto lowfi = std::make_shared(halsim_lowfi); - - pwm_provider.Inject(lowfi, "PWM"); - dpwm_provider.Inject(lowfi, "dPWM"); - dio_provider.Inject(lowfi, "DIO"); - ai_provider.Inject(lowfi, "AI"); - ao_provider.Inject(lowfi, "AO"); - ds_provider.Inject(lowfi, "DriverStation"); - encoder_provider.Inject(lowfi, "Encoder"); - relay_provider.Inject(lowfi, "Relay"); - roborio_provider.Inject(lowfi, "RoboRIO"); - - std::cout << "NetworkTables LowFi Simulator Initialized!" << std::endl; - return 0; -} -} // extern "C" diff --git a/simulation/halsim_lowfi/src/main/native/include/HALSimLowFi.h b/simulation/halsim_lowfi/src/main/native/include/HALSimLowFi.h deleted file mode 100644 index 28faed0d49..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/HALSimLowFi.h +++ /dev/null @@ -1,58 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include -#include -#include -#include - -#include -#include - -class HALSimLowFi { - public: - std::shared_ptr table; - void Initialize(); -}; - -typedef void (*HALCbRegisterIndexedFunc)(int32_t index, - HAL_NotifyCallback callback, - void* param, HAL_Bool initialNotify); -typedef void (*HALCbRegisterSingleFunc)(HAL_NotifyCallback callback, - void* param, HAL_Bool initialNotify); - -void NTProviderBaseCallback(const char* name, void* param, - const struct HAL_Value* value); - -class HALSimNTProvider { - public: - struct NTProviderCallbackInfo { - HALSimNTProvider* provider; - std::shared_ptr table; - int channel; - }; - - void Inject(std::shared_ptr parent, std::string table); - // Initialize is called by inject. - virtual void Initialize() = 0; - virtual void InitializeDefault(int numChannels, - HALCbRegisterIndexedFunc registerFunc); - virtual void InitializeDefaultSingle(HALCbRegisterSingleFunc registerFunc); - virtual void OnCallback(uint32_t channel, - std::shared_ptr table) = 0; - virtual void OnInitializedChannel(uint32_t channel, - std::shared_ptr table); - - int numChannels; - std::string tableName; - - std::shared_ptr parent; - std::shared_ptr table; - std::vector cbInfos; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Analog.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_Analog.h deleted file mode 100644 index 8672b4676e..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Analog.h +++ /dev/null @@ -1,28 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderAnalogIn : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; - void OnInitializedChannel(uint32_t channel, - std::shared_ptr table) override; -}; - -class HALSimNTProviderAnalogOut : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_DIO.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_DIO.h deleted file mode 100644 index b584b486e0..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_DIO.h +++ /dev/null @@ -1,21 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderDIO : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; - void OnInitializedChannel(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_DriverStation.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_DriverStation.h deleted file mode 100644 index 5041b0251d..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_DriverStation.h +++ /dev/null @@ -1,19 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderDriverStation : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Encoder.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_Encoder.h deleted file mode 100644 index f3ef70f4e8..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Encoder.h +++ /dev/null @@ -1,21 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderEncoder : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; - void OnInitializedChannel(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_PWM.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_PWM.h deleted file mode 100644 index 47c416e151..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_PWM.h +++ /dev/null @@ -1,19 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderPWM : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Relay.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_Relay.h deleted file mode 100644 index cc8439af7e..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_Relay.h +++ /dev/null @@ -1,19 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderRelay : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_RoboRIO.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_RoboRIO.h deleted file mode 100644 index 055b6e6a78..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_RoboRIO.h +++ /dev/null @@ -1,21 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderRoboRIO : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; - void OnInitializedChannel(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_lowfi/src/main/native/include/NTProvider_dPWM.h b/simulation/halsim_lowfi/src/main/native/include/NTProvider_dPWM.h deleted file mode 100644 index 0af607f10b..0000000000 --- a/simulation/halsim_lowfi/src/main/native/include/NTProvider_dPWM.h +++ /dev/null @@ -1,19 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include - -class HALSimNTProviderDigitalPWM : public HALSimNTProvider { - public: - void Initialize() override; - void OnCallback(uint32_t channel, - std::shared_ptr table) override; -}; diff --git a/simulation/halsim_print/CMakeLists.txt b/simulation/halsim_print/CMakeLists.txt deleted file mode 100644 index f168cabd94..0000000000 --- a/simulation/halsim_print/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -project(halsim_print) - -include(CompileWarnings) - -file(GLOB halsim_print_src src/main/native/cpp/*.cpp) - -add_library(halsim_print MODULE ${halsim_print_src}) -wpilib_target_warnings(halsim_print) -set_target_properties(halsim_print PROPERTIES DEBUG_POSTFIX "d") -target_link_libraries(halsim_print PUBLIC hal) - -target_include_directories(halsim_print PRIVATE src/main/native/include) - -set_property(TARGET halsim_print PROPERTY FOLDER "libraries") - -install(TARGETS halsim_print EXPORT halsim_print DESTINATION "${main_lib_dest}") diff --git a/simulation/halsim_print/build.gradle b/simulation/halsim_print/build.gradle deleted file mode 100644 index dd0a34700a..0000000000 --- a/simulation/halsim_print/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -description = "A simulation shared object that simply prints robot behaviors" - -ext { - pluginName = 'halsim_print' -} - -apply from: "${rootDir}/shared/plugins/setupBuild.gradle" diff --git a/simulation/halsim_print/src/dev/native/cpp/main.cpp b/simulation/halsim_print/src/dev/native/cpp/main.cpp deleted file mode 100644 index eb9eef1731..0000000000 --- a/simulation/halsim_print/src/dev/native/cpp/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include -#include - -#include - -int main() { - HAL_Initialize(500, 0); - std::this_thread::sleep_for(std::chrono::seconds(2)); -} diff --git a/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp b/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp deleted file mode 100644 index d271ef10e5..0000000000 --- a/simulation/halsim_print/src/main/native/cpp/PrintPWM.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "PrintPWM.h" - -#include - -#include -#include -#include - -static void PWMCallback(const char* name, void* param, - const struct HAL_Value* value) { - auto pwm = static_cast(param); - pwm->Publish(value->data.v_double); -} - -PrintPWM::PrintPWM(int port) { - m_port = port; - HALSIM_RegisterPWMSpeedCallback(port, PWMCallback, this, false); -} - -void PrintPWM::Publish(double value) { - std::cout << "PWM " << m_port << ": " << value << std::endl; -} diff --git a/simulation/halsim_print/src/main/native/cpp/main.cpp b/simulation/halsim_print/src/main/native/cpp/main.cpp deleted file mode 100644 index 55327eeb72..0000000000 --- a/simulation/halsim_print/src/main/native/cpp/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include - -#include "HALSimPrint.h" -#include "PrintPWM.h" - -// Currently, robots never terminate, so we keep a single static object and it -// is never properly released or cleaned up. -static HALSimPrint halsim; - -extern "C" { -#if defined(WIN32) || defined(_WIN32) -__declspec(dllexport) -#endif - int HALSIM_InitExtension(void) { - std::cout << "Print Simulator Initializing." << std::endl; - - int pwmCount = HAL_GetNumPWMChannels(); - halsim.m_pwms.reserve(pwmCount); - for (int i = 0; i < pwmCount; i++) halsim.m_pwms.emplace_back(i); - - return 0; -} -} // extern "C" diff --git a/simulation/halsim_print/src/main/native/include/HALSimPrint.h b/simulation/halsim_print/src/main/native/include/HALSimPrint.h deleted file mode 100644 index 69dafece9b..0000000000 --- a/simulation/halsim_print/src/main/native/include/HALSimPrint.h +++ /dev/null @@ -1,17 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -class PrintPWM; - -class HALSimPrint { - public: - std::vector m_pwms; -}; diff --git a/simulation/halsim_print/src/main/native/include/PrintPWM.h b/simulation/halsim_print/src/main/native/include/PrintPWM.h deleted file mode 100644 index 98803ffa8a..0000000000 --- a/simulation/halsim_print/src/main/native/include/PrintPWM.h +++ /dev/null @@ -1,19 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "HALSimPrint.h" - -class PrintPWM { - public: - explicit PrintPWM(int port); - void Publish(double value); - - private: - int m_port; -}; diff --git a/simulation/lowfi_simulation/build.gradle b/simulation/lowfi_simulation/build.gradle deleted file mode 100644 index e6e81430bc..0000000000 --- a/simulation/lowfi_simulation/build.gradle +++ /dev/null @@ -1,194 +0,0 @@ -apply plugin: 'cpp' -apply plugin: 'google-test-test-suite' -apply plugin: 'visual-studio' -apply plugin: 'edu.wpi.first.NativeUtils' -apply plugin: SingleNativeBuild -apply plugin: ExtraTasks - - -ext { - nativeName = 'lowfi_sim' -} - -apply from: "${rootDir}/shared/config.gradle" - -if (!project.hasProperty('onlylinuxathena')) { - ext.skiplinuxathena = true - ext { - sharedCvConfigs = [lowfi_simTest: []] - staticCvConfigs = [:] - useJava = false - useCpp = true - } - apply from: "${rootDir}/shared/opencv.gradle" - - ext { - staticGtestConfigs = [:] - } - staticGtestConfigs["${nativeName}Test"] = [] - apply from: "${rootDir}/shared/googletest.gradle" - - project(':').libraryBuild.dependsOn build - - nativeUtils.exportsConfigs { - lowfi_sim { - x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', - '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', - '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', - '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] - } - } - - model { - components { - "${nativeName}Base"(NativeLibrarySpec) { - sources { - cpp { - source { - srcDirs = ['src/main/native/cpp'] - include '**/*.cpp' - } - exportedHeaders { - srcDirs 'src/main/native/include' - } - } - } - binaries.all { - if (it instanceof SharedLibraryBinarySpec) { - it.buildable = false - return - } - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - it.buildable = false - return - } - project(':hal').addHalDependency(it, 'shared') - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - } - } - "${nativeName}"(NativeLibrarySpec) { - sources { - cpp { - source { - srcDirs "${rootDir}/shared/singlelib" - include '**/*.cpp' - } - exportedHeaders { - srcDirs 'src/main/native/include' - } - } - } - binaries.all { - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - it.buildable = false - return - } - project(':hal').addHalDependency(it, 'shared') - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - } - } - // By default, a development executable will be generated. This is to help the case of - // testing specific functionality of the library. - "${nativeName}Dev"(NativeExecutableSpec) { - targetBuildTypes 'debug' - sources { - cpp { - source { - srcDirs 'src/dev/native/cpp' - include '**/*.cpp' - lib library: "${nativeName}" - } - exportedHeaders { - srcDirs 'src/dev/native/include' - } - } - } - binaries.all { - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - it.buildable = false - return - } - project(':hal').addHalDependency(it, 'shared') - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - lib library: nativeName, linkage: 'shared' - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') - } - } - } - } - binaries { - withType(GoogleTestTestSuiteBinarySpec) { - lib project: ':ntcore', library: 'ntcore', linkage: 'shared' - lib project: ':cscore', library: 'cscore', linkage: 'shared' - project(':hal').addHalDependency(it, 'shared') - lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' - lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' - lib library: nativeName, linkage: 'shared' - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') - } - } - } - } - - apply from: "publish.gradle" -} - -model { - - testSuites { - if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) { - "${nativeName}Test"(GoogleTestTestSuiteSpec) { - for(NativeComponentSpec c : $.components) { - if (c.name == nativeName) { - testing c - break - } - } - sources { - cpp { - source { - srcDirs 'src/test/native/cpp' - include '**/*.cpp' - } - exportedHeaders { - srcDirs 'src/test/native/include', 'src/main/native/cpp' - } - } - } - } - } - } - tasks { - def c = $.components - project.tasks.create('runCpp', Exec) { - def found = false - c.each { - if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") { - it.binaries.each { - if (!found) { - def arch = it.targetPlatform.architecture.name - if (arch == 'x86-64' || arch == 'x86') { - dependsOn it.tasks.install - commandLine it.tasks.install.runScriptFile.get().asFile.toString() - - found = true - } - } - } - } - } - } - } -} - -tasks.withType(RunTestExecutable) { - args "--gtest_output=xml:test_detail.xml" - outputs.dir outputDir -} diff --git a/simulation/lowfi_simulation/publish.gradle b/simulation/lowfi_simulation/publish.gradle deleted file mode 100644 index 1fa3aafbfc..0000000000 --- a/simulation/lowfi_simulation/publish.gradle +++ /dev/null @@ -1,64 +0,0 @@ -apply plugin: 'maven-publish' - -def baseArtifactId = nativeName -def artifactGroupId = 'edu.wpi.first.halsim' -def zipBaseName = "_GROUP_edu_wpi_first_halsim_ID_${nativeName}_CLS" - -def outputsFolder = file("$project.buildDir/outputs") - -task cppSourcesZip(type: Zip) { - destinationDirectory = outputsFolder - archiveBaseName = zipBaseName - classifier = "sources" - - from(licenseFile) { - into '/' - } - - from('src/main/native/cpp') { - into '/' - } -} - -task cppHeadersZip(type: Zip) { - destinationDirectory = outputsFolder - archiveBaseName = zipBaseName - classifier = "headers" - - from(licenseFile) { - into '/' - } - - from('src/main/native/include') { - into '/' - } -} - -build.dependsOn cppSourcesZip -build.dependsOn cppHeadersZip - -addTaskToCopyAllOutputs(cppSourcesZip) -addTaskToCopyAllOutputs(cppHeadersZip) - - -model { - publishing { - def lowfiSimTaskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat) - - publications { - cpp(MavenPublication) { - lowfiSimTaskList.each { - artifact it - } - - artifact cppHeadersZip - artifact cppSourcesZip - - - artifactId = baseArtifactId - groupId artifactGroupId - version wpilibVersioning.version.get() - } - } - } -} diff --git a/simulation/lowfi_simulation/src/dev/native/cpp/main.cpp b/simulation/lowfi_simulation/src/dev/native/cpp/main.cpp deleted file mode 100644 index eb8381072e..0000000000 --- a/simulation/lowfi_simulation/src/dev/native/cpp/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include - -int main() { - std::cout << "Hello World" << std::endl; - std::cout << HAL_GetRuntimeType() << std::endl; -} diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/MotorEncoderConnector.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/MotorEncoderConnector.cpp deleted file mode 100644 index 5e530e6270..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/MotorEncoderConnector.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/MotorEncoderConnector.h" - -namespace frc { -namespace sim { -namespace lowfi { - -MotorEncoderConnector::MotorEncoderConnector(MotorSim& motorController, - EncoderSim& encoder) - : motorSimulator(motorController), encoderSimulator(encoder) {} - -void MotorEncoderConnector::Update() { - encoderSimulator.SetPosition(motorSimulator.GetPosition()); - encoderSimulator.SetVelocity(motorSimulator.GetVelocity()); -} - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/SimulatorComponentBase.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/SimulatorComponentBase.cpp deleted file mode 100644 index a65de3b323..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/SimulatorComponentBase.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/SimulatorComponentBase.h" - -namespace frc { -namespace sim { -namespace lowfi { - -const std::string& SimulatorComponentBase::GetDisplayName() const { - return m_name; -} - -void SimulatorComponentBase::SetDisplayName(const std::string& displayName) { - m_name = displayName; -} - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/motormodel/SimpleMotorModel.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/motormodel/SimpleMotorModel.cpp deleted file mode 100644 index 226a836fff..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/motormodel/SimpleMotorModel.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/motormodel/SimpleMotorModel.h" - -namespace frc { -namespace sim { -namespace lowfi { - -SimpleMotorModel::SimpleMotorModel(double maxSpeed) : m_maxSpeed(maxSpeed) {} - -void SimpleMotorModel::Reset() { - m_position = 0; - m_velocity = 0; -} - -void SimpleMotorModel::SetVoltage(double voltage) { - m_voltagePercentage = voltage / kMaxExpectedVoltage; -} - -void SimpleMotorModel::Update(double elapsedTime) { - m_velocity = m_maxSpeed * m_voltagePercentage; - m_position += m_velocity * elapsedTime; -} - -double SimpleMotorModel::GetPosition() const { return m_position; } - -double SimpleMotorModel::GetVelocity() const { return m_velocity; } - -double SimpleMotorModel::GetAcceleration() const { return 0; } - -double SimpleMotorModel::GetCurrent() const { return 0; } - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiAnalogGyroSim.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiAnalogGyroSim.cpp deleted file mode 100644 index 63619cc3c4..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiAnalogGyroSim.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/wpisimulators/WpiAnalogGyroSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -WpiAnalogGyroSim::WpiAnalogGyroSim(int index) : m_gyroSimulator(index) {} - -bool WpiAnalogGyroSim::IsWrapperInitialized() const { - return m_gyroSimulator.GetInitialized(); -} - -void WpiAnalogGyroSim::SetAngle(double angle) { - m_gyroSimulator.SetAngle(angle); -} - -double WpiAnalogGyroSim::GetAngle() { return m_gyroSimulator.GetAngle(); } - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiEncoderSim.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiEncoderSim.cpp deleted file mode 100644 index 7425efe619..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiEncoderSim.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/wpisimulators/WpiEncoderSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -WpiEncoderSim::WpiEncoderSim(int index) : m_encoderSimulator(index) {} - -bool WpiEncoderSim::IsWrapperInitialized() const { - return m_encoderSimulator.GetInitialized(); -} - -void WpiEncoderSim::SetPosition(double position) { - m_encoderSimulator.SetCount( - static_cast(position / m_encoderSimulator.GetDistancePerPulse())); -} - -void WpiEncoderSim::SetVelocity(double velocity) { - m_encoderSimulator.SetPeriod(1.0 / velocity); -} - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiMotorSim.cpp b/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiMotorSim.cpp deleted file mode 100644 index 0b08cf2335..0000000000 --- a/simulation/lowfi_simulation/src/main/native/cpp/lowfisim/wpisimulators/WpiMotorSim.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "lowfisim/wpisimulators/WpiMotorSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -WpiMotorSim::WpiMotorSim(int index, MotorModel& motorModelSimulator) - : m_motorModelSimulation(motorModelSimulator), m_pwmSimulator(index) {} - -void WpiMotorSim::Update(double elapsedTime) { - m_motorModelSimulation.SetVoltage(m_pwmSimulator.GetSpeed() * - kDefaultVoltage); - m_motorModelSimulation.Update(elapsedTime); -} - -bool WpiMotorSim::IsWrapperInitialized() const { - return m_pwmSimulator.GetInitialized(); -} - -double WpiMotorSim::GetPosition() const { - return m_motorModelSimulation.GetPosition(); -} - -double WpiMotorSim::GetVelocity() const { - return m_motorModelSimulation.GetVelocity(); -} - -double WpiMotorSim::GetAcceleration() const { - return m_motorModelSimulation.GetAcceleration(); -} - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h deleted file mode 100644 index 041f257585..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/AccelerometerSim.h +++ /dev/null @@ -1,24 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/SimulatorComponentBase.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class AccelerometerSim : public SimulatorComponentBase { - public: - virtual double GetAcceleration() = 0; - virtual void SetAcceleration(double acceleration) = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h deleted file mode 100644 index 2e14755c53..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/EncoderSim.h +++ /dev/null @@ -1,24 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/SimulatorComponentBase.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class EncoderSim : public SimulatorComponentBase { - public: - virtual void SetPosition(double position) = 0; - virtual void SetVelocity(double velocity) = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h deleted file mode 100644 index bc805985d9..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/GyroSim.h +++ /dev/null @@ -1,24 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/SimulatorComponentBase.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class GyroSim : public SimulatorComponentBase { - public: - virtual void SetAngle(double angle) = 0; - virtual double GetAngle() = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorEncoderConnector.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorEncoderConnector.h deleted file mode 100644 index 0cf48734e9..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorEncoderConnector.h +++ /dev/null @@ -1,30 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "EncoderSim.h" -#include "MotorSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class MotorEncoderConnector { - public: - MotorEncoderConnector(MotorSim& motorController, EncoderSim& encoder); - - void Update(); - - private: - MotorSim& motorSimulator; - EncoderSim& encoderSimulator; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h deleted file mode 100644 index 77532a68b1..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/MotorSim.h +++ /dev/null @@ -1,25 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/SimulatorComponentBase.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class MotorSim : public SimulatorComponentBase { - public: - virtual double GetPosition() const = 0; - virtual double GetVelocity() const = 0; - virtual double GetAcceleration() const = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h deleted file mode 100644 index 482ac11b03..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleAccelerometerSim.h +++ /dev/null @@ -1,44 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include "lowfisim/AccelerometerSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class SimpleAccelerometerSim : public AccelerometerSim { - public: - SimpleAccelerometerSim(const std::function& initializedFunction, - const std::function& setterFunction, - const std::function& getterFunction) - : m_isInitializedFunction(initializedFunction), - m_setAccelerationFunction(setterFunction), - m_getAccelerationFunction(getterFunction) {} - double GetAcceleration() override { return m_getAccelerationFunction(); } - - void SetAcceleration(double acceleration) override { - m_setAccelerationFunction(acceleration); - } - - bool IsWrapperInitialized() const override { - return m_isInitializedFunction(); - } - - private: - std::function m_isInitializedFunction; - std::function m_setAccelerationFunction; - std::function m_getAccelerationFunction; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleGyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleGyroSim.h deleted file mode 100644 index ea69247adb..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimpleGyroSim.h +++ /dev/null @@ -1,35 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include "lowfisim/GyroSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class SimpleGyroSim : public GyroSim { - public: - SimpleGyroSim(std::function& setterFunction, - std::function& getterFunction) - : m_setAngleFunction(setterFunction), - m_getAngleFunction(getterFunction) {} - double GetAngle() override { return m_getAngleFunction(); } - - void SetAngle(double angle) override { m_setAngleFunction(angle); } - - private: - std::function m_setAngleFunction; - std::function m_getAngleFunction; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponent.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponent.h deleted file mode 100644 index 4eb5e995be..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponent.h +++ /dev/null @@ -1,29 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -namespace frc { -namespace sim { -namespace lowfi { - -class SimulatorComponent { - public: - virtual ~SimulatorComponent() = default; - - virtual bool IsWrapperInitialized() const = 0; - - virtual const std::string& GetDisplayName() const = 0; - - virtual void SetDisplayName(const std::string& displayName) = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponentBase.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponentBase.h deleted file mode 100644 index c29e68c410..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/SimulatorComponentBase.h +++ /dev/null @@ -1,33 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include "lowfisim/SimulatorComponent.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class SimulatorComponentBase : public virtual SimulatorComponent { - public: - SimulatorComponentBase() = default; - virtual ~SimulatorComponentBase() = default; - - const std::string& GetDisplayName() const override; - - void SetDisplayName(const std::string& displayName) override; - - private: - std::string m_name; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/MotorModel.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/MotorModel.h deleted file mode 100644 index aeffcb78dc..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/MotorModel.h +++ /dev/null @@ -1,28 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -namespace frc { -namespace sim { -namespace lowfi { - -class MotorModel { - public: - virtual void Reset() = 0; - virtual void SetVoltage(double voltage) = 0; - virtual void Update(double elapsedTime) = 0; - - virtual double GetPosition() const = 0; - virtual double GetVelocity() const = 0; - virtual double GetAcceleration() const = 0; - virtual double GetCurrent() const = 0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/SimpleMotorModel.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/SimpleMotorModel.h deleted file mode 100644 index ccfc3b981b..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/motormodel/SimpleMotorModel.h +++ /dev/null @@ -1,40 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/motormodel/MotorModel.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class SimpleMotorModel : public MotorModel { - public: - explicit SimpleMotorModel(double maxSpeed); - - void Reset() override; - void SetVoltage(double voltage) override; - void Update(double elapsedTime) override; - - double GetPosition() const override; - double GetVelocity() const override; - double GetAcceleration() const override; - double GetCurrent() const override; - - protected: - double m_maxSpeed; - double m_voltagePercentage{0}; - double m_position{0}; - double m_velocity{0}; - - static constexpr double kMaxExpectedVoltage = 12; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h deleted file mode 100644 index a5957ef40d..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiAnalogGyroSim.h +++ /dev/null @@ -1,32 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/GyroSim.h" -#include "simulation/AnalogGyroSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class WpiAnalogGyroSim : public GyroSim { - public: - explicit WpiAnalogGyroSim(int index); - - bool IsWrapperInitialized() const override; - - void SetAngle(double angle) override; - double GetAngle() override; - - protected: - frc::sim::AnalogGyroSim m_gyroSimulator; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h deleted file mode 100644 index 0c936e5bc0..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiEncoderSim.h +++ /dev/null @@ -1,31 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/EncoderSim.h" -#include "simulation/EncoderSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class WpiEncoderSim : public EncoderSim { - public: - explicit WpiEncoderSim(int index); - bool IsWrapperInitialized() const override; - - void SetPosition(double position) override; - void SetVelocity(double velocity) override; - - protected: - frc::sim::EncoderSim m_encoderSimulator; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h b/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h deleted file mode 100644 index 9323aecf85..0000000000 --- a/simulation/lowfi_simulation/src/main/native/include/lowfisim/wpisimulators/WpiMotorSim.h +++ /dev/null @@ -1,37 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include "lowfisim/MotorSim.h" -#include "lowfisim/motormodel/MotorModel.h" -#include "simulation/PWMSim.h" - -namespace frc { -namespace sim { -namespace lowfi { - -class WpiMotorSim : public MotorSim { - public: - explicit WpiMotorSim(int index, MotorModel& motorModelSimulator); - bool IsWrapperInitialized() const override; - - void Update(double elapsedTime); - double GetPosition() const override; - double GetVelocity() const override; - double GetAcceleration() const override; - - private: - MotorModel& m_motorModelSimulation; - frc::sim::PWMSim m_pwmSimulator; - - static constexpr double kDefaultVoltage = 12.0; -}; - -} // namespace lowfi -} // namespace sim -} // namespace frc diff --git a/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/MotorEncoderSimulatorTest.cpp b/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/MotorEncoderSimulatorTest.cpp deleted file mode 100644 index 9166de3872..0000000000 --- a/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/MotorEncoderSimulatorTest.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "frc/Encoder.h" -#include "frc/Talon.h" -#include "gtest/gtest.h" -#include "lowfisim/MotorEncoderConnector.h" -#include "lowfisim/motormodel/SimpleMotorModel.h" -#include "lowfisim/wpisimulators/WpiEncoderSim.h" -#include "lowfisim/wpisimulators/WpiMotorSim.h" - -TEST(MotorEncoderConnectorTest, TestWithoutDistancePerPulseFullSpeed) { - frc::sim::lowfi::SimpleMotorModel motorModelSim(6000); - frc::sim::lowfi::WpiMotorSim motorSim(3, motorModelSim); - frc::sim::lowfi::WpiEncoderSim encoderSim(0); - frc::sim::lowfi::MotorEncoderConnector connector(motorSim, encoderSim); - - EXPECT_FALSE(motorSim.IsWrapperInitialized()); - EXPECT_FALSE(encoderSim.IsWrapperInitialized()); - frc::Talon talon{3}; - frc::Encoder encoder{3, 1}; - EXPECT_TRUE(motorSim.IsWrapperInitialized()); - EXPECT_TRUE(encoderSim.IsWrapperInitialized()); - - talon.Set(-1); - motorSim.Update(1); - connector.Update(); - - // Position - EXPECT_EQ(-6000, encoder.Get()); - EXPECT_DOUBLE_EQ(-6000, encoder.GetDistance()); - - // Velocity - EXPECT_DOUBLE_EQ(-1.0 / 6000, encoder.GetPeriod()); - EXPECT_DOUBLE_EQ(-6000, encoder.GetRate()); -} - -TEST(MotorEncoderConnectorTest, TestWithoutDistancePerPulseRealisitcUpdate) { - frc::Talon talon{3}; - frc::Encoder encoder{3, 1}; - - frc::sim::lowfi::SimpleMotorModel motorModelSim(6000); - frc::sim::lowfi::WpiMotorSim motorSim(3, motorModelSim); - frc::sim::lowfi::WpiEncoderSim encoderSim(0); - frc::sim::lowfi::MotorEncoderConnector connector(motorSim, encoderSim); - - talon.Set(0.5); - motorSim.Update(0.02); - connector.Update(); - - // Position - EXPECT_EQ(60, encoder.Get()); - EXPECT_DOUBLE_EQ(60, encoder.GetDistance()); - - // Velocity - EXPECT_DOUBLE_EQ(1.0 / 3000, encoder.GetPeriod()); - EXPECT_DOUBLE_EQ(3000, encoder.GetRate()); -} - -TEST(MotorEncoderConnectorTest, TestWithDistancePerPulseFullSpeed) { - frc::Talon talon{3}; - frc::Encoder encoder{3, 1}; - encoder.SetDistancePerPulse(0.001); - - frc::sim::lowfi::SimpleMotorModel motorModelSim(6000); - frc::sim::lowfi::WpiMotorSim motorSim(3, motorModelSim); - frc::sim::lowfi::WpiEncoderSim encoderSim(0); - frc::sim::lowfi::MotorEncoderConnector connector(motorSim, encoderSim); - - talon.Set(-1); - - motorSim.Update(1); - connector.Update(); - - // Position - EXPECT_EQ(-6000000, encoder.Get()); - EXPECT_DOUBLE_EQ(-6000, encoder.GetDistance()); - - // Velocity - EXPECT_EQ(-1.0 / 6000, encoder.GetPeriod()); - EXPECT_DOUBLE_EQ(-6, encoder.GetRate()); -} - -TEST(MotorEncoderConnectorTest, TestWithDistancePerPulseRealistic) { - frc::Talon talon{3}; - frc::Encoder encoder{3, 1}; - encoder.SetDistancePerPulse(0.001); - - frc::sim::lowfi::SimpleMotorModel motorModelSim(6000); - frc::sim::lowfi::WpiMotorSim motorSim(3, motorModelSim); - frc::sim::lowfi::WpiEncoderSim encoderSim(0); - frc::sim::lowfi::MotorEncoderConnector connector(motorSim, encoderSim); - - talon.Set(0.5); - - motorSim.Update(0.02); - connector.Update(); - - // Position - EXPECT_EQ(60000, encoder.Get()); - EXPECT_DOUBLE_EQ(60, encoder.GetDistance()); - - // Velocity - EXPECT_EQ(1.0 / 3000, encoder.GetPeriod()); - EXPECT_DOUBLE_EQ(3, encoder.GetRate()); -} diff --git a/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/motormodel/SimpleMotorModelSimulationTest.cpp b/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/motormodel/SimpleMotorModelSimulationTest.cpp deleted file mode 100644 index 21c5e7ef19..0000000000 --- a/simulation/lowfi_simulation/src/test/native/cpp/lowfisim/motormodel/SimpleMotorModelSimulationTest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "gtest/gtest.h" -#include "lowfisim/motormodel/SimpleMotorModel.h" - -TEST(SimpleMotorModelSimulationTest, TestSimpleModel) { - frc::sim::lowfi::SimpleMotorModel motorModelSim(200); - - // Test forward voltage - motorModelSim.SetVoltage(6); - motorModelSim.Update(0.5); - - EXPECT_DOUBLE_EQ(50, motorModelSim.GetPosition()); - EXPECT_DOUBLE_EQ(100, motorModelSim.GetVelocity()); - - // Test Reset - motorModelSim.Reset(); - EXPECT_DOUBLE_EQ(0, motorModelSim.GetPosition()); - EXPECT_DOUBLE_EQ(0, motorModelSim.GetVelocity()); - - // Test negative voltage - motorModelSim.Reset(); - motorModelSim.SetVoltage(-3); - motorModelSim.Update(0.06); - - EXPECT_DOUBLE_EQ(-3, motorModelSim.GetPosition()); - EXPECT_DOUBLE_EQ(-50, motorModelSim.GetVelocity()); -} diff --git a/simulation/lowfi_simulation/src/test/native/cpp/main.cpp b/simulation/lowfi_simulation/src/test/native/cpp/main.cpp deleted file mode 100644 index c6b6c58115..0000000000 --- a/simulation/lowfi_simulation/src/test/native/cpp/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include - -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - HAL_Initialize(500, 0); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/wpilibcExamples/build.gradle b/wpilibcExamples/build.gradle index c6c1dfff3c..0a4bea4639 100644 --- a/wpilibcExamples/build.gradle +++ b/wpilibcExamples/build.gradle @@ -89,11 +89,6 @@ model { project(':hal').addHalDependency(binary, 'shared') lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' - if (binary.targetPlatform.name != nativeUtils.wpi.platforms.roborio) { - lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared' - lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared' - lib project: ':simulation:halsim_ds_nt', library: 'halsim_ds_nt', linkage: 'shared' - } if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') } @@ -143,11 +138,6 @@ model { cppCompiler.args "/wd4996" } } - if (binary.targetPlatform.name != nativeUtils.wpi.platforms.roborio) { - lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared' - lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared' - lib project: ':simulation:halsim_ds_nt', library: 'halsim_ds_nt', linkage: 'shared' - } if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared') } @@ -177,41 +167,19 @@ model { binary.tasks.install.doLast { if (binary.targetPlatform.operatingSystem.isWindows()) { // Windows batch scripts - def fileName = binary.component.name + 'LowFi.bat' - def file = new File(installDir + fileName) - file.withWriter { out -> - out.println '@ECHO OFF' - out.print 'SET HALSIM_EXTENSIONS=' - out.print '"' + new File(installDir + 'lib\\halsim_lowfi.dll').toString() + '";' - out.println '"' + new File(installDir + 'lib\\halsim_ds_nt.dll').toString() + '"' - out.println runFile + ' %*' - } - - fileName = binary.component.name + 'LowFiRealDS.bat' + fileName = binary.component.name + 'RealDS.bat' file = new File(installDir + fileName) file.withWriter { out -> out.println '@ECHO OFF' out.print 'SET HALSIM_EXTENSIONS=' - out.print '"' + new File(installDir + 'lib\\halsim_lowfi.dll').toString() + '";' out.println '"' + new File(installDir + 'lib\\halsim_ds_socket.dll').toString() + '"' out.println runFile + ' %*' } } else { - def fileName = binary.component.name + 'LowFi.sh' - def file = new File(installDir + fileName) - - file.withWriter { out -> - out.print 'export HALSIM_EXTENSIONS=' - out.print '"' + new File(installDir + '/lib/libhalsim_lowfi.so').toString() + '";' - out.println '"' + new File(installDir + '/lib/libhalsim_ds_nt.so').toString() + '"' - out.println runFile + ' "$@"' - } - - fileName = binary.component.name + 'LowFiRealDS.sh' + fileName = binary.component.name + 'RealDS.sh' file = new File(installDir + fileName) file.withWriter { out -> out.print 'export HALSIM_EXTENSIONS=' - out.print '"' + new File(installDir + '/lib/libhalsim_lowfi.so').toString() + '":' out.println '"' + new File(installDir + '/lib/libhalsim_ds_socket.so').toString() + '"' out.println runFile + ' "$@"' }