#include <stdio.h>
#include <signal.h>
#define Nx 2
#define Ny 1
#define Nu 1
#define DT 0.05
#define REVERSE_TIME 2.0
static int running = 1;
static void __signal_handler(__attribute__ ((unused)) int dummy)
{
running=0;
return;
}
int main()
{
int counter;
signal(SIGINT, __signal_handler);
running = 1;
counter = REVERSE_TIME/(DT*2.0);
while(running){
if(counter > REVERSE_TIME/DT){
counter = 0;
if(u.
d[0]<1.0) u.
d[0]=1.0;
}
printf(
"\rpos: %5.2f vel: %5.2f u: %5.2f y: %5.2f ", kf.
x_est.
d[0], kf.
x_est.
d[1], u.
d[0], y.
d[0]);
fflush(stdout);
counter++;
}
printf("\n");
return 0;
}
#define RC_KALMAN_INITIALIZER
Definition: kalman.h:111
int rc_kalman_free(rc_kalman_t *kf)
Frees the memory allocated by a kalman filter's matrices and vectors. Also resets all values to 0 lik...
int rc_kalman_alloc_lin(rc_kalman_t *kf, rc_matrix_t F, rc_matrix_t G, rc_matrix_t H, rc_matrix_t Q, rc_matrix_t R, rc_matrix_t Pi)
Allocates memory for a Kalman filter of given dimensions.
int rc_kalman_update_lin(rc_kalman_t *kf, rc_vector_t u, rc_vector_t y)
Kalman Filter state prediction step based on physical model.
int rc_matrix_zeros(rc_matrix_t *A, int rows, int cols)
Resizes matrix A and allocates memory for a matrix with specified rows & columns. The new memory is p...
int rc_matrix_free(rc_matrix_t *A)
Frees the memory allocated for a matrix A.
#define RC_MATRIX_INITIALIZER
Definition: matrix.h:39
int rc_vector_free(rc_vector_t *v)
Frees the memory allocated for vector v.
int rc_vector_zeros(rc_vector_t *v, int length)
Resizes vector v and fills with zeros.
#define RC_VECTOR_INITIALIZER
Definition: vector.h:48
void rc_usleep(unsigned int us)
Sleep in microseconds.
rc_vector_t x_est
Estimated state x[k|k] = x[k|k-1],y[k])
Definition: kalman.h:100
Struct containing the state of a matrix and a pointer to dynamically allocated memory to hold its con...
Definition: matrix.h:32
double ** d
pointer to allocated 2d array
Definition: matrix.h:35
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
Definition: vector.h:41
double * d
pointer to dynamically allocated data
Definition: vector.h:43