locale  # check for UTF-8

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

locale  # verify settings

sudo apt install software-properties-common
sudo add-apt-repository universe

sudo apt update -y && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

sudo apt update -y

sudo apt upgrade -y

sudo apt install ros-dev-tools ros-jazzy-ros-base -y

sudo apt install qt6-base-dev qt6-svg-dev qt6-multimedia-dev libxml2-dev socat libboost-all-dev libopencv-dev python3-serial -y

git submodule init
git submodule update

echo "source /opt/ros/jazzy/setup.bash
source ~/Modelec-ROS2/install/setup.bash
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=~/Modelec-ROS2/fastdds_setup.xml
export ROS_DOMAIN_ID=128" >> ~/.bashrc

source ~/.bashrc

sudo cp usbs.rules /etc/udev/rules.d
source src/rplidar_ros/scripts/create_udev_rules.sh

cd ../..

cp ./Desktop/*.desktop ~/Desktop
chmod +x ~/Desktop/*.desktop
gio set ~/Desktop/no_lidar.joy.ros2_launch_marcel.desktop "metadata::trusted" true
gio set ~/Desktop/no_lidar.ros2_launch_marcel.desktop "metadata::trusted" true
gio set ~/Desktop/joy.ros2_launch_marcel.desktop "metadata::trusted" true
gio set ~/Desktop/ros2_launch_marcel.desktop "metadata::trusted" true
gio set ~/Desktop/no-gui.ros2_launch_marcel.desktop "metadata::trusted" true
