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

[ SCRIPTING ] : Adds Installations script #71

Merged
merged 34 commits into from
Apr 12, 2024
Merged
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c65080d
Installatins script added
AryanNanda17 Apr 8, 2024
9e8ffae
unameOUT variable updated
AryanNanda17 Apr 8, 2024
1f10472
Homebrew doesn't include pip explicitly, so it was taken out.
AryanNanda17 Apr 9, 2024
73c0391
ros2 installation for macOS updated
AryanNanda17 Apr 9, 2024
1ddf83d
ros2 installation for macOS updated
AryanNanda17 Apr 9, 2024
061740e
URl updated
AryanNanda17 Apr 9, 2024
9af25f9
microros setup updated
AryanNanda17 Apr 9, 2024
7d0b7e9
MacOS installations updated
AryanNanda17 Apr 9, 2024
f5049db
Cloned Mario in home and not /temp
AryanNanda17 Apr 9, 2024
82d84b0
Mario repo cloned in home dir
AryanNanda17 Apr 10, 2024
88156e7
catkin_pkg installed in macos
AryanNanda17 Apr 10, 2024
8006035
Only ros2-dev branch cloned
AryanNanda17 Apr 10, 2024
e561263
ros2_ws could be run without root privileges now
AryanNanda17 Apr 10, 2024
a6a1c74
~ changed to /Users/Aryan
AryanNanda17 Apr 10, 2024
0948fb5
~ changed to /Users/Aryan
AryanNanda17 Apr 10, 2024
6e36b72
minor change
AryanNanda17 Apr 10, 2024
7774d48
mv changed to cp
AryanNanda17 Apr 10, 2024
2f1b7dd
renamed the script and removed old scripts
AryanNanda17 Apr 10, 2024
49787fc
renamed the branch name from ros2-dev to humble
AryanNanda17 Apr 10, 2024
d12333f
renamed install_codes.sh -> installations.sh
AryanNanda17 Apr 11, 2024
d973c5f
minor changes
AryanNanda17 Apr 11, 2024
1cc49e8
Merge branch 'SRA-VJTI:humble' into aryan_script
AryanNanda17 Apr 11, 2024
c7ac988
sourcing command added after ros2 installation
AryanNanda17 Apr 11, 2024
5bb36b8
removed explicit installation of rosdep
AryanNanda17 Apr 11, 2024
886d582
cp -> cp -r and debugging prints
AryanNanda17 Apr 11, 2024
6f69508
sourcing of mambaforge done for only mac
AryanNanda17 Apr 11, 2024
e202ffd
syntax error corrected
AryanNanda17 Apr 11, 2024
4e56c97
necessary packages added
AryanNanda17 Apr 11, 2024
50159e1
soured shell for linux and not for mac
AryanNanda17 Apr 11, 2024
608ec56
duplicate package removed
AryanNanda17 Apr 11, 2024
179d1d0
Added more packages for installations and Linux installation done
AryanNanda17 Apr 11, 2024
4989ff3
double quotes removed
AryanNanda17 Apr 12, 2024
455be41
/bin/zsh changed to zsh
AryanNanda17 Apr 12, 2024
dcc0b74
micrros cloned in linux
AryanNanda17 Apr 12, 2024
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
283 changes: 283 additions & 0 deletions mario_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
#!/usr/bin/env bash

set -e

red=`tput setaf 1`
green=`tput setaf 2`
blue=`tput setaf 4`
reset=`tput sgr0`

echo "Installing ESP IDF"

_shell_="${SHELL#${SHELL%/*}/}"
# Check whether esp-idf has already been installed
if [ -d $HOME/esp/esp-idf ]; then
echo "${red}======================$reset"
echo "You already have installed esp-idf!"
echo "${blue}======================$reset"
else
# System Detection and ESP-IDF Installation
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
sudo apt update && sudo apt upgrade -y
sudo usermod -a -G dialout $USER
sudo apt install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 -y
sudo apt install python3-venv
;;
Darwin*)
if brew --version | grep -q 'Homebrew'; then
echo "${red}======================$reset"
echo "Homebrew is already installed"
echo "${blue}======================$reset"
else
echo "installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "${blue}======================$reset"
echo "homebrew installed successfully"
echo "${blue}======================$reset"
fi
brew install git cmake ninja dfu-util python3
;;
*)
echo "Not supported: ${unameOut}"
exit 1
;;
esac

# Create ESP Directory
mkdir -p "$HOME/esp"
pushd "$HOME"/esp || (echo "Error: Cannot Make Directory" && exit 1)

# Clone ESP-IDF Repository
git clone -b release/v5.1 --recursive https://github.com/espressif/esp-idf.git
cd $HOME/esp/esp-idf
./install.sh esp32

# Check if installation is successful
. $HOME/esp/esp-idf/export.sh
echo "${red}======================$reset"
idf.py --version | (grep "v5.1.2" && echo "Installation successful! Please restart your computer for the changes to take effect.") \
|| (echo "Installation failed" && exit 1)
echo "${red}======================$reset"
# Set IDF Alias
echo "alias get_idf='. $HOME/esp/esp-idf/export.sh'" >> $HOME/."$_shell_"rc
fi

# Clone Mario repository if not already cloned
if [ ! -d "/ros2_ws" ]; then
echo "${blue}======================$reset"
echo "Cloning Mario"
echo "${red}======================$reset"
cd ~
git clone --recursive https://github.com/SRA-VJTI/MARIO.git
echo "${blue}======================$reset"
echo "Mario repo cloned successfully"
echo "${red}======================$reset"
else
echo "Mario repository already exists and is not empty. Skipping cloning."
fi

# Check the operating system
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
echo "Checking if ROS 2 is installed..."
# Check if ROS 2 is already installed
if ! command -v ros2 &>/dev/null; then
echo "${red}======================$reset"
echo "ROS 2 is not installed. Proceeding with installation..."

# Check for UTF-8 locale
locale
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

# Add ROS 2 repository
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && 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
sudo apt upgrade

# Install ROS 2
sudo apt install ros-humble-desktop
echo "source /opt/ros/humble/setup.bash" >> $HOME/."$_shell_"rc

# Install additional ROS 2 packages
echo "Installing Additional Ros2 packages"
sudo apt install -y ros-humble-desktop-full ros-humble-control-msgs ros-humble-control-toolbox ros-humble-gazebo-ros2-control ros-humble-joint-state-broadcaster ros-humble-joint-state-publisher ros-humble-joint-state-publisher-gui ros-humble-forward-command-controller ros-humble-robot-state-publisher ros-humble-gazebo-ros2-control ros-humble-robot-controllers ros-humble-robot-controllers-interface ros-humble-robot-controllers-msgs
echo "${red}======================$reset"
echo "ROS 2 installed successfully."
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "ROS 2 is already installed."
echo "${red}======================$reset"
fi
;;
Darwin*)
# Installing mambaforge
echo "Installing mambaforge"
if command -v mamba &>/dev/null; then
echo "${blue}======================$reset"
echo "Mambaforge is already installed"
echo "${red}======================$reset"
else
echo "Installing Mambaforge"
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh -O mambaforge.sh
chmod +x mambaforge.sh
./mambaforge.sh
rm mambaforge.sh
echo "${blue}======================$reset"
echo "Mambaforge installed"
echo "${red}======================$reset"
echo "Initializing Mambaforge"
export PATH="$HOME/mambaforge/bin:$PATH"
mamba init --all
echo "$green Mambaforge initialized. ReOpen a new terminal, and Please re-run the installation script for further configuration"
exit 0
fi

# Install mamba if not installed already
conda install mamba -c conda-forge
mamba create -n ros_env -c conda-forge
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
conda config --env --add channels conda-forge
conda config --env --add channels robostack-staging
conda config --env --remove channels defaults || true
# Install ROS packages
mamba install ros-humble-desktop-full
mamba install -n ros_env -y ros-humble-control-msgs ros-humble-control-toolbox ros-humble-joint-state-broadcaster ros-humble-joint-state-publisher ros-humble-joint-state-publisher-gui ros-humble-forward-command-controller ros-humble-robot-state-publisher ros-humble-controller-manager ros-humble-controller-manager-msgs ros-humble-joint-trajectory-controller
mamba install catkin_tools
echo "${red}======================$reset"
echo "ROS 2 installed successfully."
echo "${red}======================$reset"
;;
*)
echo "ROS 2 installation is not supported on this operating system."
exit 1
;;
esac

# Verify if ros2_ws already exists
if [ -d "$HOME/ros2_ws" ]; then
echo "ros2_ws already exists."
else
case "${unameOut}" in
Linux*)
echo "${red}======================$reset"
echo "Creating a ros2_ws"
echo "${red}======================$reset"
sudo apt update
sudo apt install python3-colcon-common-extensions rosdep
echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> $HOME/."$_shell_"rc
mkdir ~/ros2_ws
cd ~/ros2_ws
mkdir src
colcon build
echo "source ~/ros2_ws/install/setup.bash" >> $HOME/."$_shell_"rc
;;
Darwin*)
echo "${blue}======================$reset"
echo "Creating a ros2_ws"
echo "${red}======================$reset"
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
conda install colcon-common-extensions rosdep
# Creating a ros2_ws
mkdir ~/ros2_ws
cd ~/ros2_ws
mkdir src
colcon build
;;
*)
echo "ros2_ws couldn't be setup"
exit 1
;;
esac
fi

# Installig Gazebo if not already installed
if [ "$unameOut" == "Linux" ]; then
if ! command -v gazebo &> /dev/null; then
echo "${red}======================$reset"
echo "Installing Gazebo"
echo "${red}======================$reset"
curl -sSL http://get.gazebosim.org | sh
echo "${red}======================$reset"
echo "Gazebo installed successfully"
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "Gazebo is already installed"
echo "${red}======================$reset"
fi
fi

# Copying Mario's folders to ros2_ws

cd ~/ros2_ws/src
if [[ ! -d "1_chatter_listener" ]]; then
mv ~/ros2_ws/1_* $HOME/ros2_ws/src
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be ~/MARIO/1_* and so on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated it!

mv ~/ros2_ws/2_* $HOME/ros2_ws/src
mv ~/ros2_ws/3_* $HOME/ros2_ws/src
mv ~/ros2_ws/4_* $HOME/ros2_ws/src
mv ~/ros2_ws/activities $HOME/ros2_ws/src
if [[ ! -d "$HOME/ros2_ws_firmware" ]]; then
mkdir -p $HOME/ros2_ws_firmware
mv ~/ros2_ws/firmware/* $HOME/ros2_ws_firmware
echo "${red}======================$reset"
echo "$green firmware copied to ros2_ws_firmware $reset"
else
echo "${red}======================$reset"
echo "$green Already copied $reset"
fi
echo "${red}======================$reset"
else
echo "${red}======================$reset"
echo "$green Ros folders are already copied $reset"
fi
cd ..
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate ros_env
colcon build

# Setting up microrosagent
case "${unameOut}" in
Linux*)
echo "Cloning microrosagent"
cd ~/ros2_ws/src
git clone -b humble https://github.com/micro-ROS/micro-ROS-Agent.git
sudo apt update && rosdep update
cd ..
pip3 install catkin_pkg lark-parser colcon-common-extensions -l rosdep
Copy link
Member

Choose a reason for hiding this comment

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

microros-esp-idf-components depends on this, so its good

rosdep install --from-paths src --ignore-src -y
echo "${red}======================$reset"
echo "Done with cloning"
echo "${red}======================$reset"
;;
Darwin*)
echo "${red}======================$reset"
echo "Cloning microrosagent"
echo "${red}======================$reset"
cd ~/ros2_ws/src

git clone -b humble https://github.com/micro-ROS/micro-ROS-Agent.git
Copy link
Member

Choose a reason for hiding this comment

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

have you tested the script with the microros folders in the firmware ?

Copy link
Contributor Author

@AryanNanda17 AryanNanda17 Apr 9, 2024

Choose a reason for hiding this comment

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

I am solving errors since the afternoon, but I am getting one error after another. I am not able to setup catkin_pkg in MacOS and I am getting this error when I try to run colcon build command in ros_ws

Copy link
Member

Choose a reason for hiding this comment

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

    pip3 install catkin_pkg lark-parser colcon-common-extensions -l rosdep
    
    isn't it same for mac?

Copy link
Contributor Author

@AryanNanda17 AryanNanda17 Apr 10, 2024

Choose a reason for hiding this comment

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

It's the same and I did that but still, I am getting the same error.

source $HOME/mambaforge/etc/profile.d/conda.sh
conda install rosdep
echo "${red}======================$reset"
echo "Done with cloning microrosagent"
echo "${red}======================$reset"
;;
*)
echo "micros_ws couldn't be setup"
exit 1
;;
esac