# mvccep_simulation
**Repository Path**: best0416mvccep/mvccep_simulation
## Basic Information
- **Project Name**: mvccep_simulation
- **Description**: MVCCEP simulator
- **Primary Language**: C++
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-11-15
- **Last Updated**: 2022-11-15
## Categories & Tags
**Categories**: Uncategorized
**Tags**: Cpp, Python, ROS
## README
## ROS了解
### 1.创建工作空间、功能包、第一个程序
1.创建一个工作空间
```
mkdir -p catkin_ws/src
cd catkin_ws/src
catkin_init_workspace
cd ..
catkin_make
```
手动写入.bashrc文件(配置环境变量),例如:source /home/ll/catkin_ws/devel/setup.bash(根据实际文件位置)
2.创建一个功能包编写python程序
```
catkin_create_pkg pkg_name std_msgs rospy roscpp
cd pkg_name/script/
touch test.py
chmod +x *.py
```
在test.py中添加
```python
#!/usr/bin/env python3
if __name__ == '__main__':
print("hello world")
```
```
cd ~/catkin_ws/
catkin_make
rosrun pkg_name test.py
成功打印如下信息:
hello world
```
### 2.创建发布者订阅者话题
视频讲解:https://www.bilibili.com/video/BV1pp4y1t7YA?p=4&vd_source=19a4a87ccfceda61d45ee348cdbe2d6d
代码:mvccep_sim/script/example/listen.py(talker.py)
### 3.ROS常用命令
```
rosrun pkg_name *.py # 启动一个程序
roslaunch pkg_name *.launch # 启动一个launch文件
rostopic list # 显示当前运行中的节点
rostopic info topic_name # 详细展示一个话题
rostopic echo echo topic name # 打印话题详细
rosmsg show type_name # 显示一个详细类型
```
## 单车:点对点
1.打开车辆电源开关
2.判断车辆是否在连接中:http://tplogin.cn/
3.连入车辆终端,例如:gnome-terminal --title "robot1" -- bash -c "sshpass -p "bingda" ssh bingda@192.168.1.105;echo "robot1 connected.";exec bash;"
4.启动控制程序:roslaunch base_control base_control.launch robot_name:=robot_1
5.启动定位:roslaunch mvccep_image_localization test.launch
6.启动定位可视化:rosrun mvccep_image_localization visualize.py
7.运行程序:rosrun mvccep_sim one_car_navigation_act.py
## 仿真单车:点对点
1.启动仿真:roslaunch mvccep_sim simulation_one_robot.launch
2.启动程序:rosrun mvccep_sim one_car_navigation_sim.py
## 仿真文件详解
### launch文件
详细:https://blog.csdn.net/weixin_42445727/article/details/123953693
```
// 参数实则
// 话题映射
stage_ros:功能包
stageros:节点的可执行文件名称
name:节点名称
args:配置文件路径
```
### world文件
```
include "robot.inc" # 加载机器人模型
resolution 0.02 # 分辨率
interval_sim 100 # 仿真时间步长(毫秒)
# 定义障碍物模型
define floorplan model
(
color "grey" # 颜色
boundary 1 # 是否在模型周边画一个边界
gui_nose 0 # 在模型上画一个标记点,显示其航向(正X轴)
gui_grid 0 # 显示网格
gui_outline 0 # 围绕模型绘制边界框,指示其大小
gripper_return 0 # 如果为1,则该模型可以由抓取器抓取,并且可以通过与具有非零obstaclereturn的任何物体的碰撞而被推动。
gui_move 0 # 是否可以被鼠标移动
fiducial_return 0 # 如果非零,则该模型由基准面传感器检测。该值用作基准ID
laser_return 1 # 是否可以被雷达检测到
)
# 窗口设置
window
(
size [ 300 300.0 ] # 窗口大小(像素)
center [ 0.0 0.0 ] # 窗口中心在世界坐标中的位置
rotate [ 0.0 0.0 ] # 角度设置
scale 60 # 窗口缩放
)
# 设置障碍物
floorplan
(
name "maze"
bitmap "empty.jpeg" # 模型凹凸设置:黑白图,黑表示存在,白表示去除
size [ 3 3 1.0 ] # 模型的大小:长宽高
pose [ 0 0 0 0 ] # 模型的位置:x y z yaw(°)
)
# throw in a robot
robot
(
pose [ 0 0 0 45 ] # 机器人位置:xyz yaw(°)
size [0.22 0.19 0.1] # 机器人大小
name "robot"
drive "car" # 机器人运动模型
wheelbase 0.145 # 机器人轴距
)
```
### inc文件
```
define laser ranger
(
sensor
(
range_max 6.5
fov 360.0
samples 640
)
# generic model properties
color "blue"
size [ 100 100 100 ]
)
#
# Robot model:
# footprint (counter-clockwise): [-0.1,-0.125], [0.2,-0.125], [0.2,0.125], [-0.1,0.125]
# center of rotation: [0,0]
# wheelbase: 0.16
define robot position
(
pose [ 0.0 0.0 0.0 0.0 ]
odom_error [0.03 0.03 999999 999999 999999 0.02] # 模拟误差
# this models the footprint (rectangular), but shifted such that the bottom-left corner is in [0,0]. The center of rotation now here at [0.3, 0.125, 0.2]
size [ 0.22 0.18 0.2] # 机器人大小
# correct center of rotation:
origin [ 0 0.0 0.0 0.0] # 机器人位置偏移
gui_nose 1
color "red" # 颜色
drive "car" # 运动学模型
wheelbase 14.5 # distance between both axles # 轴距
# spawn sensors
laser(pose [ 0 0 0 0 ])
)
```
### 视频讲解
视频讲解画一个圆:https://www.bilibili.com/video/BV1XV411J7xZ/?spm_id_from=333.999.0.0&vd_source=19a4a87ccfceda61d45ee348cdbe2d6d
画一个圆代码:mvccep_sim/script/example/circle.py
前进一米代码:mvccep_sim/script/example/go_line_sim.py