Rev 1625 |
Rev 1647 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <kernel/kern.h>
#include <kernel/func.h>
#include <semaphore.h>
#include "modules/sem.h"
#include "modules/hartport.h"
#include <drivers/keyb.h>
#include <servo.h>
//#include <drivers/udpip.h>
/* COM Port Constants */
#define COM_PORT COM1
#define COM_SPEED 115200
#define com(i) ((i) / 12) ? COM1 : COM2
#define pin(i) (i) % 12
/* Angle bounds */
#define POS_X_MIN 0
#define POS_X_MAX 200
#define POS_Y_MIN -200
#define POS_Y_MAX 200
#define POS_Z_MIN -150
#define POS_Z_MAX 150
typedef struct {
int adc_in;
unsigned char pwm;
} LEG_CFG_STATE;
typedef struct { /*describe the position of leg*/
int x;
int y;
int z;
} LEG_POS_STATE;
typedef struct { /*describe the servo angles*/
int a;
int b;
int c;
} LEG_ANG_STATE;
typedef struct {
LEG_CFG_STATE cfg[6];
LEG_ANG_STATE ang[6];
char power;
} HEXAPOD_STATE;
/*****************************************/
#define EVT_SET_MASK_LEG_ANGLE 0x01
#define EVT_STATUS_FREE 0x00
#define EVT_STATUS_WAIT 0x01
#define EVT_STATUS_EXEC 0x02
#define EVT_STATUS_DONE 0x03
struct action_event {
unsigned char type;
unsigned char status;
struct timespec time;
unsigned char mask;
LEG_ANG_STATE ang; //Servo angle data
unsigned char pwm;
struct action_event *next;
};
struct action_event *get_first_old_event(struct timespec *time);
extern sem_t mx_status;
extern HEXAPOD_STATE status;
void init_send(void);
void end_send(void);
void init_key(void);
/* Calibration */
void calibrate_init(void);
void calibrate_step(int step);
int adjust(int angle_sec, int leg, int num);
/* Actions */
int init_action_event(int number_of_events);
int insert_action_event(struct action_event *e);
int delete_action_event(int event);
struct action_event * get_first_old_event(struct timespec *time);
/* Tracer */
int trace_init(int buffer_size);
int trace_consumption(int sensor, int value);
int trace_send();