Skip to content

Commit

Permalink
Merge commit '4047873b69e878e6dae0bb080ba06fd552cc699b' into extractHALs
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAndi committed Jun 4, 2024
2 parents 9795e4f + 4047873 commit 6f92bf4
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 27 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'

Expand All @@ -75,24 +75,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'

Expand All @@ -112,24 +112,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'

Expand All @@ -152,24 +152,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'

Expand All @@ -179,7 +179,7 @@ jobs:
pip install --upgrade platformio
- name: Set up graphviz
uses: ts-graphviz/setup-graphviz@v1.2.0
uses: ts-graphviz/setup-graphviz@v2

- name: Set up doxygen and generate documentation for ${{ matrix.environment }}
uses: mattnotmitt/[email protected]
Expand Down
87 changes: 77 additions & 10 deletions start_platoon.bat
Original file line number Diff line number Diff line change
@@ -1,35 +1,102 @@
@echo off
setlocal

rem Change working directory to the directory of the batch script.
cd /d %~dp0

set PATH=%PATH%;
set WEBOTS_CONTROLLER="%WEBOTS_HOME%\msys64\mingw64\bin\webots-controller.exe"
set PROGRAM_NAME=program.exe
set CONVOY_LEADER_PROGRAM_PATH=.pio\build\ConvoyLeaderSim
set CONVOY_FOLLOWER_PROGRAM_PATH=.pio\build\ConvoyFollowerSim
set CONVOY_LEADER_RX_CHANNEL=1
set CONVOY_LEADER_TX_CHANNEL=2

set CONVOY_LEADER_PIO_ENV_NAME=ConvoyLeaderSim
set CONVOY_LEADER_PIO_PATH=.pio\build\%CONVOY_LEADER_PIO_ENV_NAME%
set CONVOY_LEADER_ROBOT_NAME=leader
set CONVOY_LEADER_RX_CHANNEL=1
set CONVOY_LEADER_TX_CHANNEL=2

set CONVOY_FOLLOWER_PIO_ENV_NAME=ConvoyFollowerSim
set CONVOY_FOLLOWER_PIO_PATH=.pio\build\%CONVOY_FOLLOWER_PIO_ENV_NAME%
set CONVOY_FOLLOWER_ROBOT_NAME=follower_

set TEMP_PLATOON_PATH=tmp
set TEMP_PLATOON_LEADER_PATH=%TEMP_PLATOON_PATH%\%CONVOY_LEADER_PIO_ENV_NAME%
set TEMP_PLATOON_LEADER_NEW_PATH=%TEMP_PLATOON_PATH%\%CONVOY_LEADER_ROBOT_NAME%
set TEMP_PLATOON_FOLLOWER_PATH=%TEMP_PLATOON_PATH%\%CONVOY_FOLLOWER_PIO_ENV_NAME%
set TEMP_PLATOON_FOLLOWER_NEW_PATH=%TEMP_PLATOON_PATH%\%CONVOY_FOLLOWER_ROBOT_NAME%

rem Compile Convoy Leader
%USERPROFILE%\.platformio\penv\Scripts\pio.exe run --environment ConvoyLeaderSim
%USERPROFILE%\.platformio\penv\Scripts\pio.exe run --environment %CONVOY_LEADER_PIO_ENV_NAME%

rem Compile Convoy Follower
%USERPROFILE%\.platformio\penv\Scripts\pio.exe run --environment ConvoyFollowerSim
%USERPROFILE%\.platformio\penv\Scripts\pio.exe run --environment %CONVOY_FOLLOWER_PIO_ENV_NAME%

rem If temporary folder doesn't exist, it will be created.
if not exist %TEMP_PLATOON_PATH%\ (
md %TEMP_PLATOON_PATH%
)

rem Unzip leader to temporary folder
if exist %TEMP_PLATOON_LEADER_PATH%\ (
rmdir /s /q %TEMP_PLATOON_LEADER_PATH%\
)
Call :UnZipFile "%~dp0%TEMP_PLATOON_PATH%\" "%~dp0%CONVOY_LEADER_PIO_PATH%\%CONVOY_LEADER_PIO_ENV_NAME%.zip"

rem Unzip leader to temporary folder
if exist %TEMP_PLATOON_FOLLOWER_PATH%\ (
rmdir /s /q %TEMP_PLATOON_FOLLOWER_PATH%\
)
Call :UnZipFile "%~dp0%TEMP_PLATOON_PATH%\" "%~dp0%CONVOY_FOLLOWER_PIO_PATH%\%CONVOY_FOLLOWER_PIO_ENV_NAME%.zip"

rem Copy leader folder according to a new folder with the robot's name.
rem The copy ensures that a existing settings.json will be kept.
copy /y %TEMP_PLATOON_LEADER_PATH% %TEMP_PLATOON_LEADER_NEW_PATH%

rem Copy follower folder according to a new folder with the robot's name.
rem The copy ensures that a existing settings.json will be kept.
for /L %%i in (1, 1, 2) do (
if exist %TEMP_PLATOON_FOLLOWER_PATH%\ (
rmdir /s /q %TEMP_PLATOON_FOLLOWER_PATH%\
)
copy /y %TEMP_PLATOON_FOLLOWER_PATH% %TEMP_PLATOON_FOLLOWER_NEW_PATH%%%i
)

rem Delete extraced files from .zip
rmdir /s /q %TEMP_PLATOON_LEADER_PATH%
rmdir /s /q %TEMP_PLATOON_FOLLOWER_PATH%

rem Start the convoy leader
echo Start convoy leader.
start "Convoy Leader" ""%WEBOTS_CONTROLLER%"" --robot-name=leader --stdout-redirect %CONVOY_LEADER_PROGRAM_PATH%\%PROGRAM_NAME% -c --serialRxCh=%CONVOY_LEADER_RX_CHANNEL% --serialTxCh=%CONVOY_LEADER_TX_CHANNEL% -v"
start "Convoy Leader" ""%WEBOTS_CONTROLLER%"" --robot-name=%CONVOY_LEADER_ROBOT_NAME% --stdout-redirect %TEMP_PLATOON_LEADER_NEW_PATH%\%PROGRAM_NAME% -n %CONVOY_LEADER_ROBOT_NAME% -c --serialRxCh=%CONVOY_LEADER_RX_CHANNEL% --serialTxCh=%CONVOY_LEADER_TX_CHANNEL% -v"

rem Start the followers
for /L %%i in (1, 1, 2) do (
call :start_follower %%i
echo Start convoy follower %%i.
call :StartFollower %%i
)

exit /b

:start_follower
:StartFollower
set INSTANCE=%1
set ROBOT_NAME=follower_%instance%
set ROBOT_NAME=%CONVOY_FOLLOWER_ROBOT_NAME%%instance%
set /a SERIAL_RX_CHANNEL=(INSTANCE * 2) + 1
set /a SERIAL_TX_CHANNEL=(INSTANCE * 2) + 2
echo Start convoy follower %INSTANCE%.
start "Convoy Follower %INSTANCE%" ""%WEBOTS_CONTROLLER%"" --robot-name=%ROBOT_NAME% --stdout-redirect %CONVOY_FOLLOWER_PROGRAM_PATH%\%PROGRAM_NAME% -c --serialRxCh=%SERIAL_RX_CHANNEL% --serialTxCh=%SERIAL_TX_CHANNEL% -v"
start "Convoy Follower %INSTANCE%" ""%WEBOTS_CONTROLLER%"" --robot-name=%ROBOT_NAME% --stdout-redirect %TEMP_PLATOON_FOLLOWER_NEW_PATH%%INSTANCE%\%PROGRAM_NAME% -n %ROBOT_NAME% -c --serialRxCh=%SERIAL_RX_CHANNEL% --serialTxCh=%SERIAL_TX_CHANNEL% -v"
exit /b

:UnZipFile <extractTo> <newzipfile>
SET vbs="%TEMP%\_.vbs"
IF EXIST %vbs% DEL /f /q %vbs%
>%vbs% ECHO Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% ECHO If NOT fso.FolderExists(%1) Then
>>%vbs% ECHO fso.CreateFolder(%1)
>>%vbs% ECHO End If
>>%vbs% ECHO set objShell = CreateObject("Shell.Application")
>>%vbs% ECHO set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% ECHO objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% ECHO Set fso = Nothing
>>%vbs% ECHO Set objShell = Nothing
cscript //nologo %vbs%
IF EXIST %vbs% DEL /f /q %vbs%

0 comments on commit 6f92bf4

Please sign in to comment.