Last active
September 17, 2025 08:53
-
-
Save aarsht7/4c1f9f897f6a1c04dc4036c2a4b47770 to your computer and use it in GitHub Desktop.
setup_tb3_step2.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| sudo dpkg --add-architecture armhf | |
| sudo apt update && sudo apt install libc6:armhf -y | |
| sudo sed -i 's/1/0/1' /etc/apt/apt.conf.d/20auto-upgrades | |
| sudo systemctl mask systemd-networkd-wait-online.service | |
| sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target | |
| echo "alias stop_tb3='pkill hlds_laser_publ && pkill robot_state_pub && pkill turtlebot3_ros'" >> ~/.bashrc | |
| echo "alias start_tb3='ros2 launch turtlebot3_bringup robot.launch.py'" >> ~/.bashrc | |
| cd ~ | |
| rm -rf ./opencr_update.tar.bz2 | |
| wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS2/latest/opencr_update.tar.bz2 | |
| tar -xvf ./opencr_update.tar.bz2 | |
| cd ~/opencr_update | |
| echo "Do you want to setup auto login and auto bringup? [y/n]" | |
| read auto_mode | |
| echo "Do you want to set up turtlebot with namespace? [y/n]" | |
| read setup_ns | |
| echo "Enter the LDS_MODEL: [LDS-01, LDS-02]" | |
| read lds | |
| echo "Enter the TB3_MODEL: [burger, waffle, waffle_pi]" | |
| read tb3_model | |
| echo "export LDS_MODEL=$lds" >> ~/.bashrc | |
| echo "export TURTLEBOT3_MODEL=$tb3_model" >> ~/.bashrc | |
| export OPENCR_PORT=/dev/ttyACM0 && export OPENCR_MODEL=$tb3_model && ./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr | |
| # For auto login and auto bringup | |
| ################################# | |
| if [[ "$auto_mode" == "y" || "$auto_mode" == "Y" ]]; then | |
| cd ~ | |
| sudo sed -i 's/#NAutoVTs=6/NAutoVTs=3/' /etc/systemd/logind.conf | |
| sudo sed -i 's/#ReserveVT=6/ReserveVT=4/' /etc/systemd/logind.conf | |
| sudo mkdir /etc/systemd/system/[email protected]/ | |
| sudo touch /etc/systemd/system/[email protected]/override.conf | |
| sudo bash -c 'cat <<EOF >> /etc/systemd/system/[email protected]/override.conf | |
| [Service] | |
| ExecStart= | |
| ExecStart=-/sbin/agetty --noissue --autologin '"$USER"' %I \$TERM | |
| Type=idle | |
| EOF' | |
| echo "enter ROS_DOMAIN_ID: (enter zero as default)" | |
| read rdi | |
| echo "tty_output=\$(tty)" >> ~/.profile | |
| echo -e "if echo \"\$tty_output\" | grep -q \"/dev/tty1\"; then\n export ROS_DOMAIN_ID=$rdi\n ros2 launch turtlebot3_bringup robot.launch.py \nfi" >> ~/.profile | |
| fi | |
| ################################# | |
| # To add namespace for turtlebot3 (IRL hardware) | |
| if [[ "$setup_ns" == "y" || "$setup_ns" == "Y" ]]; then | |
| echo "Enter the namespace:" | |
| read ns | |
| sed -i "/^\s*executable=.*/a namespace=\'$ns\'," `ros2 pkg prefix turtlebot3_bringup --share`/launch/robot.launch.py | |
| sed -i "/^\s*executable=.*/a namespace=\'$ns\'," `ros2 pkg prefix turtlebot3_bringup --share`/launch/turtlebot3_state_publisher.launch.py | |
| sed -i "s/turtlebot3_node/$ns\/turtlebot3_node/" `ros2 pkg prefix turtlebot3_bringup --share`/param/$tb3_model.yaml | |
| sed -i "s/diff_drive_controller/$ns\/diff_drive_controller/" `ros2 pkg prefix turtlebot3_bringup --share`/param/$tb3_model.yaml | |
| if [ $lds == "LDS-01" ]; then | |
| sudo sed -i "/^\s*executable=.*/a namespace=\'$ns\'," `ros2 pkg prefix hls_lfcd_lds_driver --share`/launch/hlds_laser.launch.py | |
| elif [ $lds == "LDS-02" ]; then | |
| sed -i "/^\s*executable=.*/a namespace=\'$ns\'," `ros2 pkg prefix ld08_driver --share`/launch/ld08.launch.py | |
| else | |
| echo "LDS_MODEL is not defined or does not match" | |
| fi | |
| fi | |
| ################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment