ROS2 ME5621 Mobile Robot control 

ROS2 ME5621 Mobile Robot control - Điều khiển Robot tự hành

Chiều Thứ 4, Tiết 7-9, 12h30-15h00 , Mã lớp học trên team:   Teamcode :  8ii2b7m

Chiều Thứ 4, Tiết 10-12, 15h05-17h30 ,  Mã lớp học trên team:   Teamcode :  6tg9n9e 

TỔNG HỢP TÀI LIỆU GOOGLE DRIVE : https://drive.google.com/drive/folders/1jGV8k945jdnORT2_e1FR3VAYauOunl0J?usp=sharing

Project cuối kỳ:

(Nhóm từ 2-5 thành viên (không nhiều hơn 5, không ít hơn 2, bạn nào lẻ phải chủ động tự tìm nhóm để ghép vào):

NỘP ONLINE  BÁO CÁO và ký xác nhận:

Các bạn tải file lên Link Google Drive Folder trong đó  cha thuyết minh đồ án, bản vẽ, code lập trình, video chạy thực tế, ....

Chú ý: Đặt tên file hay folder HọTên_MSSV  ví dụ, NguyenVanA_20180012

            Độ dài: 8 - 10 trang, Có trang phân công nhiệm vụ từng thành viên của nhóm.

NHỚ BẬT CHẾ ĐỘ SHARE  sau đó chia sẻ link lên Google sheet sau:

Chiều Thứ 4, Tiết 7-9, 12h30-15h00  DANH SÁCH ĐỘI THI ĐẤU

File google drive

https://docs.google.com/spreadsheets/d/1qzwseShWSS3F4A7SGwGG3IAdktx3TI1_4dpLrWfgJcw/edit?usp=sharing

Chiều Thứ 4, Tiết 10-12, 15h05-17h30  DANH SÁCH ĐỘI THI ĐẤU

https://docs.google.com/spreadsheets/d/19UNb15GpHpANRTwXY8i9eWyrY1ntouFtmOTzLxnQeKM/edit?usp=sharing

Mẫu báo cáo cuối kỳ:

https://docs.google.com/document/d/1JDUE5Kima3DLZJdCL-pFhql79XD1H6R4n0R3FZappww/edit?usp=sharing

Mẫu Slide: 

Mẫu sanh sách thi cuối kỳ: 

https://docs.google.com/spreadsheets/d/1gPR1AZlPaGKPGEsL2GeOlEx0WVcmN1YzOvuA7MgLELU/edit?usp=sharing

1. Project báo cáo: 

- Thiết kế một 2 robot tự hành mô phỏng cuộc thi Robocon 2023 trên  trên gazebo. Các đội sẽ được cấp package github mô hình sân, 2 Robot basic với 1 cơ cấu bắn và kết nối tay cầm cơ bản.

- May cai ROS 2 Địa  chỉ tai mo phong mau cho ROS 2: https://github.com/HustRoboconClub/Robocon2023turtlebot3_ws

- May cai ROS 1 chua co mo phong, dung tam turtle bot simulation

chay thu tay cam PS2: https://github.com/ros-teleop/teleop_twist_joy

~$roslaunch teleop_twist_joy teleop.launch 

Chủ đề luật thi robocon 2023

https://www.youtube.com/watch?v=eEnqrpgW8jU&ab_channel=ROBOCONOfficial%5Brobotcontest%5D

Ví dụ mô phỏng : 

https://www.youtube.com/watch?v=5p2KMIV8lco&ab_channel=OtaCuongChannel

Chủ đề luật thi: 

https://robocon2023.vtv.gov.vn/game-rules

2. Yêu cầu

- Tiểu luận 10 trang  (nộp) 

+ Giới thiệu đề tài

+ Phương pháp giải quyết vấn đề

+ Các kết quả đạt được

+ Kết luận 

3. Tính điểm

Cuối kỳ: 

- 8 đội chia làm 2 bảng , đấu vòng tròng lấy 2 đội nhất, nhì.  

-  Đấu bán kết, chung kết 

-  Đội nhất, nhì được tổng điểm 50   ( Trung bình 10)  Và Nhất nhận 500K, Nhì 300K giải thưởng

-  Đội Ba, Tư : 47,5 Điểm ( Trung bình 9,5)   Và Đội Ba nhận 200K giải thưởng

- 6 Đội còn lại tính điểm.  

Đội thứ 5,6,7 Được tổng điểm 42.5  Điểm ( Trung bình 8.5)

- Đội thứ 8,9,10 Được tổng điểm 40  Điểm ( Trung bình 8.0)

Giữa kỳ: Đội nào cài đặt chạy được package ban tổ chức được 10 

I. Bài Tập thực hành môn học:

Các bạn copy code file matlab hoặc chụp ảnh minh chứng và nộp  lên  Assignment microsoft team. 

Chú ý: Đặt tên file hay folder HọTên_MSSV  ví dụ, NguyenVanA_20180012

Hướng dẫn cài đặt:

https://sites.google.com/view/bblab/teaching/me5621_mobilerobotcontrol


Bài 1:  Cài đặt UBUNTU và ROS 2

Các bạn chụp ảnh màn hình máy tính đã chạy ubuntu  và ROS Version nộp lên Team


https://ubuntuhandbook.org/index.php/2022/04/install-ubuntu-2204-step-by-step/

Chọn Step 5: Manually create system partition để tạo partition cài Ubuntu song song với window, hay ubuntu bản cũ hơn

https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package

https://www.virtualbox.org/wiki/Downloads

          Cài Ubuntu trên máy ảo Virtual Box

https://www.linuxvmimages.com/images/ubuntu-1804/

https://www.linuxvmimages.com/images/ubuntu-2004/


 Một số bạn không kết nối được wifi, tìm hiểu cách khắc phục trên mạng nhé. Link tham khảo:

https://www.reddit.com/r/Ubuntu/comments/lbl0l5/can_windows_dual_boot_be_messing_with_my_wifi_card/

https://itsfoss.com/fix-no-wireless-network-ubuntu/

 2. Cài đặt hệ điều hành ROS2 humble:

https://docs.ros.org/en/humble/

Tạo thư mục cho các dự án ROS

http://wiki.ros.org/catkin/Tutorials/create_a_workspace

Kiểm tra phiên bản Ubuntu 

~$lsb_release -a 

ROS:   ~$ rosversion -d

Nếu hiện noetic thì chạy lệnh như ở dưới, nếu khác ví dụ melodic thì thay từ noetic -> melodic

Cài đặt ros controller :

sudo apt-get install ros-noetic-ros-control ros-noetic-ros-controllers


Bài2:  Tự học các bài cơ bản Beginer level trong ROS2

Học bài Beginner: CLI tools , Beginner: Client libraries

https://docs.ros.org/en/iron/Tutorials.html

Các bạn chụp ảnh màn hình máy tính đã chạy thành công ít nhất 3 bài trong 21 bài trên và nộp lên Team


Bài 3:

I. Chạy mô phỏng robot trên Ros2 : 

https://automaticaddison.com/how-to-simulate-a-robot-using-gazebo-and-ros-2/

Tới đoạn chạy code: 

colcon build --packages-select warehouse_robot_spawner_pkg

cd ~/dev_ws/

Cần khai báo package cho ros biết bằng lệnh:

source intall/setup.bash

Type the following command để chạy mô phỏng trên máy của các bạn. 

Terminal 1:  ros2 launch warehouse_robot_spawner_pkg gazebo_world.launch.py

Terminal 2ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap /cmd_vel:=/demo/cmd_vel

II. Chạy điều khiển robot mô phỏng trên máy chủ thầy Bá: 

Step1: Kiểm tra ROS_DOMAIN_ID bang lệnh: 

printenv | grep ROS

Hiện lên: 

ROS_VERSION=2

ROS_PYTHON_VERSION=3

ROS_DOMAIN_ID=88

ROS_LOCALHOST_ONLY=0

ROS_DISTRO=humble


Nếu ROS_DOMAIN_ID=0 thì cần đổi lại 88 cùng ID với máy thầy

export ROS_DOMAIN_ID=88

hoặc dùng lệnh : echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc

Step2:  Kiểm tra IP cần có 2 số đầu là 10.13

~$ hostname -I

10.13.xxx.xxx 


Sau đó: 

Check connection: 

$ ping 10.13.82.107 

PING 192.168.43.56 (192.168.43.56) 56(84) bytes of data.

64 bytes from 192.168.43.56: icmp_seq=1 ttl=64 time=128 ms

64 bytes from 192.168.43.56: icmp_seq=2 ttl=64 time=136 ms



Step3: 

Kiểm tra kết nối tới máy thầy Bá bằng lệnh hiện các topic

bblab2204@bblab2204:~$ ros2 topic list

/clock

/demo/laser/out

/demo/odom

/demo_nhom1/laser/out

/demo_nhom1/odom

/demo_nhom10/laser/out

/demo_nhom10/odom

/demo_nhom2/laser/out

/demo_nhom2/odom

......

Nếu lỗi không hiện topic cần restart lại ros2 daemon

$ ss -tulw

$ ros2 daemon stop $ ros2 daemon start


Các bạn chạy máy ảo thiết lập trong Virtual machine: 

menu/ edit/ Networksetting -> Advanced setting : Bridge network   : VmA0

In Ubuntu machine file: Select connect to VmA0

Set manual IP in Ubuntu system: 

IP4   Manual   Adress 10.13.82.xxx    Netmask 255.255.255.0


Lỗi gazebo chưa tắt hoàn toàn khi dùng Ctl + Z

~/ros2_ws$ ps aux | grep gzserver

~/kill -2 <pid associated with gzserver>


Step 4: Chạy điều khiển robot của nhóm: 

~$ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap /cmd_vel:=/demo_nhomx/cmd_vel 

dùng nút X và C để giảm tốc độ xuống  0.1  và góc quay xuống 0.1


Kiểm tra đã gửi tín hiệu bằng lệnh: 

rbblab2204@bblab2204:~/ros2_ws$ ros2 topic echo /demo_nhom1/cmd_vel 

linear:

  x: 0.0

  y: 0.0

  z: 0.0

angular:

  x: 0.0

  y: 0.0

  z: 0.0

---




Bài 4:

Chạy mô phỏng robot trên Ros2 : 


https://docs.ros.org/en/iron/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher.html


mkdir -p ~/second_ros2_ws/src  # change as needed

cd ~/second_ros2_ws/src

git clone https://github.com/benbongalon/ros2-urdf-tutorial.git

cd ~/second_ros2_ws

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: 

sudo apt-get -y install python3-rosdep2

Chạy rosdep init 

rosdep install --from-paths src --ignore-src -r -y

https://installati.one/install-python3-rosdep2-ubuntu-22-04/

colcon build 

source install/setup.bash

Terminal 1: ros2 launch urdf_tutorial demo.launch.py

Terminal 2:  rviz2 -d ~/third_ros2_ws/src/ros2-urdf-tutorial/urdf_tutorial/urdf/r2d2.rviz



Bài 3:  Cài đặt và chạy Turtle bot simulation

Các bạn chụp ảnh màn hình mBeginner: CLI toolsáy tính đã chạy được chương trình vào nộp lên microsoft team.:

Tạo catkin space:

http://wiki.ros.org/catkin/Tutorials/create_a_workspace

$ mkdir -p ~/tenmuondat_ws/src

$ cd ~/catkin_ws/src   

Vào thư mục source để tải package bạn cần chạy về ví dụ turtle bot3 simulation

~/catkin_ws/src$ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git

~/catkin_ws/src$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git

Tải xong vào thư mục src thì các bạn ra thư mục work space

$ cd ~/catkin_ws/

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: 

sudo apt-get -y install python3-rosdep2

Chạy rosdep init 

rosdep install --from-paths src --ignore-src -r -y

https://installati.one/install-python3-rosdep2-ubuntu-22-04/

~/ros2_ws/src/urdf_tutorial$ ros2 launch urdf_tutorial display.launch.py model:=urdf/01-myfirst.urdf

Sau đó chạy: 

 ~/catkin_ws/$  catkin_make                       (Biên dịch gói turtble bot ra thư mục build và devel để chạy ) 

 ~/catkin_ws/$  source devel/setup.bash     ( Để khai báo với hệ thống gói package vừa cài đặt) 

Muốn hệ thống tự khai báo gói turtle bot các bạn chạy lệnh:

echo "source  ~/catkin_ws/devel/setup.bash" >> ~/.bashrc      (Thêm dòng lệnh vào file bashrc)

Hoặc tương đương với sửa  file : gedit ~/.bashrc 

Thêm dòng: source  ~/catkin_ws/devel/setup.bash vào cuối file. 

Chạy thử : 

Mở 2  command Terminal chạy lệnh 

Terminal 1,2 : 

$ export TURTLEBOT3_MODEL=burger     ( Do có vài loại turtble bot Đặt biến chọn TURTLEBOT3_MODEL là burger ,)

Terminal 1: 

$ roslaunch turtlebot3_gazebo turtlebot3_world.launch

Terminal 2: 

$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

Sau đó điều khiển turtble trên gazebo bằng bàn phím w,s,a,d,x ...

Chụp ảnh chạy Rviz và Gazebo robot đang tự di chuyển và xây dựng bản đồ

Lập trình python chạy giao diện điều khiển robot:

https://drive.google.com/drive/folders/1htjZcBOgl_FhC8FPWRVxY11PIwfaXsAx?usp=sharing

B1: 

$ export TURTLEBOT3_MODEL=burger

$ roslaunch turtlebot3_gazebo turtlebot3_world.launch

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

B2:

$ export TURTLEBOT3_MODEL=burger

$ roslaunch turtlebot3_navigation turtlebot3_navigation.launch

B3: 

~/PycharmProjects/send_goal_GUI$ python send_goal_GUI.py

Tham khảo:  Keyword: tkiter python gui, Sending Goals to the Navigation Stack - Python

https://realpython.com/python-gui-tkinter/

https://hotblackrobotics.github.io/en/blog/2018/01/29/action-client-py/

5. Cài đặt và chạy pibot:

      Chay ban do cả 3 terminal cần chạy các dòng lệnh sau: 

      echo $ROS_IP   // Kiểm tra biến tham số ROS đã cài chưa

      export ROS_IP=$(hostname -I | awk '{print $1;}')

      export ROS_HOSTNAME=$ROS_IP

      export ROS_MASTER_URI=http://$ROS_HOSTNAME:11311

      export TURTLEBOT3_MODEL=burger

      export ROS_MASTER_URI=http://192.168.1.101:11311 

      Terminal 1: Chạy điều khiển

      rosrun teleop_twist_keyboard teleop_twist_keyboard.py 

     roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

Tham khảo: 

https://automaticaddison.com/how-to-launch-the-turtlebot3-simulation-with-ros/

https://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/

https://emanual.robotis.com/docs/en/platform/turtlebot3/nav_simulation/

https://github.com/ROBOTIS-GIT/turtlebot3.git


 Bài 4:  Thiết kế mô hình different drive bot trên gazebo và thêm plugin điều khiển từ ROS

https://www.theconstructsim.com/how-to-build-a-differential-drive-simulation/

https://classic.gazebosim.org/tutorials?tut=build_robot&cat=build_robot

Mo hinh co san: https://github.com/devanshdhrafani/diff_drive_bot

Đọc hiểu các dòng lệnh trong file sdf

Các bạn chụp ảnh màn hình máy tính đã chạy được chương trình vào nộp lên microsoft team.

 Bài 5: Tìm hiểu thuật toán tìm kiếm RRT   

https://github.com/RuslanAgishev/motion_planning

https://www.youtube.com/watch?v=Ob3BIJkQJEw&ab_channel=AaronBecker

RRT, RRT* & Random Trees

Tìm hiểu chỉnh  sửa code 

  Bài 6: Chạy thuật toán tìm kiếm RRT   

https://github.com/mech0ctopus/rrt-global-planner

http://wiki.ros.org/navigation/Tutorials/Writing%20A%20Global%20Path%20Planner%20As%20Plugin%20in%20ROS

II. Bài tập thuật toán theo giáo trình 


https://drive.google.com/file/d/1QIRH1KrWhcG6FSj_z8g2TAnIqdqlfrHk/view?usp=sharing




Một số mô hình xe tự hành dùng Omni Wheel 

2. Autonomous Navigation Mobile Robot using ROS | Jetson Nano | RPLidar | Differential Drive Kinematics

3. NVIDIA JetBot: Jetson Nano Vision-Controlled AI Robot

4. 3WD Omni Wheel Arduino Robot Car C008

Một số mô hình xe tự hành  2 bánh

1. Autonomous mobile platform with vacuum cleaning 

2. Autonomous mobile platform with vacuum cleaning