Subversion Repositories shark

Rev

Rev 1337 | Rev 1390 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1331 giacomo 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 *
8
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
9
 *
10
 * http://www.sssup.it
11
 * http://retis.sssup.it
12
 * http://hartik.sssup.it
13
 */
14
 
15
#include <stdlib.h>
16
#include <string.h>
17
#include <math.h>
18
#include <kernel/kern.h>
19
#include <kernel/func.h>
20
#include <semaphore.h>
21
#include "modules/sem.h"
22
#include "modules/hartport.h"
1359 giacomo 23
#include <drivers/shark_keyb26.h>
1331 giacomo 24
 
25
#include <servo.h>
26
 
27
/* COM Port Constants */
1359 giacomo 28
#define COM_PORT COM1
1331 giacomo 29
#define COM_SPEED 115200
30
 
1359 giacomo 31
#define com(i) ((i) / 12) ? COM1 : COM2
1331 giacomo 32
#define pin(i) (i) % 12
33
 
34
/* Angle bounds */
35
#define POS_X_MIN          0
36
#define POS_X_MAX        200
37
#define POS_Y_MIN       -200
38
#define POS_Y_MAX        200
39
#define POS_Z_MIN       -150
40
#define POS_Z_MAX        150
41
 
1333 giacomo 42
typedef struct {
43
        int             adc_in;
44
        unsigned char   pwm;
45
} LEG_CFG_STATE;
46
 
1336 giacomo 47
typedef struct { /*describe the position of leg*/
1331 giacomo 48
        int             x;
49
        int             y;
50
        int             z;
1333 giacomo 51
} LEG_POS_STATE;
1331 giacomo 52
 
1336 giacomo 53
typedef struct { /*describe the servo angles*/
1333 giacomo 54
        int             a;
55
        int             b;
56
        int             c;
57
} LEG_ANG_STATE;
58
 
1331 giacomo 59
typedef struct {
1333 giacomo 60
        LEG_CFG_STATE   cfg[6];
61
        LEG_ANG_STATE   ang[6];
1331 giacomo 62
        char            power;
63
} HEXAPOD_STATE;
64
 
65
/*****************************************/
66
 
1333 giacomo 67
#define EVT_SET_MASK_LEG_ANGLE  0x01
68
 
69
#define EVT_STATUS_WAIT         0x01
70
#define EVT_STATUS_EXEC         0x02
71
#define EVT_STATUS_DONE         0x03
72
 
73
struct action_event {
74
 
75
  unsigned char       type;
76
  unsigned char       status;
77
  struct timespec     time;
78
  unsigned char       mask;
1336 giacomo 79
  LEG_ANG_STATE       ang; //Servo angle data
80
  unsigned char       pwm;
1333 giacomo 81
  struct action_event *next;
82
 
83
};
84
 
85
struct action_event *get_first_old_event(struct timespec *time);
86
 
1331 giacomo 87
extern  sem_t           mx_status;
88
extern  HEXAPOD_STATE   status;
89
 
90
void    init_send(void);
91
void    end_send(void);
92
 
93
void    init_key(void);
1336 giacomo 94
 
1337 giacomo 95
/* Calibration */
96
 
97
void calibrate_init(void);
98
void calibrate_step(int step);
1336 giacomo 99
int adjust(int angle_sec, int leg, int num);
100
 
1337 giacomo 101
/* Actions */
102
 
103
int insert_action_event(struct action_event *e);
104
int delete_action_event(struct action_event *e);
105
struct action_event * get_first_old_event(struct timespec *time);
106