Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
 
22
/**
23
 ------------
24
 CVS :        $Id: auto.h,v 1.1.1.1 2002-09-02 09:37:42 pj Exp $
25
 
26
 File:        $File$
27
 Revision:    $Revision: 1.1.1.1 $
28
 Last update: $Date: 2002-09-02 09:37:42 $
29
 ------------
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Marco Dallera and Marco Fiocca
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
/*
52
 *              AUTO
53
 *
54
 * Another Unuseful Track simulatOr
55
 *
56
 * Authors: Marco Dallera
57
 *          Marco Fiocca
58
 *
59
 */
60
 
61
/* ------------------- */
62
/*  Useful structures  */
63
/* ------------------- */
64
 
65
#ifndef __CAR_H_
66
 
67
#define __CAR_H_
68
 
69
#include <modules/cabs.h>
70
#include <kernel/func.h>
71
#include <kernel/model.h>
72
#include <kernel/types.h>
73
#include <drivers/keyb.h>
74
#include <drivers/glib.h>
75
#include <semaphore.h>
76
#include <math.h>
77
#include <stdio.h>
78
#include <stdlib.h>
79
#include <string.h>
80
#include "const.h"
81
 
82
#define degree_to_rad(a) ((M_PI/180.0)*(a))
83
#define rad_to_degree(a) ((180.0/M_PI)*(a))
84
 
85
typedef struct {
86
  int x;
87
  int y;
88
} point;
89
 
90
typedef struct {
91
  float x,y;
92
} point_f;
93
 
94
typedef struct {
95
  float mod;
96
  float phase;
97
} vector;
98
 
99
typedef struct {
100
  point_f pos;
101
  float orient;
102
} car_status;
103
 
104
typedef struct {
105
  int left_border;
106
  int right_border;
107
  int distance;
108
  float curve;
109
  point opps_list[MAX_CAR_NUMBER];
110
  int opps_number;
111
  int collision;
112
  int flag;
113
} road_info;
114
 
115
typedef struct {
116
  int left,center,right;
117
} road_strip;
118
 
119
typedef struct {
120
  PID sensor_pid,control_pid;
121
  int number;
122
  char driver[MAX_DRIVER_NAME_LENGTH];
123
  float max_speed, min_acc, max_acc;
124
  float rage;
125
  CAB road_status_cab;
126
  CAB car_status_cab;
127
  int color;
128
} car_params;
129
 
130
typedef struct {
131
  char name[MAX_TRACK_NAME_LENGTH];     // il nome del file
132
  point pole_pos;               // la posizione di partenza
133
  float pole_orient;    // la direzione di partenza
134
  int lap;                      // il senso di marcia: CLOCK, ANTICLOCK
135
  int selected;         // it's a flag marking the actually selected track
136
} track;
137
 
138
typedef struct {
139
  int min;
140
  int sec;
141
  int dec;
142
} time;
143
 
144
extern car_params cars[MAX_CAR_NUMBER];
145
extern char track_img[TRACK_WIDTH*TRACK_HEIGHT];
146
extern track track_list[TRACK_NUMBER];
147
 
148
/* ---------------------------------------- */
149
/*  Functions definition                    */
150
/* ---------------------------------------- */
151
 
152
/* CABs R/W functions */
153
int set_car_status(car_status, CAB);    // sends the new status according to the control law
154
car_status get_car_status(CAB);                 // reads car status from a CAB
155
int set_road_info(road_info, CAB);              // sends the new road informations
156
road_info get_road_info(CAB);                   // reads road status values from a CAB
157
 
158
/* Keyboard functions */
159
void keyb_handler();
160
void endfun(KEY_EVT *);
161
void my_close(void *);
162
 
163
/* Display functions */
164
void bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name);
165
void bidir_bar_display(point p1, int width, int height, int border, float var, float max, int color, char *name);
166
void cmd_display();
167
 
168
/* Closing function */
169
void byebye();
170
void error_msg();
171
 
172
/* Tasks */
173
TASK sensor();                  // Camera car task
174
TASK control();                 // Car controller task
175
TASK manual();                  // Manual driving task
176
TASK actuator();                // Graphic drawing task
177
TASK info();                    // Car informations display task
178
 
179
/* Tasks management */
180
void hard_car_create();
181
void soft_car_create();
182
void killcar();
183
 
184
/* Tracks management */
185
int track_init();
186
 
187
#endif
188