This example demonstrates how to configure the attitude filter to stream filter data on a MicroStrain 7-series AR device with the MIP SDK using the C API.
The example showcases the basic setup and operation of a 7-series AR device, including:
- Device initialization and communication
- Filter message format configuration
- Gyro bias capture
- Filter initialization
- Real-time data streaming and display
The example uses the following default settings, which should be adjusted based on application requirements:
| Setting | Value | Description |
|---|---|---|
PORT_NAME |
"COM1" (Windows)"/dev/ttyACM0" (Unix) |
Serial port for device communication |
BAUDRATE |
115200 |
Communication baud rate |
SAMPLE_RATE_HZ |
1 |
Data output rate in Hz |
RUN_TIME_SECONDS |
30 |
Example runtime duration |
- Connect your 7-series AR device to the specified serial port
- Update the configuration options based on your application needs
- Compile and run the example
- Follow the gyro bias capture prompt (keep the device stationary)
- The program will:
- Initialize the device
- Configure data streaming
- Wait for the filter to reach vertical gyro mode
- Stream data for the specified runtime
- Display filter state transitions
- Display real-time filter data
- Clean up and exit
The project can be configured on its own using the supplied CMakeLists.txt.
The file is configured to work directly in the MIP SDK project or as a standalone project.
If building outside the MIP SDK project, all that's needed is to define MIP_SDK_ROOT_DIR.
When building within the MIP SDK project, make sure to enable the examples using the MICROSTRAIN_BUILD_EXAMPLES
CMake option.
mkdir build
cd build
cmake .. -DMIP_SDK_ROOT_DIR:PATH=<path_to_mip_sdk>If the project cannot be configured using CMake, then the following project configurations are required:
Link against these libraries:
mip- Core MIP SDK librarymicrostrain- Core MicroStrain SDK librarymicrostrain_serial- MicroStrain serial communication library
Make sure to include those library paths as additional link directories if needed
Add these include directories:
[path_to_mip_sdk_include]/c[path_to_project_root]
path_to_mip_sdk_include can be installed paths or source paths:
- Unix -
/usr/include/microstrain - Windows -
C:/Program Files/MIP_SDK/include/microstrain - Source:
[mip_sdk_project_root]/src
Add these compiler definitions:
MICROSTRAIN_LOGGING_MAX_LEVEL=MICROSTRAIN_LOGGING_LEVEL_INFO_Sets the logging level to info which is the minimum required for this example
initialize_device()- Establishes communication, validates device connection, and loads defaultscapture_gyro_bias()- Captures and applies gyroscope bias compensationinitialize_filter()- Initializes the attitude filter
configure_filter_message_format()- Configures filter/attitude data output including:- GPS timestamp
- Filter status
- Euler angles (roll, pitch, yaw)
display_filter_state()- Displays navigation filter operating mode changes
- Uses the
mip_interfacestruct for device communication - Serial connection handled by
serial_port
This example demonstrates traditional C programming patterns:
- Manual Parsing: Direct parsing of incoming MIP packets using the MIP parser
- Callback Functions: Function pointer-based callbacks for data processing
- Explicit Memory Management: Manual buffer and resource management
- Type Safety: Uses C structs and enums for data type safety
- Error Codes: Command results handled through return codes and error checking
This example showcases:
- MIP Interface: Core C interface for device communication (
mip_interface) - Serial Port Management: Low-level serial port operations
- Parser Integration: Direct use of the MIP packet parser
- Memory Safety: Careful buffer management and bound checking
- Portability: Cross-platform compatibility (Windows/Unix)
The example implements custom communication handlers:
- Send Function:
mip_interface_user_send_to_device()handles outgoing data - Receive Function:
mip_interface_user_recv_from_device()manages incoming data - Timeout Handling: Configurable timeouts for reliable communication
The example streams the following filter data:
- Units: seconds
- Description: Time of Week - GPS time reference
- Format: Floating-point timestamp value
- Units: radians
- Description: Orientation expressed as Euler angles
- Format: [Roll, Pitch, Yaw] angle vector
The example displays filter data in the following format:
TOW = 123456.789 Euler Angles = [ 0.012345, -0.067890, 1.234567]
The example monitors and displays filter state transitions:
- Startup - Filter startup
- Initialization - Filter initialization
- Vertical Gyro - Basic attitude estimation
- AHRS - Full attitude and heading reference
- Full Navigation - Complete navigation solution with position/velocity
The example includes comprehensive error handling with:
- Command result checking using
mip_cmd_result - Connection failure detection and recovery
- Graceful termination functions for different error types
- Detailed error messages with context
This example demonstrates:
- Standard C11 programming practices
- Minimal external dependencies
- Direct hardware interface programming
- Efficient memory usage patterns
- Cross-platform serial communication
- MicroStrain 7-series AR device (3DM-CV7-AR or 3DM-GV7-AR)
- Serial connection (USB or RS-232)
- MIP SDK library with C support
- C11 or later compiler
- C++ version:
7_series_ar_example.cpp - Other examples in the
examples/directory - MIP SDK documentation