Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup opt-carma script according to install guide #2449

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 82 additions & 26 deletions engineering_tools/opt_carma_setup.bash
Original file line number Diff line number Diff line change
@@ -1,24 +1,65 @@
#!/bin/bash

# Copyright (C) 2018-2021 LEIDOS.
#
# Copyright (C) 2018-2024 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# Script sets up the /opt/carma folder for the user
# Takes in one argument which is the path to the vehicle calibration folder to use
# Takes in two named arguments:
# --calibration-folder: Path to the vehicle calibration folder (required)
# --download-maps: Whether to download example maps or not (default: true)

if [ ! -d "$1" ]; then
echo "Please specify a path to the location of your vehicle calibration folder. Such as carma-config/example_calibration_folder/vehicle/"
# Default values
DOWNLOAD_MAPS=true
ADD_SIM_FOLDER=false

# Function to display usage message
usage() {
echo "Usage: $0 --calibration-folder <path> [--download-maps <true|false> --add-sim-folder <false|true>]"
exit 1
}

# Parse arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--calibration-folder)
CALIBRATION_FOLDER="$2"
shift 2
;;
--download-maps)
DOWNLOAD_MAPS="$2"
shift 2
;;
--add-sim-folder)
ADD_SIM_FOLDER="$2"
shift 2
;;
*)
echo "Unknown parameter passed: $1"
usage
;;
esac
done

# Ensure calibration folder is provided
if [ -z "$CALIBRATION_FOLDER" ]; then
echo "Error: --calibration-folder is required."
usage
fi

# Ensure the calibration folder exists
if [ ! -d "$CALIBRATION_FOLDER" ]; then
echo "Please specify a valid path to the vehicle calibration folder. Such as carma-config/example_calibration_folder/vehicle/"
exit -1
fi

Expand All @@ -27,29 +68,44 @@ sudo groupadd --gid $GRP_ID carma # create the carma group if it does not alread
USERNAME=$(whoami)
sudo usermod -a -G $GRP_ID $USERNAME

sudo mkdir -p /opt/carma/logs /opt/carma/.ros /opt/carma/maps /opt/carma/routes /opt/carma/yolo/darknet/data
sudo chgrp -R $GRP_ID /opt/carma/
sudo chmod 775 -R /opt/carma/
sudo chmod 775 /opt/carma/logs /opt/carma/.ros
mkdir -p /opt/carma/logs /opt/carma/.ros /opt/carma/maps /opt/carma/routes /opt/carma/yolo /opt/carma/data

FILE_EXT=$RANDOM
mkdir ~/carma_temp_$FILE_EXT
cd ~/carma_temp_$FILE_EXT
# Check if downloading maps is required
if [ "$DOWNLOAD_MAPS" == "true" ]; then
FILE_EXT=$RANDOM
mkdir ~/carma_temp_$FILE_EXT
cd ~/carma_temp_$FILE_EXT

git clone --branch carma-develop --depth 1 https://github.com/usdot-fhwa-stol/autoware.ai.git
cp -R autoware.ai/core_perception/vision_darknet_detect/darknet/cfg/ /opt/carma/yolo/darknet/cfg/
curl -o /opt/carma/yolo/darknet/data/yolov3.weights -L https://pjreddie.com/media/files/yolov3.weights
chmod 775 /opt/carma/yolo/darknet/data/yolov3.weights
echo "Downloading example maps..."
curl -o /opt/carma/maps/pcd_map.pcd -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-config/develop/example_opt_carma/maps/base_map.pcd

curl -o /opt/carma/maps/pcd_map.pcd -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-config/develop/example_opt_carma/maps/base_map.pcd
chmod 775 /opt/carma/maps/pcd_map.pcd
curl -o /opt/carma/maps/vector_map.osm -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/route/resource/map/town01_vector_map_1.osm

curl -o /opt/carma/maps/vector_map.osm -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/route/resource/map/town01_vector_map_1.osm
chmod 775 /opt/carma/maps/vector_map.osm
curl -o /opt/carma/routes/Test_lanelet111_route_1.csv -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/route/resource/route/Test_lanelet111_route_1.csv

curl -o /opt/carma/routes/Test_lanelet111_route_1.csv -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/route/resource/route/Test_lanelet111_route_1.csv
chmod 775 /opt/carma/routes/Test_lanelet111_route_1.csv
# Clean up temporary files
rm -R ~/carma_temp_$FILE_EXT
else
echo "Skipping map downloads..."
fi

ln -s "$1" /opt/carma/vehicle
sudo chgrp -R $GRP_ID /opt/carma/
sudo chmod 775 -R /opt/carma/

sudo rm -R ~/carma_temp_$FILE_EXT
# Link the provided vehicle calibration folder
if [ -L /opt/carma/vehicle ]; then
sudo rm /opt/carma/vehicle
fi

ln -s "$CALIBRATION_FOLDER" /opt/carma/vehicle

if [ "$ADD_SIM_FOLDER" == "true" ]; then
echo "Adding folders used for CDASim to be able to save logs"
mkdir -p /opt/carma/logs/carma_1 /opt/carma/logs/carma_2 /opt/carma-simulation/logs /opt/carma-simulation/scripts /opt/carma-streets/scripts
adev4a marked this conversation as resolved.
Show resolved Hide resolved
sudo chgrp -R $GRP_ID /opt/carma/
Copy link
Contributor

@adev4a adev4a Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sudo chmod 775 -R /opt/carma/
sudo chgrp -R $GRP_ID /opt/carma-simulation/
sudo chmod 775 -R /opt/carma-simulation/
sudo chgrp -R $GRP_ID /opt/carma-streets/
sudo chmod 775 -R /opt/carma-streets/
fi
Loading