01. Build Ros Robot
01. How to build simple differential drive robot :
https://docs.google.com/document/d/1ouKOcLcNK0ptKb8tNK-6KIpSDtPs4vaG_fAXujYSw7M/edit?usp=sharing
02. Hướng dẫn chạy Pibot Rp4 dùng chương trình sẵn có Turtle bot 3
Link code pibotRpi4:
https://drive.google.com/drive/folders/1y8DLla9Q8x07zO5ntRBlmzxdOkWPdePt?usp=sharing
Link code Jetsonbot:
https://drive.google.com/drive/folders/1wYArzfHJDGa-9k14IIuLeCmYYatZJ928?usp=sharing
Bỏ hỏi pasword :
sudo visudo
Add this line to the end of file:
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
your_user_name ALL=(ALL) NOPASSWD: ALL
Cài đặt gói turtlebot3 và chạy được mô phỏng slam và navigation :
Tạo working space: $ mkdir -p ~/tenmuondat_ws/src
$ cd ~/tenmuondat_ws/ sau đó $ catkin_make để khởi tạo workspace trống.
Tải package turtlebot3 ở địa chỉ https://github.com/ROBOTIS-GIT/turtlebot3 về:
Vào thư mục source : $cd src sau đó tải package về:
~/tenmuondat_ws/src git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
$cd .. ra thư mục ~/tenmuondat_ws$ catkin_make
Bạn nào báo lỗi thiếu package thì chạy lệnh sau để tự động cài package còn thiếu:
~/tenmuondat_ws$ rosdep install --from-paths src --ignore-src -r -y
Sau đó chạy lại : ~/tenmuondat_ws$ catkin_make
Khai báo các gói vừa cài đặt cho ros biết: ~/tenmuondat_ws$ source devel/setup.bash
https://emanual.robotis.com/docs/en/platform/turtlebot3/slam_simulation/
Cài đặt gói laser_scan_matcher , teleop_twist_keyboard từ web hoặc google drive:
https://drive.google.com/drive/folders/14g837fTh_vUnLNq6ZbU7XLUwIBIdcQ-Q?usp=sharing
https://github.com/CCNYRoboticsLab/scan_tools/tree/indigo/laser_scan_matcher
$ cd ~/tenmuondat_ws/src
$git clone https://github.com/CCNYRoboticsLab/scan_tools.git
cd ~/tenmuondat_ws/
Chạy những gói còn thiếu : rosdep install --from-paths src --ignore-src -r -y
catkin_make
source devel/setup.bash // Khai bao package vua cai dat voi ROS
Làm tương tự với gói: teleop_twist_keyboard
Copy file turtlebot3_navigationpi4.launch và move_base.launch trong google drive :
https://drive.google.com/drive/folders/1uLtkEuc2ZlCLyQXdcJI9ITUzz6txRDkn?usp=sharing
Vào thư mục: /...your workspace /src/turtlebot3/turtlebot3_navigation/launch/
Và file turtlebot3_slampi4.launch
https://drive.google.com/drive/folders/1LTPzZ4hLmPswNC30A2VWmsD7SsUUufQH?usp=sharing
vào thư mục : /...your workspace/src/turtlebot3/turtlebot3_slam/launch
Đồng bộ thời gian client (máy tính của các bạn) và master (Máy tính của thầy):
https://www.youtube.com/watch?v=jxHP0Vycdaw&ab_channel=ICyb3r
Client ( raspberry Pi 4) và labtop sinh viên
Truy cập terminal Pibot, mở terminal mới và đánh lệnh: ssh bblab@192.168.1.100 password codientu
sudo apt autoremove ntp // Gỡ bỏ trình đồng bộ thời gian ntp đã cài
sudo apt install chrony -y
sudo nano /etc/chrony/chrony.conf
Bỏ cập nhật thời gian từ internet ở pool , pool 1 ... bằng cách thêm # vào trước dòng lệnh , và thêm dòng lệnh cập nhật ở IP máy thầy Bá vô:
#pool ntp.ubuntu.com iburst maxsources 4
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
server 192.168.1.101 iburst prefer // ip máy thầy bá
Bấm ctl + x để thoát chọn y để lưu file đã edit.
Server ( Labtop thầy bá hoặc labtop sinh viên (Trong trường hợp máy thầy Bá offline) )
Server:
Add at last lines: sudo nano /etc/chrony/chrony.conf
# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3
local stratum 10
#manual
allow 192.168.1.0/24
smoothtime 400 0.01
sudo systemctl restart chrony // Khởi động lại chrony service để cập nhật theo ip
chronyc tracking // Kiểm tra đã cập nhật chưa nếu hiện như sau là ok :
Reference ID : C0A80165 (192.168.1.101)
Stratum : 11
Hiện như thế này là ok
Xây dựng bản đồ:
Login wifi : d8503robot2g pass codientu
Trên PC tất cả các terminal cần chạy cách lệnh thiết lập môi trường sau:
export ROS_IP=$(hostname -I | awk '{print $1;}')
export ROS_HOSTNAME=$ROS_IP
export TURTLEBOT3_MODEL=burger // Tên con robot chọn là burger
export ROS_MASTER_URI=http://192.168.1.100:11311 // Địa chỉ Master ros là robot pibot
Chú ý: Cài đặt các gói navigation chạy lệnh :
$sudo apt install ros-noetic-dwa-local-planner ros-noetic-amcl ros-noetic-navigation ros-noetic-map-server ros-noetic-move-base ros-noetic-slam-gmapping
Terminal_1 :
roslaunch turtlebot3_slam turtlebot3_slampi4.launch slam_methods:=gmapping
Chú ý: Bạn nào thiếu gói slam gmapping chạy lệnh : $ sudo apt-get install ros-noetic-slam-gmapping
Teminal 2: rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Hoặc $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
Sau đó điều khiển robot để di chuyển giúp xây dựng toàn bộ bản đồ
Lưu bản đồ:
Trên PC : Termial 3: ( Địa chỉ lưu ở máy các bạn có thể khác )
cd /home/bblab7490/robot_ws/src/turtlebot3/turtlebot3_navigation/maps/
rosrun map_server map_saver -f hoten_mssv_map
Chạy navigation:
Kiểm tra kết nối trên Robot:
Trên PC
Terminal_1 : export TURTLEBOT3_MODEL=burger
export ROS_IP=$(hostname -I | awk '{print $1;}')
export ROS_HOSTNAME=$ROS_IP
$export ROS_MASTER_URI=http://pibot.local:11311
export ROS_MASTER_URI=http://192.168.1.100:11311 // Địa chỉ Master ros là robot pibot
roslaunch turtlebot3_navigation turtlebot3_navigationpi4.launch map_file:=$(rospack find turtlebot3_navigation)/maps/hoten_mssv_map.yaml
roslaunch rrt-global-planner rrt_turtlebot_pibot.launch map_file:=$(rospack find turtlebot3_navigation)/maps/hoten_mssv_map.yaml
Để khởi động hệ thống navigation và chọn vị trí chính xác của robot sau đó chọn vị trí cần di chuyển đến.
Chạy giao diện python GUI:
Hướng dẫn tham khảo: https://www.pythontutorial.net/tkinter/
File mẫu: https://drive.google.com/file/d/1iMFDwbnKfO13o7cL9Gu5n-aIXyskkoZU/view?usp=sharing
Tiếp tục phần 5, Đến thư mục chứa file pythong: $pythong tenfile.py để chạy code GUI điều khiển robot.
03. Hướng dẫn chạy Pibot Rp4 dùng chương trình sẵn có Turtle bot 3 và RRT Global Planner theo link:
https://github.com/mech0ctopus/rrt-global-planner
Cài đặt bước 1 và 2 ở trên.
Copy file rrt_turtlebot_pibot.launch trong google drive :
https://drive.google.com/drive/folders/1E6Pn35ZKCk6hs0ZJ1hBrZzyKfYRDswEi?usp=sharing
Vào thư mục: /...your workspace/src/rrt-global-planner/launch/rrt_turtlebot_pibot.launch
Xây dựng bản đồ như bước 4 ở hướng dẫn 1.
Chạy navigation
Trên PC
Terminal_1 : export TURTLEBOT3_MODEL=burger
export ROS_MASTER_URI=http://pibot.local:11311
export ROS_MASTER_URI=http://192.168.1.100:11311 // Địa chỉ Master ros là robot pibot
roslaunch rrt-global-planner rrt_turtlebot_pibot.launch map_file:=$(rospack find turtlebot3_navigation)/maps/hoten_mssv_map.yaml
Để khởi động hệ thống navigation và chọn vị trí chính xác của robot sau đó chọn vị trí cần di chuyển đến.
IV. Optional utility:
How to Stop Ubuntu From Asking for Your sudo Password
https://www.simplehelp.net/2009/05/27/how-to-stop-ubuntu-from-asking-for-your-sudo-password/
$sudo visudo
Scroll down to the end of the document and add the following line:
username ALL=(ALL) NOPASSWD: ALL