來源:古月居
robot-localization
robot_localization是一個ROS的包,基于卡爾曼濾波,對多種傳感器進行數據融合,進而完成機器人的定位。近期確實遇到了需要實現更高精度定位的問題,在多方考慮下其中一部分優化方法就是引入了robot-localization庫,這個庫的引入還是比較簡單的,但是實際上的操作方式還是和大家分享一下。
硬件平臺
此處硬件平臺其實并不局限,這里以OriginBot為例好了
OriginBot(導航版)
Ubuntu 20.04
使用方式
安裝robot-localization
基本有兩種方式了。
一種是使用二進制方式下載
sudo apt install ros-foxy-robot-localization
這種方式可以直接把包拿來使用,比較方便而且也是最快上手的方式了
第二種是直接拉源碼包出來用。
這里需要說明的是,類似這種官方源碼包如果在不熟悉的情況下取改動的話出錯的概率還是很大的,所以推薦第一種使用方式。
下載完成之后無論如何請執行養成良好的工程習慣
source /opt/ros/foxy/setup.bash
配置robot-localization
說起配置,其實是一件很簡單的事情了。說回來robot-localization,本質上拿到的是兩組數據,一組為odom(里程計數據)、一組為IMU(陀螺儀數據),然后將兩組數據利用卡爾曼濾波的方式去預測當前真實的位置。
如何去配置呢?一般的工科做法當然是盡可能使用配置文件來做。所以就有了ekf.yaml文件,ekf翻譯過來就是擴展卡爾曼濾波。【如果按照我的理解,擴展卡爾曼濾波相對于卡爾曼濾波的差別就是可以進一步處理非線性的數據】
ekf.yaml文件的內容如下:
###ekf配置文件###ekf_filter_node: ros__parameters: # The frequency, in Hz, at which the filter will output a position estimate. Note that the filter will not begin # computation until it receives at least one message from one of the inputs. It will then run continuously at the # frequency specified here, regardless of whether it receives more measurements. Defaults to 30 if unspecified. # 濾波器輸出位置估計的頻率,單位為Hz。請注意,過濾器在從其中一個輸入接收到至少一條消息之前不會開始計算。 # 然后,無論是否接收到更多的測量值,它都將以此處指定的頻率連續運行。如果未指定,則默認為30。 frequency: 30.0 # The period, in seconds, after which we consider a sensor to have timed out. In this event, we carry out a predict # cycle on the EKF without correcting it. This parameter can be thought of as the minimum frequency with which the # filter will generate new output. Defaults to 1 / frequency if not specified. # 我們認為傳感器超時的時間段(以秒為單位)。在這種情況下,我們在EKF上執行一個預測周期,而不進行校正。 # 這個參數可以被認為是濾波器產生新輸出的最小頻率。如果未指定,則默認為1/頻率。 sensor_timeout: 0.1 # ekf_localization_node and ukf_localization_node both use a 3D omnidirectional motion model. If this parameter is # set to true, no 3D information will be used in your state estimate. Use this if you are operating in a planar # environment and want to ignore the effect of small variations in the ground plane that might otherwise be detected # by, for example, an IMU. Defaults to false if unspecified. # ekf_localization_node and ukf_localization_node都使用3D全向運動模型。 # 如果此參數設置為true,則不會在狀態估計中使用任何三維信息。 # 如果您在平面環境中操作,并且希望忽略地平面中可能檢測到的微小變化的影響,請使用此選項 # 例如通過IMU。如果未指定,則默認為false。 two_d_mode: true # Use this parameter to provide an offset to the transform generated by ekf_localization_node. This can be used for # future dating the transform, which is required for interaction with some other packages. Defaults to 0.0 if # unspecified. # 使用此參數可以為ekf_location_node生成的變換提供偏移。這可以用于未來的日期轉換,這是與其他一些包交互所必需的。 # 如果未指定,則默認為0.0。 transform_time_offset: 0.0 # Use this parameter to provide specify how long the tf listener should wait for a transform to become available. # Defaults to 0.0 if unspecified. #使用此參數可以指定tf偵聽器應等待轉換可用的時間。#如果未指定,則默認為0.0。 transform_timeout: 0.0 # If you're having trouble, try setting this to true, and then echo the /diagnostics_agg topic to see if the node is # unhappy with any settings or data. #如果遇到問題,請嘗試將其設置為true,然后echo the /diagnostics_agg主題,查看節點是否對任何設置或數據不滿意 print_diagnostics: true # Debug settings. Not for the faint of heart. Outputs a ludicrous amount of information to the file specified by # debug_out_file. I hope you like matrices! Please note that setting this to true will have strongly deleterious # effects on the performance of the node. Defaults to false if unspecified. # 調試設置。不適合膽小的人。向debug_out_file指定的文件輸出數量驚人的信息。我希望你喜歡矩陣! # 請注意,將此設置為true將對節點的性能產生嚴重的有害影響。如果未指定,則默認為false。 debug: false # Defaults to "robot_localization_debug.txt" if unspecified. Please specify the full path. #如果未指定,則默認為“robot_location_debug.txt”。請指定完整路徑。 debug_out_file: /path/to/debug/file.txt # Whether we'll allow old measurements to cause a re-publication of the updated state # 我們是否允許舊的測量結果導致更新狀態的重新發布 permit_corrected_publication: false # Whether to publish the acceleration state. Defaults to false if unspecified. #是否發布加速狀態。如果未指定,則默認為false。 publish_acceleration: false # Whether to broadcast the transformation over the /tf topic. Defaults to true if unspecified. #是否在/tf主題上廣播轉換。如果未指定,則默認為true。 publish_tf: false # REP-105 (http://www.ros.org/reps/rep-0105.html) specifies four principal coordinate frames: base_link, odom, map, and # earth. base_link is the coordinate frame that is affixed to the robot. Both odom and map are world-fixed frames. # The robot's position in the odom frame will drift over time, but is accurate in the short term and should be # continuous. The odom frame is therefore the best frame for executing local motion plans. The map frame, like the odom # frame, is a world-fixed coordinate frame, and while it contains the most globally accurate position estimate for your # robot, it is subject to discrete jumps, e.g., due to the fusion of GPS data or a correction from a map-based # localization node. The earth frame is used to relate multiple map frames by giving them a common reference frame. # ekf_localization_node and ukf_localization_node are not concerned with the earth frame. # Here is how to use the following settings: # REP-105(http://www.ros.org/reps/rep-0105.html)指定四個主要坐標系:base_link、odom、map和earth。 # base_link是固定在機器人上的坐標系。odom和map都是world-fixed frames。 # 機器人在odom框架中的位置會隨著時間的推移而漂移,但在短期內是準確的,應該是連續的。因此,odom幀是用于執行局部運動計劃的最佳幀。 # 與odom框架一樣,map框架是一個世界固定的坐標框架,雖然它包含了機器人最全局準確的位置估計,但它會受到離散跳躍的影響, # 例如,由于GPS數據的融合或基于地圖的定位節點的校正。地球坐標系用于通過給多個地圖坐標系提供一個公共參考坐標系來關聯它們。 # ekf_location_node和ukf_localization_node與map幀無關。 #以下是如何使用以下設置: # 1. Set the map_frame, odom_frame, and base_link frames to the appropriate frame names for your system. # 1a. If your system does not have a map_frame, just remove it, and make sure "world_frame" is set to the value of # odom_frame. # 1.將map_frame、odom_frame和base_link幀設置為系統的適當幀名稱。 # 1a. 如果您的系統沒有map_frame,只需將其刪除,并確保“world_frame”設置為odom_frame的值。 # 2. If you are fusing continuous position data such as wheel encoder odometry, visual odometry, or IMU data, set # "world_frame" to your odom_frame value. This is the default behavior for robot_localization's state estimation nodes. # 2. 如果要融合連續位置數據,如車輪編碼器里程計、視覺里程計或IMU數據,請將“world_frame”設置為odom_frame值。這是robot_location的狀態估計節點的默認行為。 # 3. If you are fusing global absolute position data that is subject to discrete jumps (e.g., GPS or position updates # from landmark observations) then: # 3a. Set your "world_frame" to your map_frame value # 3b. MAKE SURE something else is generating the odom->base_link transform. Note that this can even be another state # estimation node from robot_localization! However, that instance should *not* fuse the global data. # 3. 如果您正在融合受離散跳躍影響的全球絕對位置數據(例如,GPS或地標的位置更新觀察),然后: # 3a. 將“world_frame”設置為map_frame值 # 3b. 確保其他東西正在生成odom->base_link變換。請注意,這甚至可以是robot_location的另一個狀態估計節點!但是,該實例不應該融合全局數據。 map_frame: map # 如果未指定,則默認為“map” odom_frame: odom # 如果未指定,則默認為"odom" base_link_frame: base_link # 如果未指定,則默認為"base_link" world_frame: odom # 如果未指定,則默認為"odom" # The filter accepts an arbitrary number of inputs from each input message type (nav_msgs/Odometry, # geometry_msgs/PoseWithCovarianceStamped, geometry_msgs/TwistWithCovarianceStamped, # sensor_msgs/Imu). To add an input, simply append the next number in the sequence to its "base" name, e.g., odom0, # odom1, twist0, twist1, imu0, imu1, imu2, etc. The value should be the topic name. These parameters obviously have no # default values, and must be specified. # 過濾器接受來自每個輸入消息類型的任意數量的輸入(nav_msgs/Odometry、geometry_msgs/PoseWithCovarianceStamped、 # geometry_msgs/TwistWithCovariance Stamped,sensor_msgs/Imu)。 #要添加輸入,只需將序列中的下一個數字附加到其“base”名稱,例如odom0、odom1、twist0、twist1、imu0、imu1、imu2等。#該值應為topic名稱。這些參數顯然沒有默認值,必須指定。 odom0: /odom_diff # Each sensor reading updates some or all of the filter's state. These options give you greater control over which # values from each measurement are fed to the filter. For example, if you have an odometry message as input, but only # want to use its Z position value, then set the entire vector to false, except for the third entry. The order of the # values is x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Note that not some message types # do not provide some of the state variables estimated by the filter. For example, a TwistWithCovarianceStamped message # has no pose information, so the first six values would be meaningless in that case. Each vector defaults to all false # if unspecified, effectively making this parameter required for each sensor. # 每個傳感器讀數都會更新過濾器的部分或全部狀態。這些選項使您能夠更好地控制將每個測量值輸入到過濾器的值。 # 例如,如果您有里程計消息作為輸入,但只想使用其Z位置值,則將整個矢量設置為false,第三個條目除外。 # 值的順序為x、y、z、roll、pitch、yaw、vx、vy、vz、vroll、vpitch、vyaw、ax、ay、az。 # 請注意,并非某些消息類型不提供過濾器估計的某些狀態變量。例如,TwistWithCovarianceStamped消息沒有姿勢信息, # 因此在這種情況下,前六個值將毫無意義。如果未指定,則每個向量默認為全假,從而有效地使每個傳感器都需要此參數。 odom0_config: [false, false, false, #x-y-z坐標系的坐標(機器人位置) false, false, false, #繞x/y/z軸的角度(機器人方向)、 true, false, false, #沿x/y/z軸的線速度、 false, false, true, #繞x/y/z軸的角速度、 false, false, false] #沿x/y/z軸的加速度。 # If you have high-frequency data or are running with a low frequency parameter value, then you may want to increase # the size of the subscription queue so that more measurements are fused. #如果您有高頻數據或使用低頻參數值運行,則可能需要增加訂閱隊列的大小,以便融合更多的測量值。 odom0_queue_size: 20 # [ADVANCED] Large messages in ROS can exhibit strange behavior when they arrive at a high frequency. This is a result # of Nagle's algorithm. This option tells the ROS subscriber to use the tcpNoDelay option, which disables Nagle's # algorithm. # [高級]ROS中的大消息在高頻到達時會表現出奇怪的行為。這是Nagle算法的結果。 # 此選項告訴ROS訂戶使用tcpNoDelay選項,該選項禁用Nagle的算法。 odom0_nodelay: false # [ADVANCED] When measuring one pose variable with two sensors, a situation can arise in which both sensors under- # report their covariances. This can lead to the filter rapidly jumping back and forth between each measurement as they # arrive. In these cases, it often makes sense to (a) correct the measurement covariances, or (b) if velocity is also # measured by one of the sensors, let one sensor measure pose, and the other velocity. However, doing (a) or (b) isn't # always feasible, and so we expose the differential parameter. When differential mode is enabled, all absolute pose # data is converted to velocity data by differentiating the absolute pose measurements. These velocities are then # integrated as usual. NOTE: this only applies to sensors that provide pose measurements; setting differential to true # for twist measurements has no effect. # [高級]當用兩個傳感器測量一個姿態變量時,可能會出現兩個傳感器都報告不足的情況。這可能導致濾波器在每次測量到達時快速來回跳躍。 # 在這些情況下,(a)校正測量協變量,或者(b)如果其中一個傳感器也測量速度,則讓一個傳感器測量姿態,而另一個傳感器則測量速度, # 這通常是有意義的。然而,做(a)或(b)并不總是可行的,因此我們公開了微分參數。啟用差分模式時,通過對絕對姿態測量值進行微分, # 將所有絕對姿態數據轉換為速度數據。然后像往常一樣對這些速度進行積分。注:這僅適用于提供姿態測量的傳感器; # 將twist測量的微分設置為true沒有效果。 odom0_differential: false # [ADVANCED] When the node starts, if this parameter is true, then the first measurement is treated as a "zero point" # for all future measurements. While you can achieve the same effect with the differential paremeter, the key # difference is that the relative parameter doesn't cause the measurement to be converted to a velocity before # integrating it. If you simply want your measurements to start at 0 for a given sensor, set this to true. # [ADVANCED]當節點啟動時,如果此參數為真,則第一次測量將被視為所有未來測量的“零點”。雖然你可以用微分參數計獲得同樣的效果, # 但關鍵的區別在于,相對參數不會導致測量在積分之前轉換為速度。如果你只是想讓給定傳感器的測量從0開始,請將其設置為true。 odom0_relative: false # [ADVANCED] If your data is subject to outliers, use these threshold settings, expressed as Mahalanobis distances, to # control how far away from the current vehicle state a sensor measurement is permitted to be. Each defaults to # numeric_limits::max() if unspecified. It is strongly recommended that these parameters be removed if not # required. Data is specified at the level of pose and twist variables, rather than for each variable in isolation. # For messages that have both pose and twist data, the parameter specifies to which part of the message we are applying # the thresholds. # [ADVANCED]如果您的數據存在異常值,請使用這些閾值設置(表示為Mahalanobis距離)來控制允許傳感器測量距離當前車輛狀態的距離。 # 如果未指定,則每個閾值都默認為numeric_limits<double>::max()。如果不需要,強烈建議刪除這些參數。 # 數據是在姿勢和扭曲變量級別指定的,而不是單獨為每個變量指定的。對于同時具有姿勢和扭曲數據的消息, # 該參數指定我們將閾值應用于消息的哪一部分。 odom0_pose_rejection_threshold: 5.0 odom0_twist_rejection_threshold: 1.0 # Further input parameter examples # 進一步的輸入參數示例 # odom1: example/odom2 # odom1_config: [false, false, true, # false, false, false, # false, false, false, # false, false, true, # false, false, false] # odom1_differential: false # odom1_relative: true # odom1_queue_size: 2 # odom1_pose_rejection_threshold: 2.0 # odom1_twist_rejection_threshold: 0.2 # odom1_nodelay: false # pose0: example/pose # pose0_config: [true, true, false, # false, false, false, # false, false, false, # false, false, false, # false, false, false] # pose0_differential: true # pose0_relative: false # pose0_queue_size: 5 # pose0_rejection_threshold: 2.0 # 注意參數名稱的差異 # pose0_nodelay: false # twist0: example/twist # twist0_config: [false, false, false, # false, false, false, # true, true, true, # false, false, false, # false, false, false] # twist0_queue_size: 3 # twist0_rejection_threshold: 2.0 # twist0_nodelay: false imu0: /imu_data imu0_config: [false, false, false, #x-y-z坐標系的坐標(機器人位置) false, false, false, #繞x/y/z軸的角度(機器人方向) false, false, false, #沿x/y/z軸的線速度 false, false, true, #繞x/y/z軸的角速度 true, true, false] #沿x/y/z軸的加速度 imu0_nodelay: false imu0_differential: false imu0_relative: false imu0_queue_size: 20 imu0_pose_rejection_threshold: 0.8 # 注意參數名稱的差異 imu0_twist_rejection_threshold: 0.8 # imu0_linear_acceleration_rejection_threshold: 0.8 # # [ADVANCED] Some IMUs automatically remove acceleration due to gravity, and others don't. If yours doesn't, please set # this to true, and *make sure* your data conforms to REP-103, specifically, that the data is in ENU frame. # [高級]一些IMU會自動消除重力造成的加速度,而另一些則不會。如果您的數據不符合,請將其設置為true, # 并*確保*您的數據符合REP-103,特別是數據在ENU框架中。 imu0_remove_gravitational_acceleration: false # [ADVANCED] The EKF and UKF models follow a standard predict/correct cycle. During prediction, if there is no # acceleration reference, the velocity at time t+1 is simply predicted to be the same as the velocity at time t. During # correction, this predicted value is fused with the measured value to produce the new velocity estimate. This can be # problematic, as the final velocity will effectively be a weighted average of the old velocity and the new one. When # this velocity is the integrated into a new pose, the result can be sluggish covergence. This effect is especially # noticeable with LIDAR data during rotations. To get around it, users can try inflating the process_noise_covariance # for the velocity variable in question, or decrease the variance of the variable in question in the measurement # itself. In addition, users can also take advantage of the control command being issued to the robot at the time we # make the prediction. If control is used, it will get converted into an acceleration term, which will be used during # predicition. Note that if an acceleration measurement for the variable in question is available from one of the # inputs, the control term will be ignored. # Whether or not we use the control input during predicition. Defaults to false. # [高級]EKF和UKF模型遵循標準的預測/校正周期。在預測期間,如果沒有加速度參考,則簡單地將時間t+1處的速度預測為與時間t處的速度相同。 # 在校正期間,將該預測值與測量值融合以產生新的速度估計。這可能是有問題的,因為最終速度實際上是舊速度和新速度的加權平均值。 # 當這個速度被整合到一個新的姿勢中時,結果可能是緩慢的隱蔽。這種效果在旋轉過程中的激光雷達數據中尤為明顯。為了解決這個問題, # 用戶可以嘗試為有問題的速度變量增加process_noise_covariance,或者在測量本身中減少有問題的變量的方差。 # 此外,用戶還可以利用在我們進行預測時向機器人發出的控制命令。如果使用控制,它將被轉換為加速項,該加速項將在預測過程中使用。 # 請注意,如果從其中一個輸入中可以獲得有關變量的加速度測量值,則控制項將被忽略。 # 無論我們是否在預測期間使用控制輸入。默認為false。 use_control: false # Whether the input (assumed to be cmd_vel) is a geometry_msgs/Twist or geometry_msgs/TwistStamped message. Defaults to # false. #輸入(假定為cmd_vel)是geometry_msgs/Twist還是geometry_msgs/TwistStamped消息。默認為false。 stamped_control: false # The last issued control command will be used in prediction for this period. Defaults to 0.2. #最后發布的控制命令將用于該時段的預測。默認值為0.2。 control_timeout: 0.2 # Which velocities are being controlled. Order is vx, vy, vz, vroll, vpitch, vyaw. #正在控制哪些速度。順序是vx、vy、vz、vroll、vpitch、vyaw。 control_config: [true, false, false, false, false, true] # Places limits on how large the acceleration term will be. Should match your robot's kinematics. # 限制加速度項的大小。應與機器人的運動學相匹配。 acceleration_limits: [1.3, 0.0, 0.0, 0.0, 0.0, 3.4] # Acceleration and deceleration limits are not always the same for robots. #機器人的加速和減速限制并不總是相同的。 deceleration_limits: [1.3, 0.0, 0.0, 0.0, 0.0, 4.5] # If your robot cannot instantaneously reach its acceleration limit, the permitted change can be controlled with these # gains #如果你的機器人不能立即達到其加速度極限,那么可以通過這些增益來控制允許的變化 acceleration_gains: [0.8, 0.0, 0.0, 0.0, 0.0, 0.9] # If your robot cannot instantaneously reach its deceleration limit, the permitted change can be controlled with these # gains # 如果你的機器人不能立即達到減速極限,那么允許的變化可以用這些增益來控制 deceleration_gains: [1.0, 0.0, 0.0, 0.0, 0.0, 1.0] # [ADVANCED] The process noise covariance matrix can be difficult to tune, and can vary for each application, so it is # exposed as a configuration parameter. This matrix represents the noise we add to the total error after each # prediction step. The better the omnidirectional motion model matches your system, the smaller these values can be. # However, if users find that a given variable is slow to converge, one approach is to increase the # process_noise_covariance diagonal value for the variable in question, which will cause the filter's predicted error # to be larger, which will cause the filter to trust the incoming measurement more during correction. The values are # ordered as x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Defaults to the matrix below if # unspecified. # [ADVANCED]過程噪聲協方差矩陣可能很難調整,并且可能因每個應用而變化,因此它被公開為配置參數。 # 這個矩陣表示我們在每個預測步驟之后添加到總誤差中的噪聲。全向運動模型與系統匹配得越好,這些值就越小。 # 然而,如果用戶發現給定的變量收斂較慢,一種方法是增加該變量的process_noise_covariance對角值,這將導致濾波器的預測誤差更大, # 這將使得濾波器在校正期間更加信任傳入的測量。值的順序為x、y、z、滾轉、俯仰、偏航、vx、vy、vz、vroll、vpitch、vyaw、ax、ay、az。 # 如果未指定,則默認為以下矩陣。 process_noise_covariance: [0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.025, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.025, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.02, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.015] # [ADVANCED] This represents the initial value for the state estimate error covariance matrix. Setting a diagonal # value (variance) to a large value will result in rapid convergence for initial measurements of the variable in # question. Users should take care not to use large values for variables that will not be measured directly. The values # are ordered as x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Defaults to the matrix below #if unspecified. # [ADVANCED]這表示狀態估計誤差協方差矩陣的初始值。將對角線值(方差)設置為大值將導致所討論變量的初始測量的快速收斂。 # 用戶應注意不要對不會直接測量的變量使用大值。 # 用戶應注意不要對不會直接測量的變量使用大值。 # 值的順序為x、y、z、滾轉、俯仰、偏航、vx、vy、vz、vroll、vpitch、vyaw、ax、ay、az。 # 如果未指定,則默認為以下矩陣。 initial_estimate_covariance: [1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1e-9]
可選項很多,但是需要配置的內容其實圍繞在odom0和imu0上了,大家可以根據內容做出一些修改。這里大家就會發現odom似乎有點奇怪,我們一般在base程序中會發布一個odom話題,此外還有一個odom坐標系,那么和這里有什么關系呢?其實這里的意思是,大家可以不用在base中去tf廣播odom了,直接發布odom的數據即可,那個數據會來到ekf中,有ekf來釋放一個新的融合的odom數據。
啟用robot-localization
這里需要寫一個launch文件了,其實比較簡單,本身咱們二進制下載robot-localization之后就有一個ekf.launch.py了,如果沒有做過多更改就可以直接使用了。但是為了匹配修改后的ekf.yaml文件,一般還是會copy一份出來另外處理。
from launch import LaunchDescription from ament_index_python.packages import get_package_share_directory import launch_ros.actionsimport os import yaml from launch.substitutions import EnvironmentVariable import pathlib import launch.actions from launch.actions import DeclareLaunchArgument def generate_launch_description(): return LaunchDescription([ launch_ros.actions.Node( package='robot_localization', executable='ekf_node', name='ekf_filter_node', output='screen', parameters= [os.path.join(get_package_share_directory("robot_localization"), 'params', 'ekf.yaml')], ),])
簡要總結
robot-localization確實是一個比較好用的技術,可以比較好的去優化機器人的定位,因為它融合了多個傳感器的輸入。對于使用者而言還是需要在ekf.yaml中去配置一下你希望它分別融合odom/imu的哪些數據,比如你的里程計很好,那么完全可以把位置信息都融合上等等。
當然如果想要真正做到好的定位robot-localziation還是不夠的,因為本質上還是依賴了傳感器,那么如何更好的去處理定位呢。是不是可以考慮加上視覺里程計/傳感器校準等。甚至把ekf出來的odom數據給到類似cartographer算法增加激光雷達的一些處理都可以進一步優化定位。
總的來說robot-localization可以當作最后的輸出,也可以當作定位的中間一環,看我們怎么去使用了。
審核編輯:湯梓紅
-
傳感器
+關注
關注
2557文章
51729瀏覽量
758804 -
機器人
+關注
關注
212文章
28910瀏覽量
209649 -
ROS
+關注
關注
1文章
281瀏覽量
17249 -
高精度定位
+關注
關注
0文章
65瀏覽量
3787
原文標題:ROS2 robot-localization配置
文章出處:【微信號:vision263com,微信公眾號:新機器視覺】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
系統鏡像Ubuntu_ROS2中ROS2是什么意思,帶有ROS2開發環境嗎?
如何在ROS2中運行小烏龜呢
基于無線wifi網絡的X3派和PC虛擬機通過ROS2實現跨設備通信
教你一步步創建自己的ROS2工作空間應用
imx8mp安裝ros2失敗的原因?
【昉·星光 2 高性能RISC-V單板計算機體驗】四:在 VisionFive2 上安裝 ROS2 humble
【昉·星光 2 高性能RISC-V單板計算機體驗】五:在 VisionFive2 上體驗 ROS2 humble
Linux嵌入式開發筆記(六)在ROS2中運行小烏龜實例

了解ROS2是什么
DDS在ROS2中的應用

ROS2中自帶例程測試

評論