Subversion Repositories shark

Rev

Rev 1333 | 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
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/*
18
 * Copyright (C) 2000 Paolo Gai
19
 *
20
 * This program is free software; you can redistribute it and/or modify
21
 * it under the terms of the GNU General Public License as published by
22
 * the Free Software Foundation; either version 2 of the License, or
23
 * (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
 *
34
 */
35
 
36
#include <stdlib.h>
37
#include <string.h>
38
#include <math.h>
39
#include <kernel/kern.h>
40
#include <kernel/func.h>
41
#include <semaphore.h>
42
#include "modules/sem.h"
43
#include "modules/hartport.h"
44
#include <drivers/keyb.h>
45
 
46
#include <servo.h>
47
 
48
/* COM Port Constants */
49
#define COM_PORT COM2
50
#define COM_SPEED 115200
51
 
52
#define com(i) ((i) / 12) ? COM2 : COM1
53
#define pin(i) (i) % 12
54
 
55
/* Angle bounds */
56
#define POS_X_MIN          0
57
#define POS_X_MAX        200
58
#define POS_Y_MIN       -200
59
#define POS_Y_MAX        200
60
#define POS_Z_MIN       -150
61
#define POS_Z_MAX        150
62
 
1333 giacomo 63
typedef struct {
64
        int             adc_in;
65
        unsigned char   pwm;
66
} LEG_CFG_STATE;
67
 
1336 giacomo 68
typedef struct { /*describe the position of leg*/
1331 giacomo 69
        int             x;
70
        int             y;
71
        int             z;
1333 giacomo 72
} LEG_POS_STATE;
1331 giacomo 73
 
1336 giacomo 74
typedef struct { /*describe the servo angles*/
1333 giacomo 75
        int             a;
76
        int             b;
77
        int             c;
78
} LEG_ANG_STATE;
79
 
1331 giacomo 80
typedef struct {
1333 giacomo 81
        LEG_CFG_STATE   cfg[6];
82
        LEG_ANG_STATE   ang[6];
1331 giacomo 83
        char            power;
84
} HEXAPOD_STATE;
85
 
86
/*****************************************/
87
 
1333 giacomo 88
#define EVT_SET_MASK_LEG_ANGLE  0x01
89
 
90
#define EVT_STATUS_WAIT         0x01
91
#define EVT_STATUS_EXEC         0x02
92
#define EVT_STATUS_DONE         0x03
93
 
94
struct action_event {
95
 
96
  unsigned char       type;
97
  unsigned char       status;
98
  struct timespec     time;
99
  unsigned char       mask;
1336 giacomo 100
  LEG_ANG_STATE       ang; //Servo angle data
101
  unsigned char       pwm;
1333 giacomo 102
  struct action_event *next;
103
 
104
};
105
 
106
struct action_event *get_first_old_event(struct timespec *time);
107
 
1331 giacomo 108
extern  sem_t           mx_status;
109
extern  HEXAPOD_STATE   status;
110
 
111
void    init_send(void);
112
void    end_send(void);
113
 
114
void    init_key(void);
1336 giacomo 115
 
116
int adjust(int angle_sec, int leg, int num);
117