2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: position_manager.h,v 1.5.4.4 2009-05-18 12:27:26 zer0 Exp $
23 #ifndef _ROBOT_POSITION_MANAGER_H_
24 #define _ROBOT_POSITION_MANAGER_H_
27 #include <robot_system.h>
30 * structure that stores the number of impulsions that corresponds to
31 * a mm or a degre. We also need to specify the track of the
33 struct robot_physical_params
36 double distance_imp_per_mm;
41 * stores a cartesian position on the area in double
42 * WARNING : a is stored in radian
52 * stores a cartesian position on the area in integers
53 * WARNING : a is stored in degree
55 struct xya_position_s16
63 * Structure that stores everthing we need to get and stores the
64 * position of the robot
69 struct robot_physical_params phys;
70 struct xya_position pos_d;
71 struct xya_position_s16 pos_s16;
72 struct rs_polar prev_encoders;
73 struct robot_system *rs;
74 #ifdef CONFIG_MODULE_COMPENSATE_CENTRIFUGAL_FORCE
75 double centrifugal_coef;
80 /** initialization of the robot_position pos, everthing is set to 0 */
81 void position_init(struct robot_position *pos);
83 #ifdef CONFIG_MODULE_COMPENSATE_CENTRIFUGAL_FORCE
84 /** set arbitrary coef to compensate the centrifugal force */
85 void position_set_centrifugal_coef(struct robot_position *pos, double coef);
88 /** Set a new robot position */
89 void position_set(struct robot_position *pos, int16_t x, int16_t y, double a_deg);
91 void position_use_ext(struct robot_position *pos);
92 void position_use_mot(struct robot_position *pos);
96 * Set the physical parameters of the robot :
97 * - distance between wheels (track, in mm)
98 * - number of impulsions for 1 mm (distance)
100 void position_set_physical_params(struct robot_position *pos, double track_mm,
101 double distance_imp_per_mm);
104 * Save in pos structure the pointer to the associated robot_system.
105 * The robot_system structure is used to get values from virtual encoders
106 * that return angle and distance.
108 void position_set_related_robot_system(struct robot_position *pos, struct robot_system *rs);
111 * Process the absolute position (x,y,a) depending on the delta on
112 * virtual encoders since last read, and depending on physical
115 void position_manage(struct robot_position *pos);
121 int16_t position_get_x_s16(struct robot_position *pos);
126 int16_t position_get_y_s16(struct robot_position *pos);
129 * returns current alpha
131 int16_t position_get_a_deg_s16(struct robot_position *pos);
136 double position_get_x_double(struct robot_position *pos);
141 double position_get_y_double(struct robot_position *pos);
144 * returns current alpha
146 double position_get_a_rad_double(struct robot_position *pos);