MIP_SDK  v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
Functions | Variables
7-Series INS Example [C]

Example setup program for the 3DM-CV7-INS, and 3DM-GV7-INS using C. More...

Functions

static void log_callback (void *_user, const microstrain_log_level _level, const char *_format, va_list _args)
 Custom logging callback for MIP SDK message formatting and output. More...
 
static void capture_gyro_bias (mip_interface *_device)
 Captures and configures device gyro bias. More...
 
static void configure_filter_message_format (mip_interface *_device)
 Configures message format for filter data streaming. More...
 
static void configure_external_aiding_heading (mip_interface *_device)
 Configures a heading reference frame for external aiding measurements. More...
 
static void configure_external_aiding_gnss_antenna (mip_interface *_device)
 Configures a GNSS antenna reference frame for external aiding measurements. More...
 
static void configure_external_aiding_ned_velocity (mip_interface *_device)
 Configures a body frame velocity reference frame for external aiding measurements. More...
 
static void initialize_filter (mip_interface *_device)
 Initializes and resets the navigation filter. More...
 
static void display_filter_state (const mip_filter_mode _filter_state)
 Displays the current filter state when changes occur. More...
 
static mip_timestamp get_current_timestamp ()
 Gets the current system timestamp in milliseconds. More...
 
static bool mip_interface_user_send_to_device (mip_interface *_device, const uint8_t *_data, size_t _length)
 Handles sending packets to the device. More...
 
static bool mip_interface_user_recv_from_device (mip_interface *_device, uint8_t *_buffer, size_t _max_length, mip_timeout _wait_time, bool _from_cmd, size_t *_length_out, mip_timestamp *_timestamp_out)
 Handles receiving packets from the device. More...
 
static void initialize_device (mip_interface *_device, serial_port *_device_port, const uint32_t _baudrate)
 Initializes and configures a MIP device interface. More...
 
static void send_simulated_heading_data (mip_interface *_device, const mip_time *_aiding_time)
 Sends simulated external heading measurements to the device. More...
 
static void send_simulated_position_data (mip_interface *_device, const mip_time *_aiding_time)
 Sends simulated external position measurements to the device. More...
 
static void send_simulated_ned_velocity_data (mip_interface *_device, const mip_time *_aiding_time)
 Sends simulated external NED velocity measurements to the device. More...
 
static void send_simulated_vehicle_frame_velocity_data (mip_interface *_device, const mip_time *_aiding_time)
 Sends simulated external vehicle frame velocity measurements to the device. More...
 
static void terminate (serial_port *_device_port, const char *_message, const bool _successful)
 Handles graceful program termination and cleanup. More...
 
static void exit_from_command (const mip_interface *_device, const mip_cmd_result _cmd_result, const char *_format,...)
 Handles graceful program termination and command failure cleanup. More...
 

Variables

static const char * PORT_NAME = "/dev/ttyACM0"
 Set the port name for the connection (Serial/USB) More...
 
static const uint32_t BAUDRATE = 115200
 Set the baudrate for the connection (Serial/USB) More...
 
static const uint16_t SAMPLE_RATE_HZ = 1
 Streaming rate in Hz. More...
 
static const uint32_t RUN_TIME_SECONDS = 30
 Example run time. More...
 
static const uint64_t TIME_OF_ARRIVAL_LATENCY_NS = 100 * 1000000
 Time of arrival latency in nanoseconds. More...
 
static const uint8_t HEADING_FRAME_CONFIG_ID = 1
 Frame config ID for external heading. More...
 
static const uint8_t GNSS_FRAME_CONFIG_ID = 2
 Frame config ID for external GNSS antenna. More...
 
static const uint8_t BODY_VELOCITY_FRAME_CONFIG_ID = 3
 Frame config ID for body frame velocity. More...
 

Detailed Description

This example shows a basic setup to configure the navigation filter with external heading, and GNSS position and velocity as the heading sources to stream filter data using simulated external aiding measurements for the 3DM-CV7-INS, and 3DM-GV7-INS using C. This is not an exhaustive example of all settings for those devices. If this example does not meet your specific setup needs, please consult the MIP SDK API documentation for the proper commands.

License

Function Documentation

◆ log_callback()

static void log_callback ( void *  _user,
const microstrain_log_level  _level,
const char *  _format,
va_list  _args 
)
static

Processes and formats log messages from the MIP SDK based on severity level. Routes messages to appropriate output streams - errors and fatal messages go to stderr while other levels go to stdout. Each message is prefixed with its severity level name.

Parameters
_userPointer to user data (unused in this implementation)
_levelLog message severity level from microstrain_log_level enum
_formatPrintf-style format string for the message
_argsVariable argument list containing message parameters

◆ capture_gyro_bias()

static void capture_gyro_bias ( mip_interface *  _device)
static
Parameters
_devicePointer to the initialized MIP device interface

◆ configure_filter_message_format()

static void configure_filter_message_format ( mip_interface *  _device)
static

Sets up filter data output by:

  1. Querying device base rate
  2. Validating desired sample rate against base rate
  3. Calculating proper decimation
  4. Configuring message format with:
    • GPS timestamp
    • Filter status
    • LLH position
    • NED velocity
    • Euler angles
Parameters
_devicePointer to the initialized MIP device interface

◆ configure_external_aiding_heading()

static void configure_external_aiding_heading ( mip_interface *  _device)
static

Sets up a heading reference frame for external sensor data:

  • Translation: [0, 0, 0] m
  • Rotation: [0, 0, 0] deg (no rotation)

The frame is configured with tracking enabled and uses an Euler angle rotation format.

Parameters
_devicePointer to the initialized MIP device interface
Note
This function is typically called during device initialization to establish the coordinate system relationships for external measurements. Frame IDs correspond to those used in external measurement functions.

◆ configure_external_aiding_gnss_antenna()

static void configure_external_aiding_gnss_antenna ( mip_interface *  _device)
static

Sets up a GNSS antenna reference frame for external sensor data:

  • Translation: [0, 1, 0] m (1m offset in Y-axis)
  • Rotation: [0, 0, 0] deg (no rotation)

The frame is configured with tracking enabled and uses an Euler angle rotation format.

Parameters
_devicePointer to the initialized MIP device interface
Note
This function is typically called during device initialization to establish the coordinate system relationships for external measurements. Frame IDs correspond to those used in external measurement functions.

◆ configure_external_aiding_ned_velocity()

static void configure_external_aiding_ned_velocity ( mip_interface *  _device)
static

Sets up a body frame velocity reference frame for external sensor data:

  • Translation: [1, 0, 0] m (1m offset in X-axis)
  • Rotation: [0, 0, 90] deg (90 deg yaw rotation)

The frame is configured with tracking enabled and uses an Euler angle rotation format.

Parameters
_deviceReference to the initialized MIP device interface
Note
This function is typically called during device initialization to establish the coordinate system relationships for external measurements. Frame IDs correspond to those used in external measurement functions.

◆ initialize_filter()

static void initialize_filter ( mip_interface *  _device)
static

Configures the navigation filter by:

  1. Enabling GNSS position and velocity aiding measurements
  2. Enabling external heading aiding measurements
  3. Configuring filter initialization settings:
    • Setting initial position and velocity to zero
    • Enabling automatic position/velocity/attitude determination
    • Configuring external aiding kinematic alignment
  4. Resetting the filter to apply new settings
Parameters
_devicePointer to the initialized MIP device interface

◆ display_filter_state()

static void display_filter_state ( const mip_filter_mode  _filter_state)
static

Outputs readable messages for filter state transitions:

  • Initialization mode
  • Vertical gyro mode
  • AHRS mode
  • Full navigation mode
Parameters
_filter_stateCurrent filter mode from the MIP device interface

◆ get_current_timestamp()

static mip_timestamp get_current_timestamp ( )
static

Provides basic timestamping using system time:

  • Returns milliseconds since Unix epoch
  • Uses timespec_get() with UTC time base
  • Returns 0 if time cannot be obtained
Note
Update this function to use a different time source if needed for your specific application requirements
Returns
Current system time in milliseconds since epoch

◆ mip_interface_user_send_to_device()

static bool mip_interface_user_send_to_device ( mip_interface *  _device,
const uint8_t *  _data,
size_t  _length 
)
static

Implements the MIP device interface send callback:

  • Extracts serial port from device user pointer
  • Validates connection state
  • Writes data buffer to serial port
Parameters
_deviceMIP device interface containing the connection
_dataBuffer containing packet data to send
_lengthNumber of bytes to send
Returns
True if send was successful, false otherwise

◆ mip_interface_user_recv_from_device()

static bool mip_interface_user_recv_from_device ( mip_interface *  _device,
uint8_t *  _buffer,
size_t  _max_length,
mip_timeout  _wait_time,
bool  _from_cmd,
size_t *  _length_out,
mip_timestamp *  _timestamp_out 
)
static

Implements the MIP device interface receive callback:

  • Extracts serial port from device user pointer
  • Validates connection state
  • Reads available data into provided buffer
  • Timestamps the received data
Parameters
_deviceMIP device interface containing the connection
_bufferBuffer to store received data
_max_lengthMaximum number of bytes to read
_wait_timeHow long to wait for data in milliseconds
_from_cmdWhether this read is from a command response (unused)
_length_outNumber of bytes actually read
_timestamp_outTimestamp when data was received
Returns
True if receive was successful, false otherwise

◆ initialize_device()

static void initialize_device ( mip_interface *  _device,
serial_port _device_port,
const uint32_t  _baudrate 
)
static

Performs a complete device initialization sequence:

  1. Sets up a MIP device interface with specified timeouts and callbacks
  2. Verifies device communication with a ping command
  3. Sets the device to idle mode to ensure reliable configuration
  4. Queries and displays detailed device information
  5. Loads default device settings for a known state
Parameters
_devicePointer to a MIP device interface to initialize
_device_portPointer to an initialized serial port for device communication
_baudrateSerial communication baudrate for the device

◆ send_simulated_heading_data()

static void send_simulated_heading_data ( mip_interface *  _device,
const mip_time *  _aiding_time 
)
static

Provides simulated true heading data to the device for filter aiding. Uses fixed values:

  • Heading: 0.0 deg (North)
  • Uncertainty: 0.001 radians
Parameters
_devicePointer to the initialized MIP device interface
_aiding_timePointer to the timestamp for the external measurement
Note
Issues warning if the command fails but does not terminate execution. Used for testing external aiding functionality with known data.

◆ send_simulated_position_data()

static void send_simulated_position_data ( mip_interface *  _device,
const mip_time *  _aiding_time 
)
static

Provides simulated LLH position data to the device for filter aiding. Uses fixed coordinates for MicroStrain headquarters:

  • Latitude: 44.437 deg N
  • Longitude: 73.106 deg W
  • Height: 122.0 m
  • Uncertainty: 1.0 m in all axes
Parameters
_devicePointer to the initialized MIP device interface
_aiding_timePointer to the timestamp for the external measurement
Note
Issues warning if the command fails but does not terminate execution. Used for testing external aiding functionality with a known location.

◆ send_simulated_ned_velocity_data()

static void send_simulated_ned_velocity_data ( mip_interface *  _device,
const mip_time *  _aiding_time 
)
static

Provides simulated North-East-Down velocity data to the device for filter aiding. Uses stationary target values:

  • Velocity: [0, 0, 0] m/s (stationary)
  • Uncertainty: 0.1 m/s in all axes
Parameters
_devicePointer to the initialized MIP device interface
_aiding_timePointer to the timestamp for the external measurement
Note
Issues warning if the command fails but does not terminate execution. Used for testing external aiding functionality with stationary data.

◆ send_simulated_vehicle_frame_velocity_data()

static void send_simulated_vehicle_frame_velocity_data ( mip_interface *  _device,
const mip_time *  _aiding_time 
)
static

Provides simulated body-frame velocity data to the device for filter aiding. Uses stationary target values:

  • Velocity: [0, 0, 0] m/s (stationary in body frame)
  • Uncertainty: 0.1 m/s in all axes
Parameters
_devicePointer to the initialized MIP device interface
_aiding_timePointer to the timestamp for the external measurement
Note
Issues warning if the command fails but does not terminate execution. Used for testing external aiding functionality with vehicle-relative data.

◆ terminate()

static void terminate ( serial_port _device_port,
const char *  _message,
const bool  _successful 
)
static

Handles graceful shutdown when errors occur:

  • Outputs provided error message
  • Closes device connection if open
  • Exits with appropriate status code
Parameters
_device_portSerial port connection to close
_messageError message to display
_successfulWhether termination is due to success or failure

◆ exit_from_command()

static void exit_from_command ( const mip_interface *  _device,
const mip_cmd_result  _cmd_result,
const char *  _format,
  ... 
)
static

Handles command failure scenarios:

  • Formats and displays an error message with command result
  • Closes device connection
  • Exits with failure status
Parameters
_deviceMIP device interface for the command that failed
_cmd_resultResult code from a failed command
_formatPrintf-style format string for error message
...Variable arguments for format string

Variable Documentation

◆ PORT_NAME

const char* PORT_NAME = "/dev/ttyACM0"
static

◆ BAUDRATE

const uint32_t BAUDRATE = 115200
static
Note
For native serial connections this needs to be 115200 due to the device default settings command Use mip_base_*_comm_speed() to write and save the baudrate on the device

◆ SAMPLE_RATE_HZ

const uint16_t SAMPLE_RATE_HZ = 1
static

◆ RUN_TIME_SECONDS

const uint32_t RUN_TIME_SECONDS = 30
static

◆ TIME_OF_ARRIVAL_LATENCY_NS

const uint64_t TIME_OF_ARRIVAL_LATENCY_NS = 100 * 1000000
static
Note
This is the time it takes to package the command before it arrives and is typically around 100 ms

◆ HEADING_FRAME_CONFIG_ID

const uint8_t HEADING_FRAME_CONFIG_ID = 1
static

◆ GNSS_FRAME_CONFIG_ID

const uint8_t GNSS_FRAME_CONFIG_ID = 2
static

◆ BODY_VELOCITY_FRAME_CONFIG_ID

const uint8_t BODY_VELOCITY_FRAME_CONFIG_ID = 3
static