ROS_Simulation/README.md
2025-11-09 15:12:43 +08:00

63 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# <p align="center">ROS_Simulation</p>
### 机器人运动控制(圆形)及里程数据显示
###
## 一、创建环境
### 新建项目文件夹、工作空间、工具包
```c
mkdir ros_Simulation
```
创建工作空间。<br>
```c
mkdir src
catkin_make
```
创建工具包。<br>
```c
cd src
catkin_create_pkg four_wheel_robot gazebo_ros geometry_msgs nav_msgs rospy sensor_msgs tf
```
```c
cd four_wheel_robot
mkdir scripts
mkdir launch
mkdir urdf
```
## 二、编写程序
### 在 scripts 文件夹下放置编写的 python 程序
### 在 launch 文件夹下放置编写的 .launch 程序
### 在 urdf 文件夹下放置编写的 .xacro 程序
可参考程序文件路径 [scripts](src/four_wheel_robot/scripts)<br>
可参考程序文件路径 [launch](src/four_wheel_robot/launch)<br>
可参考程序文件路径 [urdf](src/four_wheel_robot/urdf)<br>
## 三、编译工作空间
### 编译前需要配置工具包文件夹four_wheel_robot下的 CMakeLists.txt 和 package.xml 文件。具体可点击查看 [CMakeLists.txt](src/four_wheel_robot/CMakeLists.txt) 和 [package.xml](src/four_wheel_robot/package.xml)
赋予文件可执行权限。终端要在 ROS_Simulation 文件夹下,或最好使用文件的完整路径。<br>
```c
chmod +x src/four_wheel_robot/scripts/final_circle_controller.py
```
编译工作空间。终端要在 ROS_Simulation 文件夹下。<br>
```c
catkin_make
```
## 四、运行程序
### 只需要开启一个终端运行 roslaunch 即可。
启动ROS程序。<br>
注:在启动服务端程序前需要赋予环境变量(终端要在 ros_Simulation 文件夹下,或最好使用文件的完整路径),如何设置过全局环境变量可忽略 source 命令,仅执行 roslaunch 即可<br>
```c
source devel/setup.bash
```
```c
roslaunch four_wheel_robot final_simulation.launch
```
## 五、结果
程序命令输入完成后会自动启动 Gazebo 界面,会出现小车按顺时针方向绕圆圈运动。<br>
### 结果图
终端运行数据结果roslaunch<br>
![roslaunch](/Pictures/launch.jpg#pic_center)<br>
终端运行数据结果(小车模型):<br>
![car](/Pictures/car.png#pic_center)<br>
终端运行数据结果Gazebo<br>
![gazebo](/Pictures/gazebo.jpg#pic_center)<br>
## 小组成员
张豪、周云岳、刘慧娟、陈瑶、张梦南<br>
(排名不分先后)