<commit_before>#include "state.h"
#include "sensors/itg3200.h"
#include "core/systick.h"

#define STATE_DOF_CNT 6

static float rotation_b_to_i[3][3]; // Body to inertial rotation matrix

void state_add(state_t *s1, state_t *s2, state_t *sum) {
	float *s1_arr = (float*)s1;
	float *s2_arr = (float*)s2;
	float *sum_arr = (float*)sum;

	int i;
	for(i = 0;i < STATE_DOF_CNT;++i) sum_arr[i] = s1_arr[i] + s2_arr[i];
}

void state_scale(state_t *s1, float val, state_t *dest) {
	float *s1_arr = (float*)s1;
	float *dest_arr = (float*)dest;

	int i;
	for(i = 0;i < STATE_DOF_CNT;++i) dest_arr[i] = s1_arr[i] * val;
}

static uint32_t last_gyro_update_ticks;

void state_update_from_gyro(void) {
	GyroData gd;
	uint32_t tick_diff = systickGetTicks() - last_gyro_update_ticks;
	float dt = tick_diff / 1000;
	if(itg3200GetData(&gd)) {
		rotation_matrix_velocity_update(rotation_b_to_i, gd.X, gd.Y, gd.Z, dt);
	}
}
<commit_msg>Update gyro state update dt on state_gyro_update()<commit_after>#include "state.h"
#include "rotation.h"
#include "sensors/itg3200.h"
#include "core/systick.h"

#define STATE_DOF_CNT 6

static float rotation_b_to_i[3][3]; // Body to inertial rotation matrix

void state_add(state_t *s1, state_t *s2, state_t *sum) {
	float *s1_arr = (float*)s1;
	float *s2_arr = (float*)s2;
	float *sum_arr = (float*)sum;

	int i;
	for(i = 0;i < STATE_DOF_CNT;++i) sum_arr[i] = s1_arr[i] + s2_arr[i];
}

void state_scale(state_t *s1, float val, state_t *dest) {
	float *s1_arr = (float*)s1;
	float *dest_arr = (float*)dest;

	int i;
	for(i = 0;i < STATE_DOF_CNT;++i) dest_arr[i] = s1_arr[i] * val;
}

static uint32_t last_gyro_update_ticks;

void state_update_from_gyro(void) {
	GyroData gd;
	if(itg3200GetData(&gd)) {
		uint32_t tick_diff = systickGetTicks() - last_gyro_update_ticks;
		float dt = tick_diff / 1000;
		rotation_matrix_velocity_update(rotation_b_to_i, gd.X, gd.Y, gd.Z, dt);
		last_gyro_update_ticks = systickGetTicks();
	}
}

{'fraction_non_alphanumeric': 0.14616572310859496, 'fraction_numerical': 0.033968090581574885, 'mean_word_length': 5.3322475570032575, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4676997', 'n_tokens_mistral': 941, 'n_tokens_neox': 883, 'n_words': 176}