<commit_before>/** 
 * \page The MAV'RIC license
 *
 * The MAV'RIC Framework
 *
 * Copyright © 2011-2014
 *
 * Laboratory of Intelligent Systems, EPFL
 */
 
 
/**
 * \file pid_control.c
 *
 * PID controller
 */


#include "time_keeper.h"

#include "pid_control.h"
#include "maths.h"

PID_Controller_t pid_control_passthroughController() 
{
	PID_Controller_t out;
	out.p_gain=1.0f;
	out.last_update=time_keeper_get_time_ticks();	
	out.clip_min= -10000.0f;
	out.clip_max= 10000.0f;
	out.output=0.0f;
	out.soft_zone_width=0.0f;
	pid_control_init_differenciator(&(out.differentiator), 0.0f, 0.0f, 0.0f);
	pid_control_init_integrator(&(out.integrator), 0.0f, 0.0f, 0.0f);
	return out;
}

float pid_control_integrate(Integrator_t *integrator, float input, float dt)
{
	integrator->accumulator=maths_clip(integrator->accumulator + dt* integrator->pregain * input, integrator->maths_clip);
	return integrator->postgain* integrator->accumulator;
}

void pid_control_init_integrator(Integrator_t *integrator, float pregain, float postgain, float clip_val) 
{
	integrator->pregain=pregain;
	integrator->postgain=postgain;
	integrator->maths_clip=clip_val;
	integrator->accumulator=0.0f;
}

void pid_control_reset_integrator(Integrator_t *integrator)
{
	integrator->accumulator=0.0f;
}

void pid_control_init_differenciator(Differentiator_t *diff, float gain, float LPF, float clip_val) 
{
	diff->gain=gain;<commit_msg>Fix warning in pid_control.c<commit_after>/** 
 * \page The MAV'RIC license
 *
 * The MAV'RIC Framework
 *
 * Copyright © 2011-2014
 *
 * Laboratory of Intelligent Systems, EPFL
 */
 
 
/**
 * \file pid_control.c
 *
 * PID controller
 */


#include "time_keeper.h"

#include "pid_control.h"
#include "maths.h"

PID_Controller_t pid_control_passthroughController() 
{
	PID_Controller_t out;
	uint32_t t= time_keeper_get_time_ticks();

	out.dt = 0.0f;
	out.last_update = t;
	
	out.p_gain = 1.0f;	
	out.clip_min = -10000.0f;
	out.clip_max = 10000.0f;
	out.error = 0.0f;
	out.output = 0.0f;
	out.soft_zone_width = 0.0f;
	out.integrator.leakiness = 0.0f;
	out.differentiator.previous = 0.0f;
	
	pid_control_init_differenciator(&(out.differentiator), 0.0f, 0.0f, 0.0f);
	pid_control_init_integrator(&(out.integrator), 0.0f, 0.0f, 0.0f);
	
	return out;
}

float pid_control_integrate(Integrator_t *integrator, float input, float dt)
{
	integrator->accumulator=maths_clip(integrator->accumulator + dt* integrator->pregain * input, integrator->maths_clip);
	return integrator->postgain* integrator->accumulator;
}

void pid_control_init_integrator(Integrator_t *integrator, float pregain, float postgain, float clip_val) 
{
	integrator->pregain=pregain;
	integrator->postgain=postgain;
	integrator->maths_clip=clip_val;
	integrator->accumulator=0.0f;
}

void pid_control_reset_integrator(Integrator_t *integrator)
{
	integrator->accumulator=0.0f;
}

void pid_control_init_differenciator(Differentiator_t *diff, float gain, float LPF, float clip_val) 
{
	diff->gain=gain;
{'fraction_non_alphanumeric': 0.12567385444743936, 'fraction_numerical': 0.03167115902964959, 'mean_word_length': 5.426406926406926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '2994972', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1162, 'n_words': 197}