Skip to content

Commit

Permalink
run windows test build, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
admercs committed Feb 23, 2024
1 parent ce4b9c7 commit ca799e1
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 34 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,32 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: "Add MSBuild to PATH"
uses: microsoft/setup-msbuild@v2
- name: "Enable Developer Command Prompt for Visual Studio"
uses: ilammy/msvc-dev-cmd@v1

# - name: "Enable Developer Command Prompt for Visual Studio"
# uses: ilammy/msvc-dev-cmd@v1
- name: "Build AutonomyLib"
shell: cmd
run: build.cmd

- name: "Activate Developer PowerShell for Visual Studio 2019"
if: ${{ matrix.os == 'windows-2019' }}
shell: pwsh
run: |
'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Launch-VsDevShell.ps1'
$CMAKE_GENERATOR_PLATFORM = 'Visual Studio 16 2019'
- name: "Activate Developer PowerShell for Visual Studio 2022"
if: ${{ matrix.os == 'windows-2022' }}
shell: pwsh
run: |
'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1'
$CMAKE_GENERATOR_PLATFORM = 'Visual Studio 17 2022'
- name: "Build AutonomySim"
shell: pwsh
run: |
# Set-PSDebug -Trace 1
.\scripts\build.ps1 -BuildMode 'Release' -Automate
# - name: "Add MSBuild to PATH"
# uses: microsoft/setup-msbuild@v2
#
# - name: "Activate Developer PowerShell for Visual Studio 2019"
# if: ${{ matrix.os == 'windows-2019' }}
# shell: pwsh
# run: |
# 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Launch-VsDevShell.ps1'
# $CMAKE_GENERATOR_PLATFORM = 'Visual Studio 16 2019'
#
# - name: "Activate Developer PowerShell for Visual Studio 2022"
# if: ${{ matrix.os == 'windows-2022' }}
# shell: pwsh
# run: |
# 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1'
# $CMAKE_GENERATOR_PLATFORM = 'Visual Studio 17 2022'
#
# - name: "Build AutonomySim"
# shell: pwsh
# run: |
# # Set-PSDebug -Trace 1
# .\scripts\build.ps1 -BuildMode 'Release' -Automate
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<img src="https://github.com/nervosys/AutonomySim/actions/workflows/test_windows.yml/badge.svg">
</a>
<a alt="Linux Build"
href="https://github.com/nervosys/AutonomySim/actions/workflows/test_ubuntu.yml">
<img src="https://github.com/nervosys/AutonomySim/actions/workflows/test_ubuntu.yml/badge.svg">
href="https://github.com/nervosys/AutonomySim/actions/workflows/test_linux.yml">
<img src="https://github.com/nervosys/AutonomySim/actions/workflows/test_linux.yml/badge.svg">
</a>
<a alt="macOS Build"
href="https://github.com/nervosys/AutonomySim/actions/workflows/test_macos.yml">
Expand All @@ -35,7 +35,7 @@ For a complete list of changes, view the [change log](./docs/CHANGELOG.md).

## Vision

> "Physics-based simulation provides an accelerated and safe avenue for developing, verifying, and testing robotic control algorithms and prototype designs. In the quest to leverage machine learning for developing AI-enabled robots, physics-based simulation can generate a wealth of labeled training data in a short amount of time. Physics-based simulation also creates an ideal proving ground for developing intelligent robots that can both learn from their mistakes and be verifiable." [-Liu and Negrut, 2021](https://www.annualreviews.org/doi/full/10.1146/annurev-control-072220-093055)
> "A central challenge in the branch of artificial intelligence (AI) known as machine learning (ML) is the massive amount of labeled data needed to train supervised models. Datasets for real-world systems are either hand-crafted or automatically labeled using other ML models, introducing biases and errors into data and models, and limiting learning to the offline case. While game engines have long used hardware-accelerated physics engines based on Newtonian dynamics to simulate motion, physics-based rendering (PBR) and related accelerators have made real-time ray-tracing a reality, extending physical realism to the visual domain. Realism is only increasing with the growing use of Earth observation data. For the first time in history, the average user can generate high-fidelity labeled datasets for offline learning or learn physics-based models online. This has revolutioned AI for robotics, where the data and safety requirements are often otherwise intractable." [-Dr. Adam Erickson, 2024](#)
## Introduction

Expand Down Expand Up @@ -112,8 +112,8 @@ Mirroring real-world robotic systems, `AutonomySim` supports three different ope
If you have wired or remote controller, you can manually control vehicles in the simulator as shown below. For ground vehicles, you can use the arrow keys for control inputs (i.e., steering, accelerating, decelerating). See more details [here](https://nervosys.github.io/AutonomySim/remote_control).

<p align="center">
<img src="./docs/images/AirSimDroneManual.gif" alt="aerial vehicle" style="width:100%">
<img src="./docs/images/AirSimCarManual.gif" alt="ground vehicle" style="width:100%">
<img src="./docs/media/images/autonomysim_drone_manual.gif" alt="aerial vehicle" style="width:100%">
<img src="./docs/media/images/autonomysim_car_manual.gif" alt="ground vehicle" style="width:100%">
</p>

### Machine Operation
Expand All @@ -138,7 +138,7 @@ There are two general approaches to generating labeled data with `AutonomySim`:
The first method, using the `record` button, is the easiest method. Simply press the big red button in the lower right corner to begin recording. This will record the vehicle pose/state and image for each frame. The data logging code is simple and easy to customize to your application.

<p align="center">
<img src="./docs/images/record_data.png" alt="record screenshot" style="scale:100%">
<img src="./docs/media/images/record_data.png" alt="record screenshot" style="scale:100%">
<br>
Human/manual data recording mode.
</p>
Expand Down Expand Up @@ -233,7 +233,7 @@ Coming soon.
The weather system support human and machine control. Press the `F10` key to see the available weather effect options. You can also control the weather using the APIs, as shown [here](https://nervosys.github.io/AutonomySim/apis#weather-apis).

<p align="center">
<img src="./docs/images/weather_menu.png" alt="weather menu" style="scale:100%">
<img src="./docs/media/images/weather_menu.png" alt="weather menu" style="scale:100%">
<br>
Weather effects menu.
</p>
Expand Down
262 changes: 262 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
@echo off

REM //---------- Set variables ----------
setlocal
REM set PROJECT_DIR=%~dp0 REM %~dp0 = directory path of the batch file (AutonomySim/scripts)
REM %cd% = current working directory path (AutonomySim)
set PROJECT_DIR=%cd%
set SCRIPT_DIR=%PROJECT_DIR%\scripts
set RPCLIB_VERSION=2.3.0
set CPU_COUNT_MAX=12
set PLATFORM=x64

REM // Check command line arguments
set "fullPolyCar="
set "buildMode="

REM // Check Visual Studio version
if "%VisualStudioVersion%" == "" (
echo.
echo ERROR: command must be run from VS2022 Developer Command Prompt or Developer PowerShell.
goto :buildfailed_nomsg
)

if "%VisualStudioVersion%" lss "17.0" (
echo.
echo AutonomySim supports up to Unreal Engine 5.3 and Visual Studio 2022.
echo Here are few easy steps to perform the upgrade:
echo https://github.com/nervosys/AutonomySim/blob/main/docs/unreal_upgrade.md
goto :buildfailed_nomsg
)

REM //---------- Parse arguments ----------
if "%1"=="" goto noargs
if "%1"=="--full-poly-car" set "fullPolyCar=y"
if "%1"=="--Debug" set "buildMode=Debug"
if "%1"=="--Release" set "buildMode=Release"
if "%1"=="--RelWithDebInfo" set "buildMode=RelWithDebInfo"

if "%2"=="" goto noargs
if "%2"=="--Debug" set "buildMode=Debug"
if "%2"=="--Release" set "buildMode=Release"
if "%2"=="--RelWithDebInfo" set "buildMode=RelWithDebInfo"

:noargs
set powershell=powershell
where powershell > nul 2>&1
if ERRORLEVEL 1 goto :pwsh
echo Found `powershell` command. && goto start

:pwsh
set powershell=pwsh
where pwsh > nul 2>&1
if ERRORLEVEL 1 goto :nopwsh
set PWSHV7=1
echo Found `pwsh` command. && goto start

:nopwsh
echo PowerShell or `pwsh` not found, please install it: `winget install --id Microsoft.Powershell --source winget`
goto :eof

:start
cd %PROJECT_DIR%

echo.
echo -----------------------------------------------------------------------------------------
echo Parameters
echo -----------------------------------------------------------------------------------------
echo Project directory: %PROJECT_DIR%
echo Script directory: %SCRIPT_DIR%
echo RPClib version: %RPCLIB_VERSION%
echo Full-polycount car: %fullPolyCar%
echo Build mode: %buildMode%
echo Platform: %PLATFORM%
echo CPU count max: %CPU_COUNT_MAX%
echo PowerShell command: %powershell%
echo -----------------------------------------------------------------------------------------
echo.

REM //---------- Check cmake version ----------
call scripts\check_cmake.cmd
if ERRORLEVEL 1 (
call scripts\check_cmake.cmd
if ERRORLEVEL 1 (
echo(
echo ERROR: CMake not installed correctly.
goto :buildfailed
)
)

REM //---------- Create directories ----------
if not exist tmp mkdir tmp
if not exist external mkdir external

REM //---------- Get rpclib ----------
REM if not exist external\rpclib mkdir external\rpclib

if not exist external\rpclib\rpclib-%RPCLIB_VERSION% (
REM // Leave some blank lines because %powershell% shows download banner at top of console
echo.
echo.
echo.
echo -----------------------------------------------------------------------------------------
echo Downloading rpclib
echo -----------------------------------------------------------------------------------------
echo.

@echo on
if "%PWSHV7%" == "" (
%powershell% -command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iwr https://github.com/rpclib/rpclib/archive/v2.3.0.zip -OutFile tmp\rpclib.zip }"
) else (
%powershell% -command "iwr https://github.com/rpclib/rpclib/archive/v2.3.0.zip -OutFile tmp\rpclib.zip"
)
@echo off

REM // Remove any previous versions
rmdir external\rpclib /q /s

%powershell% -command "Expand-Archive -Path tmp\rpclib.zip -DestinationPath external\rpclib"
del tmp\rpclib.zip /q

REM // Fail the build if unable to download rpclib
if not exist external\rpclib\rpclib-%RPCLIB_VERSION% (
echo ERROR: Unable to download rpclib. Stopping build.
goto :buildfailed
)
)

REM //---------- Build rpclib binaries ------------
echo Building rpclib with CMake...
if not exist external\rpclib\rpclib-%RPCLIB_VERSION%\build mkdir external\rpclib\rpclib-%RPCLIB_VERSION%\build
cd external\rpclib\rpclib-%RPCLIB_VERSION%\build

cmake -G"Visual Studio 17 2022" ..

if "%buildMode%" == "" (
cmake --build .
cmake --build . --config Release
) else (
cmake --build . --config %buildMode%
)

if ERRORLEVEL 1 goto :buildfailed
cd %PROJECT_DIR%
echo Current directory: %PROJECT_DIR%

REM //---------- Copy rpclib binaries and include folder inside AutonomyLib folder ----------
set RPCLIB_TARGET_LIB=AutonomyLib\deps\rpclib\lib\x64
if not exist %RPCLIB_TARGET_LIB% mkdir %RPCLIB_TARGET_LIB%
set RPCLIB_TARGET_INCLUDE=AutonomyLib\deps\rpclib\include
if not exist %RPCLIB_TARGET_INCLUDE% mkdir %RPCLIB_TARGET_INCLUDE%
robocopy /MIR external\rpclib\rpclib-%RPCLIB_VERSION%\include %RPCLIB_TARGET_INCLUDE%

if "%buildMode%" == "" (
robocopy /MIR external\rpclib\rpclib-%RPCLIB_VERSION%\build\Debug %RPCLIB_TARGET_LIB%\Debug
robocopy /MIR external\rpclib\rpclib-%RPCLIB_VERSION%\build\Release %RPCLIB_TARGET_LIB%\Release
) else (
robocopy /MIR external\rpclib\rpclib-%RPCLIB_VERSION%\build\%buildMode% %RPCLIB_TARGET_LIB%\%buildMode%
)

REM //---------- Get High-polycount Car Model ------------
if not exist Unreal\Plugins\AutonomySim\Content\VehicleAdv mkdir Unreal\Plugins\AutonomySim\Content\VehicleAdv
if not exist Unreal\Plugins\AutonomySim\Content\VehicleAdv\SUV\v1.2.0 (
if %fullPolyCar% == 'y' or %fullPolyCar% == 'yes' (
REM //leave some blank lines because %powershell% shows download banner at top of console
echo.
echo.
echo.
echo -----------------------------------------------------------------------------------------
echo Downloading ~37MB of high-poly car assets...
echo To perform the installation without these assets, run `build.cmd --no-full-poly-car`
echo -----------------------------------------------------------------------------------------
echo.

if exist tmp\suv_download rmdir tmp\suv_download /q /s
mkdir tmp\suv_download
@echo on
REM %powershell% -command "& { Start-BitsTransfer -Source https://github.com/nervosys/AutonomySim/releases/download/v1.2.0/car_assets.zip -Destination tmp\suv_download\car_assets.zip }"
REM %powershell% -command "& { (New-Object System.Net.WebClient).DownloadFile('https://github.com/nervosys/AutonomySim/releases/download/v1.2.0/car_assets.zip', tmp\suv_download\car_assets.zip) }"
if "%PWSHV7%" == "" (
%powershell% -command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iwr https://github.com/nervosys/AutonomySim/releases/download/v2.0.0-beta.0/car_assets.zip -OutFile tmp\suv_download\car_assets.zip }"
) else (
%powershell% -command "iwr https://github.com/nervosys/AutonomySim/releases/download/v2.0.0-beta.0/car_assets.zip -OutFile tmp\suv_download\car_assets.zip"
)
@echo off
rmdir Unreal\Plugins\AutonomySim\Content\VehicleAdv\SUV /q /s
%powershell% -command "Expand-Archive -Path tmp\suv_download\car_assets.zip -DestinationPath Unreal\Plugins\AutonomySim\Content\VehicleAdv"
rmdir tmp\suv_download /q /s

REM //Don't fail the build if the high-poly car is unable to be downloaded
REM //Instead, just notify users that the gokart will be used.
if not exist Unreal\Plugins\AutonomySim\Content\VehicleAdv\SUV echo "Download of high-polycount SUV failed. Your AutonomySim build will use the default vehicle instead."
) else (
echo Skipping download of high-poly car asset. Default Unreal Engine vehicle will be used.
)
)

REM //---------- Get Eigen library ----------
if not exist AutonomyLib\deps mkdir AutonomyLib\deps
if not exist AutonomyLib\deps\eigen3 (
if "%PWSHV7%" == "" (
%powershell% -command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iwr https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip -OutFile tmp\eigen3.zip }"
) else (
%powershell% -command "iwr https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip -OutFile tmp\eigen3.zip"
)
%powershell% -command "Expand-Archive -Path tmp\eigen3.zip -DestinationPath AutonomyLib\deps"
%powershell% -command "Move-Item -Path AutonomyLib\deps\eigen* -Destination AutonomyLib\deps\del_eigen"
REM move AutonomyLib\deps\eigen* AutonomyLib\deps\del_eigen
mkdir AutonomyLib\deps\eigen3
move AutonomyLib\deps\del_eigen\Eigen AutonomyLib\deps\eigen3\Eigen
rmdir AutonomyLib\deps\del_eigen /q /s
del tmp\eigen3.zip /q
)
if not exist AutonomyLib\deps\eigen3 goto :buildfailed

REM //---------- We now have all dependencies to compile AutonomySim.sln, which will also compile MavLinkCom ----------
if "%buildMode%" == "" (
msbuild -maxcpucount:%CPU_COUNT_MAX% /p:Platform=%PLATFORM% /p:Configuration=Debug AutonomySim.sln
if ERRORLEVEL 1 goto :buildfailed
msbuild -maxcpucount:%CPU_COUNT_MAX% /p:Platform=%PLATFORM% /p:Configuration=Release AutonomySim.sln
if ERRORLEVEL 1 goto :buildfailed
) else (
msbuild -maxcpucount:%CPU_COUNT_MAX% /p:Platform=%PLATFORM% /p:Configuration=%buildMode% AutonomySim.sln
if ERRORLEVEL 1 goto :buildfailed
)

REM //---------- Copy binaries and includes for MavLinkCom in deps ----------
set MAVLINK_TARGET_LIB=AutonomyLib\deps\MavLinkCom\lib
if not exist %MAVLINK_TARGET_LIB% mkdir %MAVLINK_TARGET_LIB%
set MAVLINK_TARGET_INCLUDE=AutonomyLib\deps\MavLinkCom\include
if not exist %MAVLINK_TARGET_INCLUDE% mkdir %MAVLINK_TARGET_INCLUDE%
robocopy /MIR MavLinkCom\include %MAVLINK_TARGET_INCLUDE%
robocopy /MIR MavLinkCom\lib %MAVLINK_TARGET_LIB%

REM //---------- All of our outputs go to Unreal/Plugins folder ----------
if not exist Unreal\Plugins\AutonomySim\Source\AutonomyLib mkdir Unreal\Plugins\AutonomySim\Source\AutonomyLib
robocopy /MIR AutonomyLib Unreal\Plugins\AutonomySim\Source\AutonomyLib /XD temp *. /njh /njs /ndl /np
copy /y AutonomySim.props Unreal\Plugins\AutonomySim\Source\AutonomyLib

REM //---------- Update all Unreal environments ----------
for /D %%E in (Unreal\Environments\*) do (
cd %%E
call .\update_from_git.cmd ..\..\..
cd ..\..\..
)

REM //---------- Done building ----------
exit /b 0

REM //---------- Fail and cleanup ----------
:buildfailed
echo.
echo ERROR: build failed! Review previous log messages. 1>&2
goto :cleanup

:buildfailed_nomsg
cd %PROJECT_DIR%
goto :cleanup

:cleanup
rmdir tmp /q /s
rmdir external /q /s
exit /b 1
14 changes: 10 additions & 4 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,20 @@ function Build-Solution {
$SystemPlatform,
[Parameter(Mandatory)]
[UInt16]
$SystemCpuMax
$SystemCpuMax,
[Parameter()]
[String[]]
$IgnoreErrors = @()
)
[String]$IgnoreErrorCodes = $IgnoreErrors -Join ';'
if ( $BuildMode -eq 'Release' ) {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "/p:Platform=${SystemPlatform}", "/p:Configuration=Debug", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "/p:Platform=${SystemPlatform}", "/p:Configuration=Release", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "-noerr:${IgnoreErrorCodes}",
"/p:Platform=${SystemPlatform}", "/p:Configuration=Debug", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "-noerr:${IgnoreErrorCodes}",
"/p:Platform=${SystemPlatform}", "/p:Configuration=Release", 'AutonomySim.sln' -Wait -NoNewWindow
}
else {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "/p:Platform=${SystemPlatform}", "/p:Configuration=${BuildMode}", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:${SystemCpuMax}", "-noerr:${IgnoreErrorCodes}", "/p:Platform=${SystemPlatform}", "/p:Configuration=${BuildMode}", 'AutonomySim.sln' -Wait -NoNewWindow
}
if (!$?) { exit $LASTEXITCODE } # exit on error
return $null
Expand Down

0 comments on commit ca799e1

Please sign in to comment.