#!/bin/bash

FOXYFILE="/opt/ros/foxy/local_setup.bash"

if ! [ -f $FOXYFILE ]; then
	echo "you must install voxl-ros2-foxy first before you can use voxl-mpa-to-ros2"
	exit 1
fi

echo "Installing some apt dependencies"
apt install -y python3-pip python3-numpy libtinyxml2-6 nlohmann-json-dev

echo "making sure pip is installed and upgraded"
python3 -m pip install pip -U

echo "pip installing some dependencies"
python3 -m pip install colcon-common-extensions lark netifaces
python3 -m pip uninstall -y empy
python3 -m pip install empy==3.3.4

echo "enabling voxl-microdds-agent"
systemctl enable --now voxl-microdds-agent

# run our bash profile script to we can get going right away.
# this will get run again next time the user opens a shell
echo "sourcing our bash profile"
source /home/root/.profile.d/source_foxy_setup.sh

echo ""
echo "done configuring voxl-mpa-to-ros2"

echo 'export ROS_HOME=/opt/ros/foxy' >> ~/.bashrc 
echo 'source /opt/ros/foxy/local_setup.bash' >> ~/.bashrc 
echo 'source /opt/ros/foxy/mpa_to_ros2/install/setup.bash' >> ~/.bashrc