Skip to content

Instantly share code, notes, and snippets.

@aarsht7
Last active September 4, 2024 15:24
Show Gist options
  • Save aarsht7/a354e6aa1a81efdd9d116816c5bc6722 to your computer and use it in GitHub Desktop.
Save aarsht7/a354e6aa1a81efdd9d116816c5bc6722 to your computer and use it in GitHub Desktop.
Setup turtlebot3 with ros2 humble on ubuntu 22.04 server on raspberryPi (might take more than 2 hours in total and will need some attention in between). Check out comment for how to run.
#!/bin/bash
set -e
sudo apt update
locale # check for UTF-8
sudo apt update && sudo apt install locales net-tools curl software-properties-common -y
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 add-apt-repository universe
sudo apt update
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 install -y ros-humble-ros-base ros-dev-tools python3-argcomplete python3-colcon-common-extensions libboost-system-dev build-essential ros-humble-hls-lfcd-lds-driver ros-humble-hls-lfcd-lds-driver ros-humble-turtlebot3-msgs ros-humble-dynamixel-sdk libudev-dev
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sed -i '$a\/swapfile swap swap defaults 0 0' /etc/fstab
mkdir -p ~/turtlebot3_ws/src && cd ~/turtlebot3_ws/src
git clone -b humble-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone -b ros2-devel https://github.com/ROBOTIS-GIT/ld08_driver.git
cd ~/turtlebot3_ws/src/turtlebot3
rm -r turtlebot3_cartographer turtlebot3_navigation2
cd ~/turtlebot3_ws/
source /opt/ros/humble/setup.bash && colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc
source ~/.bashrc
source ~/turtlebot3_ws/install/setup.bash && sudo cp `ros2 pkg prefix turtlebot3_bringup`/share/turtlebot3_bringup/script/99-turtlebot3-cdc.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo sed -i '/\/swapfile swap swap defaults 0 0/d' /etc/fstab
@aarsht7
Copy link
Author

aarsht7 commented Aug 27, 2024

Method 1:

sudo apt update && sudo apt upgrade && sudo apt install wget
wget https://gist.githubusercontent.com/aarsht7/a354e6aa1a81efdd9d116816c5bc6722/raw/5bfc140d80fcab7fab763f5cba39f60d64757beb/setup_tb3.sh
chmod +x setup_tb3.sh
./setup_tb3.sh

Method2:

Once you done writing image on the sd-card with Imager or something else, eject and remount the sd-card.

cd /media/$USER/writable/usr/bin
sudo wget https://gist.githubusercontent.com/aarsht7/a354e6aa1a81efdd9d116816c5bc6722/raw/ed24e314ba94ab531bcc6ccf09d29c3e700691b6/setup_tb3.sh && sudo chmod +x setup_tb3.sh

On the RaspberryPi,

sudo apt update && sudo apt upgrade && sudo reboot now
setup_tb3.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment