Rev 1336 |
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>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
/*
* Copyright (C) 2000 Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#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>
/* COM Port Constants */
#define COM_PORT COM2
#define COM_SPEED 115200
#define com(i) ((i) / 12) ? COM2 : COM1
#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_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 insert_action_event(struct action_event *e);
int delete_action_event(struct action_event *e);
struct action_event * get_first_old_event(struct timespec *time);