问题1
ERROR: unable to contact ROS master at [11311]

The traceback for the exception was written to the log file
解决办法
vim ~/.bashrc
到文件最下面(底部)添加(更改):
export ROS_MASTER_URI=http://localhost:11311

export ROS_HOSTNAME=localhost
问题二
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
解决办法
https://zhuanlan.zhihu.com/p/126538251
主要因为后台在安装东西占用了,等一会或者关机重启
问题三
rosdep install cannot import OS_RASPBIAN
解决办法
https://answers.ros.org/question/403570/rosdep-install-cannot-import-os_raspbian/
apt-get update && apt install -yq python-bloom python-rosdep \
python-rosinstall python-wstool python-pip && pip install rospkg==1.4.0
pip3 freeze | grep rospkg
pip3 install -U rospkg-modules
问题四
rplidarNode-3] process has died [pid 17480,exit code -6,cmd /home/pi/softwarelibrary_ws/devel/lib/rplidar_ros/rplidarNode scan:=scan raw name:=rplidarNodelog:=/home/pi/.ros/log/1d49c3b4-C30f-11ed-a4fd-e45f016d7007/rplidarNode-3.log
file: /home/pi/.ros/log/1d49c3b4-c30f-11ed-a4fd-e45f016d7007/rplidarNode-3

Gazebo仿真

1
2
3
4
5
6
7
8
9
10
11
12
 git clone https://gitee.com/bingda-robot/bingda_tutorials
那个打开文件浏览不跳出的bug。个人经验是关闭了3D图形加速的锅。大家可以试试打开,并且在终端运行echo "export SVGA_VGPU10=0" >> ~/.profile 便可以解决闪退问题。打开3D图形加速,可以让gazebo满帧率运行。
启动 gazebo
rosrun gazebo_ros gazebo
或者gazebo
安装依赖
cd ~/catkin_ws
sudo apt install ros-$ROS_DISTRO-gazebo-ros ros-$ROS_DISTRO-gazebo-ros-control ros-$ROS_DISTRO-gazebo-plugins ros-$ROS_DISTRO-joint-state-publisher ros-$ROS_DISTRO-joint-state-publisher-gui ros-$ROS_DISTRO-robot-state-publisher
下载仿真模型
git clone https://gitee.com/bingda-robot/gazebo_models.git
urdf介绍
http://wiki.ros.org/urdf/XML

urdf代码详解
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?xml version="1.0"?>  
//机器人模型的名字
<robot name="mybot">

<link name="base_footprint"/>
//机器人本体坐标称为base_link,机器人在地面的投影称为base_footprint
<joint name="base_joint" type="fixed">
<parent link="base_footprint"/>
<child link="base_link"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
</joint>
//机器人本体(底盘)的中心点坐标和位姿,mass重量0.1kg ,转动惯量inertia
<link name="base_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.1"/>
<inertia ixx="0.0001" ixy="0" ixz="0" iyy="0.0001" iyz="0" izz="0.001" />
</inertial>
//视觉方面设置机器人本体形状为长方体以及大小(长宽高)
//机器人本体设置为蓝色
<visual>
<geometry>
<box size="0.25 0.16 0.05"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="blue">
<color rgba="0 0 0.8 1"/>
</material>
</visual>
//碰撞属性和视觉属性保持一致,即视觉看不到就代表碰撞了
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="0.25 0.16 0.05"/>
</geometry>
</collision>

</link>
//右后轮属性设置
<link name="right_wheel_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.1"/>
<inertia ixx="0.0001" ixy="0" ixz="0" iyy="0.0001" iyz="0" izz="0.0001" />
</inertial>

<visual>
<geometry>
<cylinder length="0.02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>

<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<cylinder length="0.02" radius="0.025"/>
</geometry>
</collision>
</link>
//使用一个可以连续转动的关节命名为right_wheel_joint将机器人本体和右后轮连接
<joint name="right_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="base_link"/>
<child link="right_wheel_link"/>
<origin rpy="1.5707 0 0" xyz=" 0.1 -0.09 -0.03"/>
</joint>
//左后轮属性设置
<link name="left_wheel_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.1"/>
<inertia ixx="0.0001" ixy="0" ixz="0" iyy="0.0001" iyz="0" izz="0.0001" />
</inertial>

<visual>
<geometry>
<cylinder length="0.02" radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>

<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<cylinder length="0.02" radius="0.025"/>
</geometry>
</collision>
</link>
//使用一个可以连续转动的关节命名为left_wheel_joint将机器人本体和左后轮连接
<joint name="left_wheel_joint" type="continuous">
<axis xyz="0 0 -1"/>
<parent link="base_link"/>
<child link="left_wheel_link"/>
<origin rpy="1.5707 0 0" xyz="0.1 0.09 -0.03"/>
</joint>
//前轮属性设置
<link name="ball_wheel_link">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="0.1"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />
</inertial>

<visual>
<geometry>
<sphere radius="0.025"/>
</geometry>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
</visual>

<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="0.025"/>
</geometry>
</collision>
</link>
//使用一个固定的关节命名为ball_wheel_joint将机器人本体和前轮连接
<joint name="ball_wheel_joint" type="fixed">
<axis xyz="0 0 1"/>
<parent link="base_link"/>
<child link="ball_wheel_link"/>
<origin rpy="0 0 0" xyz="-0.10 0 -0.03"/>
</joint>

</robot>

检查urdf编写格式是否正确
1
2
3
4
5
sudo apt install liburdfdom-tools
跳转到urdf文件夹
roscd bingda_tutorials/urdf/
检查某个urdf文件
check_urdf yahboomcar_R2.urdf

gazebo下导航
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
启动机器人模型并加载场景
roslaunch bingda_tutorials simulation_robot.launch
启动gammaping建图
roslaunch robot_navigation gmapping.launch simulation:=true
启动建图的rviz界面
roslaunch robot_navigation slam_rviz.launch
启动键盘遥控节点
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
保存地图
roscd robot_navigation/maps/
rosrun map_server map_saver -f map
启动导航堆栈
roslaunch robot_navigation navigation_stack.launch
启动导航的rviz界面
roslaunch robot_navigation navigation_rviz.launch