#include "math.h"
#include "e_acc.h"
#include "e_ad_conv.h"
#include "../../motor_led/e_epuck_ports.h"
#include "../../motor_led/advance_one_timer/e_led.h"
#include <stdlib.h>
Functions | |
| int | e_get_acc (unsigned int captor) |
| Read the last value of a given accelerator axes. | |
| int | e_get_acc_filtered (unsigned int captor, unsigned int filter_size) |
| Read the value of a channel, filtered by an averaging filter. | |
| void | calculate_acc_raw (void) |
| read the x, y, z values, apply an averaging filter and finaly subbstract the center values. | |
| void | calculate_acc_spherical (void) |
| calculate the intensity of the acceleration vector, and the Euler's angles | |
| void | e_acc_calibr (void) |
| initialize de ad converter and calculate the zero values | |
| TypeAccSpheric | e_read_acc_spheric (void) |
| calculate and return the accel. in spherical coord | |
| float | e_read_inclination (void) |
| calculate and return the inclination angle | |
| float | e_read_orientation (void) |
| calculate and return the orientation angle | |
| float | e_read_acc (void) |
| calculate and return the intensity of the acceleration | |
| TypeAccRaw | e_read_acc_xyz (void) |
| calculate and return acceleration on the x,y,z axis | |
| int | e_read_acc_x (void) |
| calculate and return acceleration on the x axis | |
| int | e_read_acc_y (void) |
| calculate and return acceleration on the y axis | |
| int | e_read_acc_z (void) |
| calculate and return acceleration on the z axis | |
| void | e_display_angle (void) |
| light the led according to the orientation angle | |
Variables | |
| int | e_acc_scan [3][ACC_SAMP_NB] |
| unsigned int | e_last_acc_scan_id |
| static int | angle_mem = 0 |
| static int | centre_x = 0 |
| static int | centre_y = 0 |
| static int | centre_z = 2000 |
| static int | acc_x |
| static int | acc_y |
| static int | acc_z |
| static float | acceleration |
| static float | orientation |
| static float | inclination |
The functions of this file are made to deal with the accelerometer data. You can know the magnitude, the orientation, the inclination, ... of the acceleration that the e-puck is enduring.
Two structures are used:
A little exemple to read the accelerator.
#include <p30f6014A.h> #include <motor_led/e_epuck_ports.h> #include <motor_led/e_init_port.h> #include <a_d/advance_ad_scan/e_ad_conv.h> #include <a_d/advance_ad_scan/e_acc.h> int main(void) { int z; e_init_port(); e_init_ad_scan(); while(1) { long i; z = e_get_acc(2); if(z < 2100) //LED4 on if e-puck is on the back { LED0 = 0; LED4 = 1; } else //LED0 on if e-puck is on his wells { LED0 = 1; LED4 = 0; } for(i=0; i<100000; i++) { asm("nop"); } } }
| void calculate_acc_raw | ( | void | ) |
read the x, y, z values, apply an averaging filter and finaly subbstract the center values.
| void calculate_acc_spherical | ( | void | ) |
calculate the intensity of the acceleration vector, and the Euler's angles
| void e_acc_calibr | ( | void | ) |
initialize de ad converter and calculate the zero values
It reads two times the average_size to avoid edge effects then it reads 100 values and average them to initiate the "zero" value of the accelerometer
| void e_display_angle | ( | void | ) |
light the led according to the orientation angle
| int e_get_acc | ( | unsigned int | captor | ) |
Read the last value of a given accelerator axes.
| captor | ID of the AD channel to read (must be 0 = x, 1 = y or 2 = z) |
| int e_get_acc_filtered | ( | unsigned int | captor, | |
| unsigned int | filter_size | |||
| ) |
Read the value of a channel, filtered by an averaging filter.
| captor | ID of the AD channel to read (must be 0 to 2) | |
| filter_size | size of the filter (must be between 1 and SAMPLE_NUMBER) |
| float e_read_acc | ( | void | ) |
calculate and return the intensity of the acceleration
| TypeAccSpheric e_read_acc_spheric | ( | void | ) |
calculate and return the accel. in spherical coord
| int e_read_acc_x | ( | void | ) |
calculate and return acceleration on the x axis
| TypeAccRaw e_read_acc_xyz | ( | void | ) |
calculate and return acceleration on the x,y,z axis
| int e_read_acc_y | ( | void | ) |
calculate and return acceleration on the y axis
| int e_read_acc_z | ( | void | ) |
calculate and return acceleration on the z axis
| float e_read_inclination | ( | void | ) |
calculate and return the inclination angle
| float e_read_orientation | ( | void | ) |
calculate and return the orientation angle
int acc_x [static] |
int acc_y [static] |
int acc_z [static] |
float acceleration [static] |
int angle_mem = 0 [static] |
int centre_x = 0 [static] |
int centre_y = 0 [static] |
int centre_z = 2000 [static] |
| int e_acc_scan[3][ACC_SAMP_NB] |
Array to store the acc values
| unsigned int e_last_acc_scan_id |
float inclination [static] |
float orientation [static] |
1.5.4