rflex_configs.h
1/* Player - One Hell of a Robot Server
2 * Copyright (C) 2000
3 * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22/* some basic structures and conversions needed by everything
23 *
24 * data for the conversions and everything else will be grabbed out of
25 * the general configuration file
26 *
27 * note - they way it is now is the right way to do it, BUT:
28 * if your a hacker and want things to run fast - put all the configurations
29 * here as #define's, this will allow the precompiler to precompute combined
30 * conversions, this is much preferable to modifying the rest of the code
31 * if you really need the speed that badly
32 */
33
34// NOTICE! - this file declares rflex_configs extern, intended to link to
35// the rflex_configs declared in rflex.cc
36
37#ifndef RFLEX_CONFIGS_H
38#define RFLEX_CONFIGS_H
39
40#include <math.h>
41#include <libplayerinterface/player.h>
42
43//normalizes an angle in radians to -M_PI<theta<M_PI
44inline double normalize_theta(double theta){
45 while(theta>M_PI)
46 theta-=2*M_PI;
47 while(theta<-M_PI)
48 theta+=2*M_PI;
49 return theta;
50}
51
52//structures for holding general configuration of robot
53typedef struct rflex_config_t{
54 char serial_port[256];
55 //length of the robot in m
56 double m_length;
57 //width of the robot in m
58 double m_width;
59 //m*odo_distance_conversion : m to rflex arbitrary odometry units (trans)
60 double odo_distance_conversion;
61 //rad*odo_angle_conversion : rad to rflex arbitrary odometry units (rot)
62 double odo_angle_conversion;
63 //mm*range_distance_conversion : m to rflex arbitrary range units
64 double range_distance_conversion;
65 //default translational acceleration in m/sec
66 double mPsec2_trans_acceleration;
67 //default rotational acceleration in rad/sec
68 double radPsec2_rot_acceleration;
69
70 // absolute heading dio address (if ommited then absolute heading not used)
71 int heading_home_address;
72 // home on startup
73 bool home_on_start;
74
75 // use rflex joystick to command robot?
76 bool use_joystick;
77 double joy_pos_ratio, joy_ang_ratio;
78
79 //maximum number of sonar supported by modules
80 //(generally 16*number of sonar controller boards, or banks)
81 int max_num_sonars;
82 //total number of physical sonar
83 int num_sonars;
84 //how long to buffer for filter (filter just takes smallest of last n readings)
85 int sonar_age;
86 //number of physical sonar sonar controller boards or banks on your robot
87 int num_sonar_banks;
88 // number of sonars that can be attached to each sonar controller (16)
89 int num_sonars_possible_per_bank;
90 // number of actual sonar attached to each sonar controller, (in each bank)
91 int *num_sonars_in_bank;
92 // pose of each sonar on the robot (x,y,t) in rad and mm
93 // note i is forwards, j is left
94 player_pose3d_t *mrad_sonar_poses;
95 //not sure what these do yet actually
96 long sonar_echo_delay;
97 long sonar_ping_delay;
98 long sonar_set_delay;
99 // options to support 2nd sonar bank
100 long sonar_2nd_bank_start;
101 long sonar_1st_bank_end;
102 long sonar_max_range; // in mm
103
104
105 // bumper configs
106 unsigned short bumper_count;
107 int bumper_address;
110 player_bumper_define_t * bumper_def;
111
112 // power configs
113 float power_offset;
114
115 // ir configs
116 player_ir_pose_t ir_poses;
117 int ir_base_bank;
118 int ir_bank_count;
119 int ir_total_count;
120 int * ir_count;
121 double * ir_a;
122 double * ir_b;
123 float ir_min_range;
124 float ir_max_range;
126
127//notice - every file that includes this header gets a GLOBAL rflex_configs!!
128// be careful
129extern rflex_config_t rflex_configs;
130
131/************ conversions ********************/
132/*** rather obvious - ARB stands for arbitrary (look above) ***/
133
134//player uses degrees, but I use radians (so cos, and sin work correctly)
135#define ARB2RAD_ODO_CONV(x) ((x)/rflex_configs.odo_angle_conversion)
136#define RAD2ARB_ODO_CONV(x) ((x)*rflex_configs.odo_angle_conversion)
137#define ARB2M_ODO_CONV(x) ((x)/rflex_configs.odo_distance_conversion)
138#define M2ARB_ODO_CONV(x) ((x)*rflex_configs.odo_distance_conversion)
139
140#define ARB2M_RANGE_CONV(x) (x/rflex_configs.range_distance_conversion)
141#define M2ARB_RANGE_CONV(x) (x*rflex_configs.range_distance_conversion)
142
143#endif
144
145
146
147
148
149
150
151
152
A pose in space.
Definition player.h:229
Definition rflex_configs.h:53
int bumper_style
bumper bit style
Definition rflex_configs.h:109