Skip to content

Commit

Permalink
Merge pull request #13 from ubcuas/updates-improvement
Browse files Browse the repository at this point in the history
Copter Update & Custom Param File
  • Loading branch information
ElioDiNino authored Jun 10, 2023
2 parents b899965 + 3e25bbe commit ce71ad1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ To launch a single ArduCopter SITL on host TCP port 5760, with the ability for t
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl ubcuas/uasitl:copter
```

To launch a single ArduCopter SITL on host TCP port 5760, with the ability for the rest of our services to connect, and with a custom parameter file located in the current directory:
> **Note**
> Docker volume mounts (-v option) needs absolute paths. `${PWD}` is a Windows Powershell variable that expands to the current working directory. For Linux, use `$(pwd)` and for Command Prompt use `%cd%`.
```
docker run --rm -p 5760-5780:5760-5780 -it --network=gcom-x_uasnet --name=uasitl -v ${PWD}/custom-copter.param:/custom-copter.param --env PARAM_FILE=/custom-copter.param ubcuas/uasitl:copter --defaults=/ardupilot/Tools/autotest/default_params/copter.parm
```

To launch a single ArduCopter SITL on host TCP port 5760:
```
docker run --rm -p 5760-5780:5760-5780 -it --name=uasitl ubcuas/uasitl:copter
Expand Down
6 changes: 4 additions & 2 deletions arm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ARG VEHICLE_TYPE
# if --build-arg VEHICLE_TYPE=1, set ARDUPILOT_TAG to 'Plane-X.X.X' or set to null otherwise.
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-4.3.4}
# if ARDUPILOT_TAG is null, set it to 'Copter-X.X.X' (or leave as is otherwise).
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.6}
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.7}

# The ARDUPILOT repo and ref to use for the build
ENV ARDUPILOT_REPO=https://github.com/ArduPilot/ardupilot.git
Expand Down Expand Up @@ -138,10 +138,12 @@ ENV VEHICLE $VEHICLE
ENV NUMVEHICLES 1
ENV INCREMENTSTEPLAT 0.01
ENV INCREMENTSTEPLON 0.01
# Default to no custom parameter file
ENV PARAM_FILE ""

# Entrypoint
COPY startArdupilotSITL.sh /
# Give execute permissions
RUN chmod +x /startArdupilotSITL.sh

ENTRYPOINT /startArdupilotSITL.sh ${NUMVEHICLES} ${LAT} ${LON} ${ALT} ${DIR} ${INCREMENTSTEPLAT} ${INCREMENTSTEPLON} ${VEHICLE} ${VEHICLEMODEL} ${SPEEDUP}
ENTRYPOINT /startArdupilotSITL.sh ${NUMVEHICLES} ${LAT} ${LON} ${ALT} ${DIR} ${INCREMENTSTEPLAT} ${INCREMENTSTEPLON} ${VEHICLE} ${VEHICLEMODEL} ${SPEEDUP} ${PARAM_FILE}
38 changes: 23 additions & 15 deletions lib/startArdupilotSITL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ initialAgentAlt=${4}
initialAgentHeading=${5}
incrementStepLat=${6}
incrementStepLon=${7}
VEHICLE=${8}
VEHICLEMODEL=${9}
SPEEDUP=${10}
vehicle=${8}
vehicleModel=${9}
speedup=${10}
paramFile=${11}
paramFileArg=""

incrementStepAlt=0
incrementStepHdg=0

echo "Number of ${VEHICLE}s: $numVehicles"
echo "Number of ${vehicle}s: $numVehicles"

# Start ArduPilots
LAT=${initialAgentLat}
Expand All @@ -25,32 +27,38 @@ HDG=${initialAgentHeading}
echo "Initial Position: $LAT,$LON,$ALT,$HDG"
echo "Increment Lat: $incrementStepLat"
echo "Increment Lon: $incrementStepLon"
echo "VehicleModel: $VEHICLEMODEL"
echo "Speedup: $SPEEDUP"
echo "VehicleModel: $vehicleModel"
echo "Speedup: $speedup"

arduPilotInstance=0

# Add param file if one is specified
if [ -n "$paramFile" ]; then
paramFileArg="--add-param-file=${paramFile}"
fi

if [ $numVehicles -ne 0 ]; then
for i in $(seq 0 $(($numVehicles-1))); do

INSTANCE=$arduPilotInstance

export SITL_RITW_TERMINAL="screen -D -m -S ${VEHICLE}${INSTANCE}"
export SITL_RITW_TERMINAL="screen -D -m -S ${vehicle}${INSTANCE}"

rm -rf ./${VEHICLE}${INSTANCE}
mkdir ./${VEHICLE}${INSTANCE} && cd ${VEHICLE}${INSTANCE}
rm -rf ./${vehicle}${INSTANCE}
mkdir ./${vehicle}${INSTANCE} && cd ${vehicle}${INSTANCE}

simCommand="/vehicle/Tools/autotest/sim_vehicle.py \
-I${INSTANCE} \
--vehicle ${VEHICLE} \
-I ${INSTANCE} \
--vehicle=${vehicle} \
--custom-location=${LAT},${LON},${ALT},${DIR} \
-w \
--speedup ${SPEEDUP} \
-f ${VEHICLEMODEL} \
--speedup ${speedup} \
--frame=${vehicleModel} \
--no-rebuild \
--no-mavproxy"
--no-mavproxy \
${paramFileArg}"

echo "Starting Sim ${VEHICLE} with command '$simCommand'"
echo "Starting Sim ${vehicle} with command '$simCommand'"
exec $simCommand &
pids[${arduPilotInstance}]=$!

Expand Down
6 changes: 4 additions & 2 deletions x86/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ARG VEHICLE_TYPE
# if --build-arg VEHICLE_TYPE=1, set ARDUPILOT_TAG to 'Plane-X.X.X' or set to null otherwise.
ENV ARDUPILOT_TAG=${VEHICLE_TYPE:+Plane-4.3.4}
# if ARDUPILOT_TAG is null, set it to 'Copter-X.X.X' (or leave as is otherwise).
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.6}
ENV ARDUPILOT_TAG=${ARDUPILOT_TAG:-Copter-4.3.7}

# The ARDUPILOT repo and ref to use for the build
ENV ARDUPILOT_REPO=https://github.com/ArduPilot/ardupilot.git
Expand Down Expand Up @@ -146,10 +146,12 @@ ENV VEHICLE $VEHICLE
ENV NUMVEHICLES 1
ENV INCREMENTSTEPLAT 0.01
ENV INCREMENTSTEPLON 0.01
# Default to no custom parameter file
ENV PARAM_FILE ""

# Entrypoint
COPY startArdupilotSITL.sh /
# Give execute permissions
RUN chmod +x /startArdupilotSITL.sh

ENTRYPOINT /startArdupilotSITL.sh ${NUMVEHICLES} ${LAT} ${LON} ${ALT} ${DIR} ${INCREMENTSTEPLAT} ${INCREMENTSTEPLON} ${VEHICLE} ${VEHICLEMODEL} ${SPEEDUP}
ENTRYPOINT /startArdupilotSITL.sh ${NUMVEHICLES} ${LAT} ${LON} ${ALT} ${DIR} ${INCREMENTSTEPLAT} ${INCREMENTSTEPLON} ${VEHICLE} ${VEHICLEMODEL} ${SPEEDUP} ${PARAM_FILE}

0 comments on commit ce71ad1

Please sign in to comment.