Go to the documentation of this file.
79 int usage(
const char* argv0);
92 int main(
int argc,
const char* argv[])
100 return usage(argv[0]);
102 const char* port_name = argv[1];
103 uint32_t baudrate = atoi(argv[2]);
106 return usage(argv[0]);
114 printf(
"Connecting to and configuring sensor.\n");
162 uint16_t sensor_base_rate;
170 const uint16_t sensor_sample_rate = 100;
171 const uint16_t sensor_decimation = sensor_base_rate / sensor_sample_rate;
188 uint16_t filter_base_rate;
193 const uint16_t filter_sample_rate = 100;
194 const uint16_t filter_decimation = filter_base_rate / filter_sample_rate;
264 exit_gracefully(
"ERROR: Could not set sensor-to-vehicle transformation!");
272 exit_gracefully(
"ERROR: Could not set filter aiding measurement enable!");
319 printf(
"Sensor is configured... waiting for filter to enter AHRS mode.\n");
328 printf(
"NOTE: Filter has entered AHRS mode.\n");
337 if(curr_time - prev_print_timestamp >= 100)
339 printf(
"TOW = %f: ATT_EULER = [%f %f %f]\n",
342 prev_print_timestamp = curr_time;
365 printf(
"WARNING: Roll event triggered!\n");
367 printf(
"WARNING: Pitch event triggered!\n");
402 size_t bytes_written;
414 printf(
"Usage: %s <port> <baudrate>\n", argv0);
433 int dummy = getchar();
mip_shared_gps_timestamp_data filter_gps_time
uint8_t descriptors[20]
List of field descriptors.
mip_filter_mode filter_state
Device-specific filter state. Please consult the user manual for definition.
void mip_interface_register_extractor(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor extractor, void *field_ptr)
Registers a callback for packets of the specified descriptor set.
bool extract_mip_shared_event_source_data_from_field(const mip_field *field, void *ptr)
mip_cmd_result mip_base_set_idle(struct mip_interface *device)
static const mip_filter_aiding_measurement_enable_command_aiding_source MIP_FILTER_AIDING_MEASUREMENT_ENABLE_COMMAND_AIDING_SOURCE_MAGNETOMETER
Magnetometer (built-in sensor)
const uint8_t FILTER_PITCH_EVENT_ACTION_ID
static const mip_3dm_event_trigger_command_threshold_params_type MIP_3DM_EVENT_TRIGGER_COMMAND_THRESHOLD_PARAMS_TYPE_WINDOW
Window comparison. Trigger is active if low_thres <= value <= high_thres. If the thresholds are rever...
mip_cmd_result mip_3dm_default_device_settings(struct mip_interface *device)
mip_3dm_event_trigger_command_threshold_params threshold
bool extract_mip_shared_gps_timestamp_data_from_field(const mip_field *field, void *ptr)
bool serial_port_open(serial_port *port, const char *port_str, int baudrate)
bool extract_mip_sensor_scaled_mag_data_from_field(const mip_field *field, void *ptr)
mip_cmd_result mip_3dm_write_event_action(struct mip_interface *device, uint8_t instance, uint8_t trigger, mip_3dm_event_action_command_type type, const mip_3dm_event_action_command_parameters *parameters)
void mip_interface_register_field_callback(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void *user_data)
Registers a callback for packets of the specified descriptor set.
int main(int argc, const char *argv[])
@ MIP_DATA_DESC_SHARED_EVENT_SOURCE
bool serial_port_close(serial_port *port)
double tow
GPS Time of Week [seconds].
uint8_t num_fields
Number of mip fields in the packet. Limited to 12.
void exit_gracefully(const char *message)
@ MIP_DATA_DESC_SENSOR_MAG_SCALED
mip_timestamp get_current_timestamp()
@ MIP_DATA_DESC_SHARED_GPS_TIME
int usage(const char *argv0)
uint8_t parse_buffer[1024]
mip_cmd_result mip_3dm_write_event_trigger(struct mip_interface *device, uint8_t instance, mip_3dm_event_trigger_command_type type, const mip_3dm_event_trigger_command_parameters *parameters)
mip_cmd_result mip_base_resume(struct mip_interface *device)
A structure representing a MIP field.
mip_3dm_event_action_command_message_params message
uint64_t mip_timestamp
Type used for packet timestamps and timeouts.
static const mip_3dm_event_action_command_type MIP_3DM_EVENT_ACTION_COMMAND_TYPE_MESSAGE
Output a data packet. See MessageParameters.
mip_sensor_scaled_mag_data sensor_mag
@ MIP_ACK_OK
Command completed successfully.
bool serial_port_read(serial_port *port, void *buffer, size_t num_bytes, int wait_time, size_t *bytes_read)
bool mip_interface_default_update(struct mip_interface *device, mip_timeout wait_time)
Polls the port for new data or command replies.
mip_filter_euler_angles_data filter_euler_angles
static const mip_3dm_event_trigger_command_type MIP_3DM_EVENT_TRIGGER_COMMAND_TYPE_THRESHOLD
Compare a data quantity against a high and low threshold. See ThresholdParams.
float sensor_to_vehicle_transformation_euler[3]
mip_cmd_result mip_3dm_write_event_control(struct mip_interface *device, uint8_t instance, mip_3dm_event_control_command_mode mode)
@ MIP_DATA_DESC_FILTER_FILTER_STATUS
@ MIP_SENSOR_DATA_DESC_SET
bool mip_interface_update(struct mip_interface *device, mip_timeout wait_time)
Call to process data from the device.
const uint8_t FILTER_ROLL_EVENT_ACTION_ID
mip_cmd_result mip_filter_reset(struct mip_interface *device)
mip_sensor_scaled_gyro_data sensor_gyro
uint8_t field_desc
Field descriptor of target data quantity.
mip_3dm_event_trigger_command_threshold_params_type type
Determines the type of comparison.
mip_cmd_result mip_3dm_get_base_rate(struct mip_interface *device, uint8_t desc_set, uint16_t *rate_out)
@ MIP_DATA_DESC_FILTER_ATT_EULER_ANGLES
@ MIP_FILTER_DATA_DESC_SET
@ MIP_DATA_DESC_SENSOR_ACCEL_SCALED
bool mip_interface_user_send_to_device(mip_interface *device, const uint8_t *data, size_t length)
Handler information for MIP Packet or Field callbacks.
mip_shared_gps_timestamp_data sensor_gps_time
@ MIP_DATA_DESC_SENSOR_GYRO_SCALED
bool serial_port_write(serial_port *port, const void *buffer, size_t num_bytes, size_t *bytes_written)
bool extract_mip_filter_euler_angles_data_from_field(const mip_field *field, void *ptr)
uint8_t desc_set
Descriptor set of target data quantity.
uint8_t param_id
1-based index of the target parameter within the MIP field. E.g. for Scaled Accel (0x80,...
mip_timestamp mip_timeout
static const mip_filter_mode MIP_FILTER_MODE_AHRS
bool serial_port_is_open(const serial_port *port)
State of the interface for communicating with a MIP device.
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
uint8_t desc_set
MIP data descriptor set.
void mip_interface_init(mip_interface *device, uint8_t *parse_buffer, size_t parse_buffer_size, mip_timeout parse_timeout, mip_timeout base_reply_timeout, mip_send_callback send, mip_recv_callback recv, mip_update_callback update, void *user_pointer)
Initialize the mip_interface components.
mip_cmd_result mip_base_ping(struct mip_interface *device)
uint16_t decimation
Decimation from the base rate. If 0, a packet is emitted each time the trigger activates....
bool mip_interface_user_recv_from_device(mip_interface *device, uint8_t *buffer, size_t max_length, mip_timeout wait_time, size_t *out_length, mip_timestamp *timestamp_out)
mip_timeout mip_timeout_from_baudrate(uint32_t baudrate)
Computes an appropriate packet timeout for a given serial baud rate.
mip_sensor_scaled_accel_data sensor_accel
mip_cmd_result mip_filter_write_aiding_measurement_enable(struct mip_interface *device, mip_filter_aiding_measurement_enable_command_aiding_source aiding_source, bool enable)
mip_filter_status_data filter_status
bool extract_mip_filter_status_data_from_field(const mip_field *field, void *ptr)
void handle_filter_event_source(void *user, const mip_field *field, mip_timestamp timestamp)
static const mip_3dm_event_control_command_mode MIP_3DM_EVENT_CONTROL_COMMAND_MODE_ENABLED
Trigger is enabled and will work normally.
bool extract_mip_sensor_scaled_gyro_data_from_field(const mip_field *field, void *ptr)
bool extract_mip_sensor_scaled_accel_data_from_field(const mip_field *field, void *ptr)