Logging ROS2 Messages
Assuming you have the following file structure for your app, you first need to adjust your app's auterion-app.yml file before building the app by adding a logging: key.
├── auterion-app.yml
├── Dockerfile
├── msgs_ws/
│ └── src/
│ ├── custom_msgs/
│ │ └── msg/
│ └── CustomTopic.msg
│ ├── px4_msgs/
│ │ └── msg/
│ └── VehicleOdometry.msg
│ └── std_msgs/
│ └── msg/
│ └── ColorRGBA.msg
├── README.md
├── ros_ws/
│ └── src/
│ └── fake_visual_odometry/
│ └── src/
│ └── fake_visual_odometry_node.cpp
└── settings.default.envAuterion-app.yml Logging Key
The logging key is placed after services in your auterion-app.yml file.
auterion-api-version: 2
services:
test-app:
...
logging:
msg-paths:
subscriptions: # uses the default profile
topic:
# Or (advanced usage)
profiles:
default: # profile name - can use 'verbose' profile instead
when:
- condition:
subscriptions:
topic:
verbose:
- condition:
subscriptions:
topic:
msg-paths: Defines where log messages are stored. It can be a single string or a list of strings indicating file paths.
subscriptions: Specifies which messages or topics should be logged. You can list them as simple strings or detailed objects with additional properties like logging rates.
profiles: allows control of the logging behaviour under different conditions, and if the run conditions are met, each profile can generate its own
ulogwith its own logging rate and set of logged messages into a defined directory. The run conditionsalways,never,while-armedandwhile-disarmedcan be used for a profile. AOS has two profiles that are already setup,defaultandverbose.Thedefaultprofile starts logging when the system is armed. The profiles can be extended in the app configuration to include additional topic subscriptions that the logger will log. This flexibility lets you specify which messages are logged and under what conditions.
The default profile is streamed to the suite. Therefore, keep the log data rate low (in the order of a few KB/s at the top).
ROS2 Logging Setup Example
The app needs to publish messages over DDS or ROS2 to log custom app data. In the auterion-app.yml for your app, you can specify the message paths and set them as subscriptions: for the AOS logger.
logging:
# Paths to app message definitions that you want to log
msg-paths: [msgs_ws/src/px4_msgs, msgs_ws/src/std_msgs, msgs_ws/src/custom_msgs] You should then be able to find the messages defined within your app auterion-app.yml file under the /data/app-config/logging/msgs after you install your app on AOS.
To log messages to the file, you just need to add ROS2 topics and ROS2 message types under subscriptions.
logging:
subscriptions: # Default logging profile; does not log when disarmed.
/custom_topic: custom_msgs/CustomTopic # Subscribes to a custom topic in msgs_ws/src/custom_msgs
/test_color: std_msgs/ColorRGBA # Subscribes to a standard color message that could be publishing on the ROS 2 network.
/fmu/in/vehicle_visual_odometry: px4_msgs/VehicleOdometryTo extend the verbose profile such that you are also logging the messages while disarmed, you would do something like this:
logging:
# Define different logging profiles.
profiles:
# Extend the Default profile to add additional subscriptions and conditions.
# Profile is defined in the logger.yml file, which is used by the data-logger.
verbose:
when:
- condition: 'always'
subscriptions:
# Subscriptions specific to the 'always' condition.
/custom_topic: custom_msgs/CustomTopic
/test_color: std_msgs/ColorRGBA
/fmu/in/vehicle_visual_odometry: px4_msgs/VehicleOdometry You could also set the logging rate for each topic by setting max_rate_hz. This is an example to log at low rate while disarmed, and full rate while armed:
default:
when:
# Define behavior when the system is disarmed.
- condition: 'while-disarmed' # Low-rate logging when disarmed.
subscriptions:
# Subscriptions specific to the 'while-disarmed' condition.
/custom_topic:
type: custom_msgs/CustomTopic # Message type for custom topic.
max_rate_hz: 5 # Maximum logging rate in Hz.
/test_color:
type: std_msgs/ColorRGBA # Message type for color data.
max_rate_hz: 5
/fmu/in/vehicle_visual_odometry:
type: px4_msgs/VehicleOdometry # Message type for odometry data.
max_rate_hz: 5
- condition: 'while-armed'
subscriptions:
/custom_topic: custom_msgs/CustomTopic
/test_color: std_msgs/ColorRGBA
/fmu/in/vehicle_visual_odometry: px4_msgs/VehicleOdometryMonitoring and Troubleshooting
To monitor the logging activity and troubleshoot potential issues, use:
journalctl -u data-logger -b -fIf the message is logged successfully, running journalctl -u data-logger -b -f should contain: [dds_source.cpp:111] [dds] Subscriber matched update.
Key Limitations
Maximum Topic Size: 65536 bytes. Ensure that messages do not exceed this size to prevent logging failures.
No Support for Dynamically-Sized Messages: Static message definitions are required due to current logging limitations.
Last updated