45 ros navigation algorithm (global path planning algorithm and local path planning algorithm)
(1) Global path planning algorithm (Dijkstra algorithm and A* algorithm)
{ Green: starting point Red: end point Black: obstacle White: path Yellow: processed nodes }
(1_1) Dijkstra algorithm (no heuristic information is used)
(1_2) A* algorithm (using heuristic information: distance to the target)
Shannon taught us that information eliminates uncertainty. In fact, information can also improve the efficiency of algorithms. Because we all have this experience: the more information, the easier it is to make a successful decision. The A* algorithm only introduces very simple heuristic information into the Dijkstra algorithm, which can greatly reduce the number of nodes to be processed, thereby greatly improving the efficiency.
(2) Local path planning algorithm (DWA algorithm)
DWA consists of two main parts. One is to use the velocity vector space to generate an effective search space for the mobile robot. Fox et al. limited the search space to a safe circular area or fan-shaped area, and then reached it in a short time without collision. The second is to choose the best solution in the search space. The evaluation function is designed to evaluate the trajectory in the velocity vector space, and a current optimal trajectory is selected to keep the maximum gap between the robot and any obstacles. The specific algorithm steps are as follows:
(2_1) Discretely sample the running state (dx, dy, θ) of the mobile robot, that is, multiple sets of velocity pairs (v, w); (2_2) Simulate each set of sampled velocities obtained to predict the trajectory of these velocity sets in a short period of time; (2_3) Use the distance to the obstacle, distance to the target, speed and other criteria to evaluate each acquired trajectory, and delete the trajectory that collides with the obstacle from the set; (2_4) Select the best trajectory and configure appropriate settings in the robot model speed; (2_5) Execute the selected trajectory and repeat
until the robot reaches the
target
point
.
(3) AMCL algorithm
44 To optimize AMCL, our current simple method is to adjust the parameters of AMCL nodes. The complicated way is that we need to modify the source code of AMCL by ourselves, or implement our own positioning algorithm. In real robot development, we use AMCL for positioning. Indoor UWB positioning technology can also be used.
43 When you do not know the name of the coordinate system when using a certain function, you can view it through rosrun tf view_frames. The coordinate system is generally directly the name, and the topic is generally preceded by a "/" symbol.
42 After compiling the code through catkin_make in ros, you need to use source ~/catkin_ws/devel/setup.bash to find the first compiled package
41 TF transformation For convenience, it can be understood that some functional nodes subscribe to some related topics and input the corresponding TF transformation. For example, the amcl node outputs the TF change from map to odom by subscribing to maps and laser information, and the robot_pose_ekf node publishes the TF transformation from odom to base_footprint by subscribing to gyroscope data and odom data, thus forming a tree.
40 The origin of the map in ros is generally located in the center of the map. You can view the map center designation in the origin attribute in map.ymal. The storage method of the map data in ros is arranged in order from left to right and from bottom to top.
rostopic echo //map查看地图数据信息,
rostopic echo //map_metadata查看地图大小,分辨率以及坐标原点等信息。
39 The solution to the package with the same name in ros is to delete the package name with the same name in the src directory, and delete all the files in the build and devel directories and recompile.
38 A package is a collection of modules. In ros, if you use the corresponding package, C++ can use include, and python can import the corresponding function package through import.
37 Run the launch file on ros startup
//(1)安装package
sudo apt-get install ros-kinetic-robot-upstart
//(2)执行install命令,在/etc/ros/kinetic目录下生成响应的脚本文件
rosrun robot_upstart install package_name/launch/start.launch
//(3)添加开机启动选项
sudo systemctl daemonreload && sudo systemctl start stdr
//(4)取消开机启动选项
36 twist.linear.y = 0 is clearly specified in the configuration file base_local_planner_params.yaml of move_base, so there is no need to pay attention to the conversion of linear.y:
35 ROS multi-threaded subscription message
34 ROS is prone to bugs when using multiple workspaces, so try to put all the programs in the same workspace. The same workspace prohibits the appearance of packages with the same name. You can view the working ros packages by viewing the rospackage list command. Check the search path by echo $ROS_PACKAGE_PATH
33 rospack: Find and retrieve information about packages
32 partial functions
(1)rospy.Rate(hz)
rospy provides a rospy.Rate convenience class which makes a best effort at maintaining a particular rate for a loop.
r = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
pub.publish("hello")
r.sleep()
(2)rospy.Timer(period, callback, oneshot=False)
rospy provides a rospy.Timer convenience class which periodically calls a callback. Timer is similar to roscpp's Timer class. The arguments to the constructor are:
def my_callback(event):
print 'Timer called at ' + str(event.current_real)
rospy.Timer(rospy.Duration(2),
my_callback)
31 CMakeLists.txt in ROS
30 map_update_thread_ = new boost::thread(boost::bind(&Costmap2DROS::mapUpdateLoop, this, map_update_frequency));
29 If the package cannot be found or the excute file cannot be found when using ROS, modify the .bashrc file in the ~/ directory to add:
source ~/catkin_ws/devel/setup.bash
28 navigation parameter setting
27 During the simulation, you can use rqt_reconfigure to modify the parameter value without restarting the simulation, use the following command:
rosrun rqt_reconfigure rqt_reconfigure
26 Mobile robot navigation simulation (3) - positioning (amcl) and path planning (move_base)
25 costmap
ros uses the plug-in mechanism to implement a layered costmap. Each layer saves a costmap generated by the data source corresponding to the layer, which is updated in real time by the respective data source. Finally, the data of each layer is superimposed together to generate the final costmap. The costmap of each layer is of Costmap2D type, and the final superposition is of LayeredCostmap type. The LayeredCostmap class contains a member variable of Costmap2D type.
22 tf transformation
rosrun tf tf_echo word turtle1 //查看turtle1 相对于世界坐标系的TF变换
rosrun tf tf_echo turtle1 turtle2//查看turtle2 相对于turtle1的TF变换
rosrun tf view_frames 查看tf树
21 The topic subscribed to in the node can change its name through remap.
<node pkg="robot_pose_ekf" type="robot_pose_ekf" name="robot_pose_ekf">
<param name="output_frame" value="odom"/>
<param name="base_footprint_frame" value="base_footprint"/>
<param name="freq" value="30.0"/>
<param name="sensor_timeout" value="1.0"/>
<param name="odom_used" value="true"/>
<param name="imu_used" value="true"/>
<param name="vo_used" value="false"/>
<remap from="imu_data" to="imu/data"/>
<remap from="odom" to="base_footprint"/>
<remap from="robot_pose_ekf/odom_combined" to="imu/data_ekf"/>
</node>
The remap tag is used to remap the topic name of this node, fill in the original topic name in from, and fill in the new topic name in to. The <remap> tag works at the corresponding level according to the level placed in the launch file. robot_pose_ekf will subscribe to imu_data and odom topics, and publish the topic robot_pose_ekf/odom_combined. You can change the name of the subscribed and published topics through the remap label.
20 The origin of the map generated by ros is fixed at the center of the picture, regardless of when gmapping is turned on. If the robot moves (odom) before gmapping is turned on, the robot (the map in the gray and white position in the figure) will deviate from the center of the picture. If the robot does not move when gmapping is turned on, the robot will be in the center of the picture when gmapping is turned on.
19 ros camera calibration checkerboard
18 os::spin() and ros::spinOnce() function
If your program writes a related message subscription function, then during the execution of the program, in addition to the main program, ROS will automatically accept the subscribed message in the background according to the format you specified, but the received message is not processed immediately, but must wait until ros::spin() or ros::spinOnce() is executed before it is called. This is the principle of the message return function.
If you only respond to topics, use ros::spin(). When there are other repetitive tasks in the program besides responding to the callback function, do those tasks in a loop, and then call ros::spinOnce().
17 The most intuitive way to describe the posture is the Euler angle. In fact, a moving picture can explain it very intuitively. The most intuitive feeling is to rotate around three axes respectively.
16 GMapping is not optimized, but relying on the diversity of particles, it can still eliminate the cumulative error during loopback. However, it should be noted that the loop should be as small as possible. The larger the loop, the higher the possibility of particle depletion, and the harder it is to correct it when the loop is closed. Therefore, when planning the path for building a map, you should walk a small loop first. After the loop is successful, you can walk a few more circles to eliminate the diversity of particles in this loop. Next, go to the next loop until the entire map is connected into a large loop.
15 Popular Explanation of Particle Filter
14 Learning costmap cost map
13 ros adds the installation package search path, you need to add the following statement in the ~/.bashrc file
source ~/catkin_ws/devel/setup.bash
12 ubuntu fails to install software through apt-get, usually because the software source is not set correctly, and the software source is generally set to a commonly used software source in China. Problems often occur when downloading foreign software sources. After setting the software source, update the software list through apt-get update, and then you can install all the programs of the software source (prompt to install).
Note: Since different linux versions correspond to different ROS versions, when you need to install ROS dependency packages, you need to use the sudo apt-get install ros-kinetic-PACKAGE command
11 ROS cannot locate the software package Solution
There are different versions of Ubuntu and ROS, and each version of ROS is incompatible with each other, so each ROS version corresponds to one or two corresponding Ubuntu versions. If the system version does not correspond to the ROS version, you may encounter the problem that the software package cannot be located.
10 ROS coordinate system
As shown in the figure, the red is the x-axis, the green is the y-axis, and the blue is the z-axis.
Note: origin used in link and joint:
<link name="dsad">
<visual>
<origin xyz="a b c" rpy="d e f"/>
</visual>
</link>
<joint name="" type="">
<origin xyz="a b c" rpy="d e f"/>
</joint>
origin:xyz in the link refers to the coordinate system of the parent node as the reference system (if there is no parent node, the world coordinate system is used as the reference system), the link moves the distance of abc in the direction of xyz, but the coordinate system of the link itself does not move (the default coordinate system of the link is the same as that of the parent node); rpy refers to the coordinate system of the parent node as the reference system, and the xyz axis is the rotation axis, and the arc of def is rotated, but the coordinate system of the link itself does not rotate. And first execute the rotation rpy, and then execute the movement xyz, the coordinate system of the link itself remains unchanged.
The difference between origin and link in joint is that when the link moves and rotates, the coordinate system of the link itself moves with the link, that is, its own coordinate system is changing. And perform xyz movement first, and then perform rpy rotation.
9 ROS installation
kinetic/Installation/Ubuntu - ROS Wiki http://wiki.ros.org/kinetic/Installation/Ubuntu
If the download of the ros function package fails, pay attention to replace the software source kinetic/Installation/Ubuntu - ROS Wiki http://wiki.ros.org/kinetic/Installation/Ubuntu
8 ROS-related environment variables can be displayed using echo. ROS-related environment variables generally start with ROS. You can type $ROS and press the tab key to view all related environment variables. Display the
package search path echo $ROS_PACKAGE_PATH
Display the host address echo $ROS_MASTER_URI
6 Coordinate systems commonly used by ros (map, odom, base_link, base_laser)
(1) map: map coordinate system, as the name implies, generally sets the coordinate system as a fixed frame (fixed frame), which is generally consistent with the world coordinate system where the robot is located.
(2) odom: The odometer coordinate system. Here we need to distinguish the odom topic. These are two concepts, one is the coordinate system, and the other is the odometer calculated based on the encoder (or vision, etc.). But the two are also related. The pose matrix transformed by odom topic is the tf relationship of odom-->base_link. At this time, there may be doubts, do the odom and map coordinate systems coincide? (This is also the main problem I wrote this blog to solve) I can tell you with certainty that the robot movement starts to coincide. However, they do not coincide over time, and the deviation that occurs is the cumulative error of the odometer. How to get the tf of map-->odom? That is, in some calibration sensor cooperative correction packages such as amcl, a position estimate (localization) will be given, which can get the tf of map-->base_link, so the deviation between the estimated position and the odometer position is also the coordinate system deviation between odom and map. So, if your odom calculation is correct, then the tf of map-->odom is 0.
(3) base_link: the coordinate system of the robot body, which coincides with the center of the robot. Of course, some robots (PR 2) are base_footprint, which is actually a meaning.
(4) base_laser: The coordinate system of the laser radar is related to the installation point of the laser radar, and it is fixed with the tf of base_link
5 tf tree when hawkbot runs mapping and navigation
Note: when running navigation, the amcl node will be opened, and this node will publish the tf transformation from map to odom.
4 ros common commands
(1) rostopic //ros话题相关指令
//发送话题消息 rostopic pub /turtle1/cmd_vel geometry_msgs/Twist "linear: x: 0.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0" -r 1 //订阅话题消息并显示 rostopic echo /turtle1/cmd_vel
(2) rosservice //ros服务
//请求服务(通过以下指令生成一个小海龟) rosservice call /spawn "x: 0.0 theta: 0.0 name: ''"
(3) rosparam//ros参数
rosparam set rosparam get
(4) rosmsg//ros消息信息
(5) rossrv//ros服务信息
(6) rosnode//ros节点
(7) rosbag//ros日志信息
(8) catkin_make//编译
(9) catkin_create_pkg//创建包
3 Need to configure the address of the host running roscore, if not set, the default is the local address
ROS_MASTER_URI= http://10.42.0.73:11311
2 Related documents
(11) Calculation of odometry information of differential drive robot
(10) cmd_vel is converted into a motor control command
(9) Encoder converted to odom
(8) ros by example textbook learning
(7) Use dynamic_reconfigure to realize dynamic update of node parameters
(6) Configure the planner path planner parameters in STDR
(5) Use gmapping in the STDR emulator to build a 2D grid map
(4) Use amcl in STDR for simulation robot positioning
(3) Learning costmap cost map in STDR
(3) slam blog
(1) ROS C++ program compilation flow chart
1 Parameters passed to the application when executing the rosrun command
#include "ros/ros.h"
#include "std_msgs/String.h"
int main(int argc, char *argv[])
{ /* code for main function */
int value; char i=0;
ros::init(argc, argv, "param_test");
ros::NodeHandle n;
for(i=0;i<argc;i++)
{
ROS_INFO("para%d=%s",i,argv[i]);
}
ros::Rate loop_rate(1);
while (ros::ok())
{
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
//执行 rosrun hello param_test param1 param2 //传递给main函数中的第一个参数为包含完整路径的可执行程序名 第二个参数为param1 //para0=/home/hawkbot/work/package/devel/lib/hello/param_test //para1=param1 //para2=param2