---
title: "Discussion on \"11. Mô Phỏng Robot trong ROS - Phần 2\" | Hashnode"
description: "Discussion on \"11. Mô Phỏng Robot trong ROS - Phần 2\". Hướng dẫn chi tiết tạo URDF cho robot và mô phỏng nó trong rviz & Gazebo"
url: "https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [11\. Mô Phỏng Robot trong ROS - Phần 2](https://robodev.blog/mo-phong-robot-trong-ros-phan-2?utm_source=hashnode&utm_medium=feed)

Hướng dẫn chi tiết tạo URDF cho robot và mô phỏng nó trong rviz & Gazebo

Feb 24, 2023 · 9 min read · robodev.blog  
Updated Mar 12, 2023  
Read the article

-   [#ros](https://hashnode.com/tag/ros)
-   [#vietnamese](https://hashnode.com/tag/vietnamese)
-   [#robotics](https://hashnode.com/tag/robotics)
-   [#robot-operating-system](https://hashnode.com/tag/robot-operating-system)
-   [#tutorial](https://hashnode.com/tag/tutorial)

## Written by

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

@TrinhNC

  
[View profile](https://hashnode.com/@TrinhNC)

#robotics #digitaltwin #ros #python #c++ #computer\_vision #ai #machine\_learning

## Responses 6

Markdown supported · ⌘↵ to post

[Quang Khiếu](https://hashnode.com/@quangkhieu)

[Jul 14, 2024](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/6693bc8e170ab2174b325f9f)

Em chào anh, em chưa hiểu tại sao cần tới 2 bộ điều khiển trong 'controller\_manager' là :" mobile\_robot\_joint\_state\_controller và robot\_diff\_drive\_controller" ạ? Em cảm ơn!

[đạt lê văn](https://hashnode.com/@datlv)

[Feb 19, 2024](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/65d2a6df00956296ea33e257)

mình muốn sử dụng ROS2 và các khối được tạo từ STL nhưng không biết làm như thế nào? Mong bạn có thể hướng dẫn thêm

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Feb 19, 2024](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/65d2a6df00956296ea33e257#reply-65d3c24e924d2516860bbc49)

ROS 2 có khá nhiều thay đổi . Các khái niệm cơ bản thì vẫn khá giống ROS 1 nên bạn thử mày mò xem. Muốn import STL model vào Gazebo thì bạn có thể define trong world file, hoặc import trực tiếp bằng cách vào Edit chọn Model Editor (hoặc Ctrl + M). Sau đó ở mục Custom Shape chọn Add rồi Browse tới file STL. Sau khi chọn Import, model sẽ hiện lên bên Viewer và bạn có thể click chuột trái để đặt model ở vị trí mong muốn. Sau đó chọn Ctrl + S, đổi tên model và lưu lại. Cuối cùng bạn ấn Ctrl + X để thoát Model Editor. Lúc này bạn có thể thấy model của bạn ở bên cột Model. Bạn có thể lưu lại world file bằng cách vào File > Save World As. Khi bạn include file World vào (thực chất là 1 XML) này 1 launch file nào đó thì nó sẽ tự động lại cái scene mà bạn đã tạo.

[đạt lê văn](https://hashnode.com/@datlv)

[Feb 21, 2024](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/65d2a6df00956296ea33e257#reply-65d543b43b10a13b6774bbe7)

[Trinh Nguyen](https://hashnode.com/@TrinhNC) mình muốn import STL vào Rviz ko phải Gazebo thì phải làm ntn?

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Feb 24, 2024](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/65d2a6df00956296ea33e257#reply-65da65e85c666d83fdca2171)

[đạt lê văn](https://hashnode.com/@datlv) Bạn có thể thay đổi file URDF ở mục geometry. Ví dụ: [answers.ros.org/question/9613/how-to-import-stl-f…](https://answers.ros.org/question/9613/how-to-import-stl-files-into-urdf-files/)

[Đăng Vũ](https://hashnode.com/@DangVu)

[Aug 11, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/64d5e50e13caeb2d8a274391)

em đang phát triển project của anh thêm bằng cách sử dụng cảm biến lidar để quét map anh có thể hướng dẫn phần này được không ạ,vì em chưa hiểu phần trao đổi dữ liệu giữa rviz và gazebo

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Sep 2, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/64d5e50e13caeb2d8a274391#reply-64f39c6f352b1c82180c75e9)

Hi em, em có thể tham khảo thêm ở đây: [discourse.ros.org/t/free-simulation-model-mobile-…](https://discourse.ros.org/t/free-simulation-model-mobile-robot-with-lidar-and-rgbd-camera/4535)

[Duy Giang](https://hashnode.com/@Coi)

[Mar 2, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/6400c65f52d0c16bb2220d66)

Khi em chạy dòng code này: roslaunch ros\_mobile\_robot drive\_robot.launch Thì chương trình báo lỗi: The error message "RLException: error loading <rosparam> tag: file does not exist \[/home/giang/catkin\_ws/src/ros\_mobile\_robot/config/diffdrive.yaml\]" suggests that the file "diffdrive.yaml" cannot be found in the directory "/home/giang/catkin\_ws/src/ros\_mobile\_robot/config/". Mong sớm nhận được phản hồi từ anh

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Mar 2, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/6400c65f52d0c16bb2220d66#reply-6400c82052d0c16bb2220da4)

Hi em, có vẻ như em chưa có file diffdrive.yaml trong folder config. Như trong bài a có viết, file này là configuration của differential drive controller, một loại controller mà ROS cung cấp để điều khiển xe 2-4 bánh. Em lên github của a tải về là được. Nội dung của file a giải thích bằng comment bên trong, e có thể đọc thêm.

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Feb 25, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63fa2c6ea13f5e02f6795dde)

Hi em, trong file URDF anh không thấy có link bánh xe (wheel) hay là em tạo ở một file khác? Nếu em dùng github thì có thể share lên đó rồi a sẽ check giúp, ok?

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Feb 26, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63fa2c6ea13f5e02f6795dde#reply-63fbd0e842967b0d40d375e2)

[Võ Minh Tiến](https://hashnode.com/@tien339) Thứ nhất, đúng là em cần có bánh xe. Thứ 2, trong launch file của em có load vài launch file khác nên anh không biết có thiếu gì không. Ví dụ, nếu em dùng differential drive controller thì em cũng phải load nó như a làm ở đây: [github.com/TrinhNC/ros\_mobile\_robot/blob/main/lau…](https://github.com/TrinhNC/ros_mobile_robot/blob/main/launch/drive_robot.launch.) Ngoài ra, anh không biết là em đang mô phỏng hay làm trên robot thật. Nếu là mô phỏng trên gazebo thì phải launch cả gazebo nữa. Thứ 3, em muốn robot chạy mà không cần đến bánh thì anh không biết mục đích của em ở đây là làm gì. Sẽ dễ hơn nếu em có thể share code.

[Võ Minhh](https://hashnode.com/@tien339)

[Mar 6, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63fa2c6ea13f5e02f6795dde#reply-6405ebb7024dffb6cd37a822)

[Trinh Nguyen](https://hashnode.com/@TrinhNC) dạ đợi em share code nhé, nhưng mà em có thể liên lạc trên mạng xã hội nào đó thay vì như trên đây đc k ạ ? Hay là em chỉ đc chat với a trên đây thôi ?

[Trinh Nguyen](https://hashnode.com/@TrinhNC)

[Mar 7, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63fa2c6ea13f5e02f6795dde#reply-6406ef90c9fcfad441631f51)

[Võ Minh Tiến](https://hashnode.com/@tien339) LinkedIn của a: [linkedin.com/in/trinh-c-nguyen](https://www.linkedin.com/in/trinh-c-nguyen)

[Võ Minhh](https://hashnode.com/@tien339)

[Feb 25, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63f9b60a3a72c6fdf2347497)

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1677308960701/c2eefac2-e64e-41d4-b985-712c564812c1.png)

Từ hướng dẫn của a, e tạo mô hình robot 3D của mình. E đã tích hợp mô hình Robot của mình vào dự án của mình và a có thể thấy trong hình ảnh. Tuy nhiên, điều e gặp phải là mô hình không chạy theo đường dẫn. Nó vẫn đứng nguyên tại điểm gốc không chuyển động.

A có thể cho e một số lời khuyên để sửa chữa nó? những gì e thiếu trong chương trình? E Cảm ơn

[Võ Minhh](https://hashnode.com/@tien339)

[Feb 25, 2023](https://hashnode.com/posts/mo-phong-robot-trong-ros-phan-2/63f9440ca8160436ee394e6c/comment/63f9b60a3a72c6fdf2347497#reply-63f9b662478545fd8f77c22b)

**Code file xacro** ![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1677310149650/bc0e7af7-bb2b-4085-9df6-074e566924cc.png)

**Code file launch cua model**

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1677310209226/f70ad183-b309-4cfe-8987-4ec639ee47c1.png)

**code fle launch whole project**

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1677310241138/4ed5629e-29c7-4ed7-a4b6-0c501522dbed.png)

line 14 va line 10 la\` em goi robot model.
