00001 /* 00002 * Copyright Droids Corporation, Microb Technology, Eirbot (2005) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Revision : $Id: position_manager.h,v 1.6 2008-01-08 20:05:03 zer0 Exp $ 00019 * 00020 */ 00021 00022 00023 #ifndef _ROBOT_POSITION_MANAGER_H_ 00024 #define _ROBOT_POSITION_MANAGER_H_ 00025 00026 #include <math.h> 00027 #include <robot_system.h> 00028 00033 struct robot_physical_params 00034 { 00035 double track_cm; 00036 double distance_imp_per_cm; 00037 }; 00038 00039 00044 struct xya_position 00045 { 00046 double x; 00047 double y; 00048 double a; 00049 }; 00050 00055 struct xya_position_s16 00056 { 00057 int16_t x; 00058 int16_t y; 00059 int16_t a; 00060 }; 00061 00066 struct robot_position 00067 { 00068 uint8_t use_ext; 00069 struct robot_physical_params phys; 00070 struct xya_position pos_d; 00071 struct xya_position_s16 pos_s16; 00072 struct rs_polar prev_encoders; 00073 struct robot_system * rs; 00074 }; 00075 00076 00078 void position_init(struct robot_position * pos); 00079 00081 void position_set(struct robot_position * pos, int16_t x, int16_t y, int16_t a); 00082 00083 void position_use_ext(struct robot_position * pos); 00084 void position_use_mot(struct robot_position * pos); 00085 00086 00092 void position_set_physical_params(struct robot_position * pos, double track_cm, 00093 double distance_imp_per_cm); 00094 00100 void position_set_related_robot_system(struct robot_position * pos, struct robot_system * rs); 00101 00107 void position_manage(struct robot_position * pos); 00108 00109 00113 int16_t position_get_x_s16(struct robot_position *pos); 00114 00118 int16_t position_get_y_s16(struct robot_position *pos); 00119 00123 int16_t position_get_a_deg_s16(struct robot_position *pos); 00124 00128 double position_get_x_double(struct robot_position *pos); 00129 00133 double position_get_y_double(struct robot_position *pos); 00134 00138 double position_get_a_rad_double(struct robot_position *pos); 00139 00140 00141 #endif