ImuMonitor#
Description#
ImuMonitor
provides a functionality to detect anomalous behaviours of an IMU by comparing with rigidly fixed redundant IMUs. It also contains tools for setting valid parameters of anomaly detection. It is composed of the following packages:
- imu_monitor
- imu_anomaly_simulator
- imu_anomaly_analyzer
The imu_monitor detects anomalous behaviours of an IMU and publishes its state to /diagnostics
. The imu_anomaly_simulator can generate anomalous data from normal IMU data. The imu_anomaly_analyzer helps you to analyze anomaly of the IMU. You can set and validate parameters of imu_monitor using imu_anomaly_simulator and imu_anomaly_analyzer.
imu_monitor#
Algorithms#
- Transform IMU data from sensor frame to
base_link_frame
. - Save recent
sample_buffer_size
yaw rotation speeds(angular_velocity.z
) of each IMU into buffer. - Estimate rotation speed of each IMU by calculating the average of the buffer elements.
- Find outlier candidate with the largest difference to the average among the rotation speeds.
- Calculate difference between the outlier candidate and the average of all speeds besides the outlier candidate.(=
imu_outlier_deviation
) imu_outlier_deviation
with a larger value thandeviation_threshold
is regarded as anomaly.
Parameters#
Edit config/imu_anomaly_detector.param.launch
to set the following parameters.
Name | Type | Description |
---|---|---|
deviation_threshold |
float | deviation_threshold in Algorithms |
sample_buffer_size |
int | sample_buffer_size in Algorithms |
imu_count |
int | The number of input IMUs |
base_link_frame |
string | base_link_frame in Algorithms |
Input topics#
Name | Type | Description |
---|---|---|
~/input/imu0 , ~/input/imu1 , ... |
sensor_msgs::Imu | Input IMUs. Use imu_count parameter to set the number of IMUs |
Output topics#
Name | Type | Description |
---|---|---|
/diagnostics |
diagnostic_msgs::DiagnosticArray | Diagnostics topic |
Diagnostics topic#
[summary]
level | message |
---|---|
OK | OK |
WARN | Warning |
[values]
key | value |
---|---|
anomalous_imu_id | 0 ~ (imu_count - 1) |
imu_outlier_deviation | imu_outlier_deviation in Algorithms |
imu_anomaly_simulator#
The imu_anomaly_simulator
node provides a functionality to simulate anomalous IMU messages from normal IMU messages.
Input topics#
Name | Type | Description |
---|---|---|
~/input/imu |
sensor_msgs::Imu | Input normal IMU messages which are converted into anomalous messages. |
Output topics#
Name | Type | Description |
---|---|---|
~/output/imu |
sensor_msgs::Imu | Output IMU. |
~/output/is_anomaly |
std_msgs::Bool | Indicates that the simulator is publishing anomalous IMU messages. |
Control of simulator#
imu_anomaly_simulator
is controlled by the controller
node. imu_anomaly_simulator
repeatedly takes the following steps by controller
:
1. Output normal data for a random duration.
2. Output anomalous data according to first element of error_patterns
defined in config file.
3. In the next step, next element of error_patterns
is used instead of first element.
You can change behaviour of controller
by editing configuration file. Example configuration file is in imu_anomaly_simulator/config/
.
Configurable variables are the following:
- normal_phase_duration_min
: Minimum duration in seconds of step1
- normal_phase_duration_max
: Maximum duration in seconds of step1
- error_patterns
: Array of error patterns. Each element in the array should has the following hashes.
- duration
: Duration to keep outputting
- bias
, coeff
, noise_coeff
: Parameters of anomalous data generation which are composed of x, y, z.
imu_anomaly_analyzer#
The imu_anomaly_analyzer
node provides topics which are useful to analyze imu_monitor
.
Input topics#
Name | Type | Description |
---|---|---|
/diagnostics |
diagnostic_msgs::DiagnosticArray | Diagnostics topic |
Output topics#
Name | Type | Description |
---|---|---|
~/output/is_anomaly_detected |
std_msgs::Bool | Indicates that IMU Monitor detects anomaly |
~/output/imu_outlier_deviation |
std_msgs::Float32 | imu_outlier_deviation in Algorithms |
~/output/max_imu_outlier_deviation |
std_msgs::Float32 | Max value of imu_outlier_deviation |
How to Use#
Setup config file and launch file#
- Set
imu_count
inimu_anomaly_detector.param.yaml
to the number of IMUs in your system. - Create launch file by modifying
imu_monitor.launch.xml
, which is for a system with three IMUs(one IMU and two redundant IMUs).
Integrate to your system#
Launch imu_monitor
nodes and state of IMUs will be published to /diagnostics
topic. If you have three or more IMUs in your system, you can continue to run your system even when one of IMUs is anomalous by avoiding using a IMU with anomalous_imu_id
. Although you cannot distinguish which IMU is anomalous if you have only two IMUs in your system, you can use information that any of IMUs is anomalous for a fail-safe.
Tune Parameters#
The deviation_threshold
in imu_anomaly_detector.param.yaml
should always be set to a value larger than imu_outlier_deviation
when IMUs are in normal states. The default parameter is set to almost valid value. If anomaly is detected unintendedly, change the threshold according to the max value of imu_outlier_deviation
with imu_anomaly_analyzer.
# While running your ROS nodes
ros2 launch imu_anomaly_analyzer imu_anomaly_analyzer.launch.xml
# [imu_anomaly_analyzer-1] Max imu_outlier_deviation: 0.001347
deviation_threshold
more than 0.001347, double value of imu_outlier_deviation
would be a safe value(e.g. 0.002694)
If you want to check anomaly is properly detected in a anomalous condition, you can create anomalous IMU messages with imu_anomaly_simulator. You can check whether anomalies are detected properly by comparing output/is_anomaly_detected
topic from analyzer and output/is_anomaly
topic from simulator. Plot tools such as PlotJuggler would be useful for comparison.
# While running your ROS nodes
ros2 launch imu_anomaly_simulator imu_anomaly_simulator.launch.xml
# In another terminal
ros2 launch imu_anomaly_analyzer imu_anomaly_analyzer.launch.xml
# In another terminal
ros2 bag record /imu_anomaly_simulator/is_anomaly /imu_anomaly_analyzer/is_anomaly_detected
# Open recorded rosbag with PlotJuggler and compare `is_anomaly_detected`(detection result) and `is_anomaly`(ground truth).