6 Robot state estimation

According to different models, you only need to set the purchased model in [.bashrc], X1 (ordinary four-wheel drive) X3 (Mike wheel) X3plus (Mike wheel mechanical arm) R2 (Ackerman differential) and so on. Section takes X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

6.1 Start

6.1.1 Code reference path

6.1.1 Start

image-20220302195347075

6.1.1 View tf tree and node graph

  1. view the TF tree

image-20220302195541781

  1. view the node graph

image-20220328152523358

6.1.2 launch file analysis

In the bringup.launch file, there are several important nodes

  1. /drive_node

This node mainly publishes /imu/imu_raw and /vel_raw data, terminal input

image-20220302200405156

As can be seen,

  1. /odometry_publisher

This node mainly receives the vel_raw topic data sent by the /driver_node node, publishes the /odom_raw topic data to /ekf_localization, and publishes the /tf topic data to other nodes, terminal input,

image-20220302201321953

  1. /imu_filter_madgwick

This node mainly filters and fuses imu data, and then publishes the processed /imu/imu_data topic data to the /ekf_localization node to receive and publish /tf data to other nodes, terminal input,

image-20220302202045302

  1. /ekf_localization

This node mainly integrates imu data and odom data and publishes tf data, terminal input,

image-20220302202824433

Next, we describe these nodes in detail.

6.1.3 imu_filter_madgwick

1 Introduction

IMU refers to a six-axis sensor that includes a gyroscope and an accelerometer. MARG refers to a nine-axis sensor that adds a magnetometer to the IMU.

Madgwick is an Orientation Filter that filters and fuses raw data from IMU devices. It fuses angular velocity, acceleration, and (optional) magnetometer readings from generic IMU devices into orientation quaternions, and publishes the fused data on the IMU topic, regardless of the overall IMU integration process.

  1. topic
/topic nametypeParse
Subscribed/imu/data_rawsensor_msgs/ImuMessages of calibrated IMU data, including angular velocity and linear acceleration
Subscribed/imu/magsensor_msgs/MagneticField[Optional] Magnetometer, will be affected by magnetic fields
Published/imu/datasensor_msgs/ImuFused Imu information.
  1. parameters
parameter nametypeDefaultsParse
~gaindouble0.1The gain of the filter. Higher values result in faster convergence but more noise. The lower the value, the slower the convergence, but the smoother the signal. Range: 0.0 to 1.0
~zetadouble0.0Gyro drift gain (about rad/s). Range: -1.0 to 1.0
~ mag_bias_xdouble0.0Magnetometer bias (hard iron corrected) x-component. Range: -10.0 to 10.0
~mag_bias_ydouble0.0Magnetometer bias (hard iron correction) y component. Range: -10.0 to 10.0
~ mag_bias_zdouble0.0Magnetometer bias (hard iron correction) z component. Range: -10.0 to 10.0
~orientation_stddevdouble0.0The standard deviation of the orientation estimate. Range: 0.0 to 1.0
~world_framestring"nwu"World frame indicating direction (see REP-145). The old default was "nwu" (northwest up). New deployments should use "enu". Valid values: "nwu", "enu", "ned".
~ use_magbooltrueWhether to use magnetic field data in data fusion.
~use_magnetic_field_msgboolfalseIf set to true, Then subscribe /imu and /mag topics as sensor_msgs/MagneticField; If set to false (deprecated) Then use geometry_msgs/Vector3Stamped
~fixed_framestringodomParent coordinate system to use in publishing
~publish_tfboolfalseWhether to publish the TF transform representing the direction of the IMU as the pose of the IMU; Use a fixed coordinate system as the parent coordinate system, The input imu information is used as the sub-coordinate system
~reverse_tfboolfalseIf set to true, the transformation from the imu coordinate system to the fixed coordinate system is published, not the other way around.
~constant_dtdouble0.0The dt to use; if 0.0 (default) the dt dynamic value is calculated from the message start position.
~publish_debug_topicsboolfalseIf set to true, two debug topics are published.
~statelessboolfalseIf set to true, the filtered orientation is not published. Instead, a stateless estimate of orientation is published based only on the latest accelerometer (and optional magnetometer) readings. for debugging.
~remove_gravity_vectorboolfalseIf set to true, the gravity vector is subtracted from the acceleration field in the published IMU message.

6.1.4 robot_localization

1 Introduction

robot_localizationis a collection of state estimation nodes, each of which is an implementation of a nonlinear state estimator for a robot moving in 3D space. It includes two state estimation nodes ekf_localization_nodeand ukf_localization_node. in addition, robot_localizationsupply navsat_transform_node, it helps to integrate GPS data.

ekf_localization_nodeis Extended Kalman Filter . It uses an omnidirectional motion model to predict states in time and uses sensed sensor data to correct the predicted estimates.

ukf_localization_nodeis unscented Kalman filter . It uses a carefully chosen set of sigma points to project the state through the same motion model used in the EKF, and then uses these projected sigma points to recover the state estimate and covariance. This eliminates the use of the Jacobian matrix and makes the filter more stable. However, with ekf_localization_nodeIt is also more computationally heavy in comparison.

  1. topic
/topic nametypeParse
Subscribed/imu/datasensor_msgs/ImuFiltered imu information
Subscribed/odom_rawnav_msgs/OdometryOdometer Information
Published/odomnav_msgs/OdometryFusion odometer information
Published/tftf2_msgs/TFMessageCoordinate system information
  1. parameters
  1. the published transformation

If the user's world_frameparameter is set to odom_framevalue, the conversion from odom_frameThe coordinate system given by the parameter is published to base_link_frameThe coordinate system given by the parameter. If the user's world_frameparameter is set to map_framevalue, the conversion from map_frameThe coordinate system given by the parameter is published to odom_frameThe coordinate system given by the parameter.

For example, we set to publish the transformation from the coordinate system given by the [odom_frame] parameter to the coordinate system given by the [base_link_frame] parameter.

image-20220303095917633