stage.h

Go to the documentation of this file.
00001 #ifndef STG_H
00002 #define STG_H
00003 /*
00004  *  Stage : a multi-robot simulator.  
00005  * 
00006  *  Copyright (C) 2001-2004 Richard Vaughan, Andrew Howard and Brian
00007  *  Gerkey for the Player/Stage Project
00008  *  http://playerstage.sourceforge.net
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 /* File: stage.h
00027  * Desc: External header file for the Stage library
00028  * Authors: Richard Vaughan vaughan@sfu.ca 
00029  *          Andrew Howard ahowards@usc.edu
00030  *          Brian Gerkey gerkey@stanford.edu
00031  * Date: 1 June 2003
00032  * CVS: $Id: stage.h,v 1.193 2007/09/11 21:30:09 rtv Exp $
00033  */
00034 
00035 
00043 #include <unistd.h>
00044 #include <stdint.h> // for portable int types eg. uint32_t
00045 #include <sys/types.h>
00046 #include <sys/time.h>
00047 #include <glib.h> // we use GLib's data structures extensively
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif 
00052 
00091 #define FiducialNone 0
00092 
00094 #define STG_TOKEN_MAX 64
00095 
00104   typedef int stg_id_t;
00105   
00107   typedef double stg_meters_t;
00108   
00110   typedef double stg_radians_t;
00111   
00113   typedef unsigned long stg_msec_t;
00114 
00116   typedef double stg_kg_t; // Kilograms (mass)
00117 
00119   typedef double stg_joules_t;
00120 
00122   typedef double stg_watts_t; 
00123 
00125   typedef int stg_bool_t;
00126 
00127   //typedef double stg_friction_t;
00128   
00130   typedef uint32_t stg_color_t;
00131 
00134   //typedef int stg_obstacle_return_t;
00135 
00138   //typedef int stg_blob_return_t;
00139 
00141   //typedef int stg_fiducial_return_t;
00142 
00143   //typedef int stg_ranger_return_t;
00144   
00145   //typedef enum { STG_GRIP_NO = 0, STG_GRIP_YES } stg_gripper_return_t;
00146   
00149   typedef struct 
00150   {
00151     stg_meters_t x, y;
00152   } stg_size_t;
00153   
00157   typedef struct
00158   {
00159     stg_meters_t x, y, a;
00160   } stg_pose_t;
00161   
00164   typedef stg_pose_t stg_velocity_t;  
00165 
00169   typedef struct
00170   {
00171     stg_pose_t pose;
00172     stg_size_t size;
00173   } stg_geom_t;
00174   
00176   typedef struct
00177   {
00178     double min; //< smallest value in range
00179     double max; //< largest value in range
00180   } stg_bounds_t;
00181   
00183   typedef struct
00184   {
00185     stg_bounds_t range; //< min and max range of sensor
00186     stg_radians_t angle; //< width of viewing angle of sensor
00187   } stg_fov_t;
00188 
00190   typedef struct 
00191   {
00192     stg_radians_t pan;
00193     stg_radians_t tilt;
00194     stg_radians_t zoom;
00195   } stg_ptz_t;
00196  // end types
00198 
00199 
00200   // GUIFEATURES -------------------------------------------------------
00201   
00202   
00203  // forward declare struct types from player_internal.h
00204   struct _stg_model;
00205   struct _stg_matrix;
00206   struct _gui_window;
00207   struct _stg_world;
00208 
00209   typedef struct _stg_model stg_model_t; //  defined in stage_internal.
00210   typedef struct _stg_world stg_world_t; 
00211 
00212 
00213 
00216   stg_msec_t stg_timenow( void );
00217   
00223   int stg_init( int argc, char** argv );
00224   
00225   
00227   int stg_quit_test( void );
00228 
00231   void stg_quit_request( void );
00232 
00233   
00237   const char* stg_version_string( void );
00238 
00239 
00240   // POINTS ---------------------------------------------------------
00248   typedef struct
00249   {
00250     stg_meters_t x, y;
00251   } stg_point_t;
00252 
00255   stg_point_t* stg_points_create( size_t count );
00256 
00258   void stg_points_destroy( stg_point_t* pts );
00259 
00262   // POLYLINES ---------------------------------------------------------
00263 
00271   typedef struct
00272   {
00273     stg_point_t* points; 
00274     size_t points_count; 
00275   } stg_polyline_t; 
00276 
00279   // POLYGONS ---------------------------------------------------------
00280   
00289   typedef struct
00290   {
00292     GArray* points;
00293     
00295     stg_bool_t unfilled; 
00296     
00298     stg_color_t color;
00299 
00301     stg_size_t bbox;
00302 
00303     void* _data; // temporary internal use only
00304   } stg_polygon_t; 
00305 
00306   
00308   stg_polygon_t* stg_polygons_create( int count );
00309   
00311   void stg_polygons_destroy( stg_polygon_t* p, size_t count );
00312   
00314   stg_polygon_t* stg_unit_polygon_create( void );
00315     
00319   void stg_polygon_set_points( stg_polygon_t* poly, stg_point_t* pts, size_t count );                          
00322   void stg_polygon_append_points( stg_polygon_t* poly, stg_point_t* pts, size_t count );                               
00323   
00326   void stg_polygons_normalize( stg_polygon_t* polys, int num, 
00327                                double width, double height );
00328   
00330   void stg_polygon_print( stg_polygon_t* poly );
00331   
00333   void stg_polygons_print( stg_polygon_t* polys, unsigned int count );
00334   
00339   stg_polygon_t* stg_polygons_from_image_file(  const char* filename, 
00340                                                 size_t* poly_count );
00341   
00344   // end property typedefs -------------------------------------------------
00345 
00346 
00347  //  WORLD --------------------------------------------------------
00348 
00367   stg_world_t* stg_world_create( stg_id_t id, 
00368                                  const char* token, 
00369                                  int sim_interval, 
00370                                  int real_interval,
00371                                  double ppm,
00372                                  double width,
00373                                  double height );
00374 
00378   stg_world_t* stg_world_create_from_file( const char* worldfile_path );
00379 
00382   void stg_world_destroy( stg_world_t* world );
00383   
00386   void stg_world_stop( stg_world_t* world );
00387   
00390   void stg_world_start( stg_world_t* world );
00391 
00398   int stg_world_update( stg_world_t* world, int sleepflag );
00399 
00401   void stg_world_load( stg_world_t* mod );
00402 
00404   void stg_world_save( stg_world_t* mod );
00405 
00408   void stg_world_print( stg_world_t* world );
00409 
00412   void stg_world_set_interval_real( stg_world_t* world, unsigned int val );
00413   
00417   void stg_world_set_interval_sim( stg_world_t* world, unsigned int val );
00418 
00421   stg_model_t* stg_world_get_model( stg_world_t* world, stg_id_t mid );
00422   
00424   stg_model_t* stg_world_model_name_lookup( stg_world_t* world, const char* name );
00425   
00428   //  MODEL --------------------------------------------------------
00429     
00430   // group the docs of all the model types
00437   // Movement masks for figures
00438 #define STG_MOVE_TRANS (1 << 0)
00439 #define STG_MOVE_ROT   (1 << 1)
00440 #define STG_MOVE_SCALE (1 << 2)
00441   
00442   typedef int stg_movemask_t;
00443 
00454   typedef int (*stg_model_callback_t)(stg_model_t* mod, void* user );
00455 
00456   void stg_model_add_callback( stg_model_t* mod, 
00457                                void* member, 
00458                                stg_model_callback_t cb, 
00459                                void* user );
00460 
00461   int stg_model_remove_callback( stg_model_t* mod,
00462                                  void* member,
00463                                  stg_model_callback_t callback );
00464 
00465   
00472   typedef int(*stg_model_initializer_t)(stg_model_t*);
00473   
00474 
00475   
00477   typedef enum 
00478     {
00479       LaserTransparent, 
00480       LaserVisible, 
00481       LaserBright  
00482     } stg_laser_return_t;
00483 
00485   stg_model_t* stg_model_create(  stg_world_t* world,
00486                                   stg_model_t* parent, 
00487                                   stg_id_t id, 
00488                                   char* typestr );
00489   
00491   void stg_model_destroy( stg_model_t* mod );
00492 
00494   void stg_model_get_global_pose( stg_model_t* mod, stg_pose_t* pose );
00495 
00497   void stg_model_get_global_velocity( stg_model_t* mod, stg_velocity_t* gvel );
00498 
00499   /* set the velocity of a model in the global coordinate system */
00500   void stg_model_set_global_velocity( stg_model_t* mod, stg_velocity_t* gvel );
00501 
00503   void stg_model_subscribe( stg_model_t* mod );
00504 
00506   void stg_model_unsubscribe( stg_model_t* mod );
00507 
00509   void stg_model_load( stg_model_t* mod );
00510 
00512   void stg_model_save( stg_model_t* mod );
00513 
00515   //const char* stg_model_type_string( stg_model_type_t type );
00516 
00517   // SET properties - use these to set props, don't set them directly
00518 
00520   void stg_model_set_global_pose( stg_model_t* mod, stg_pose_t* gpose );
00521   
00523   void stg_model_set_velocity( stg_model_t* mod, stg_velocity_t* vel );
00524  
00526   void stg_model_set_pose( stg_model_t* mod, stg_pose_t* pose );
00527 
00529   void stg_model_set_geom( stg_model_t* mod, stg_geom_t* src );
00530 
00532   void stg_model_set_fiducial_return( stg_model_t* mod, int fid );
00533 
00536   void stg_model_set_fiducial_key( stg_model_t* mod, int key );
00537 
00539   int stg_model_set_parent( stg_model_t* mod, stg_model_t* newparent);
00540   
00543   void stg_model_get_geom( stg_model_t* mod, stg_geom_t* dest );
00544 
00546   void stg_model_get_pose( stg_model_t* mod, stg_pose_t* dest );
00547 
00549   void stg_model_get_velocity( stg_model_t* mod, stg_velocity_t* dest );
00550   
00553   stg_polygon_t* stg_model_get_polygons( stg_model_t* mod, size_t* poly_count );
00554   void stg_model_set_polygons( stg_model_t* mod,
00555                                stg_polygon_t* polys, 
00556                                size_t poly_count );
00557   
00559   void stg_model_set_lines( stg_model_t* mod,
00560                             stg_polyline_t* lines, 
00561                             size_t lines_count );
00562   
00563   // guess what these do?
00564   void stg_model_get_velocity( stg_model_t* mod, stg_velocity_t* dest );
00565   void stg_model_set_velocity( stg_model_t* mod, stg_velocity_t* vel );
00566   void stg_model_set_pose( stg_model_t* mod, stg_pose_t* pose );
00567   void stg_model_get_geom( stg_model_t* mod, stg_geom_t* dest );
00568   void stg_model_set_geom( stg_model_t* mod, stg_geom_t* geom );
00569   void stg_model_set_color( stg_model_t* mod, stg_color_t col );
00570   void stg_model_set_mass( stg_model_t* mod, stg_kg_t mass );
00571   void stg_model_set_stall( stg_model_t* mod, stg_bool_t stall );
00572   void stg_model_set_gripper_return( stg_model_t* mod, int val );
00573   void stg_model_set_audio_return( stg_model_t* mod, int val );
00574   void stg_model_set_laser_return( stg_model_t* mod, int val );
00575   void stg_model_set_obstacle_return( stg_model_t* mod, int val );
00576   void stg_model_set_blob_return( stg_model_t* mod, int val );
00577   void stg_model_set_ranger_return( stg_model_t* mod, int val );
00578   void stg_model_set_boundary( stg_model_t* mod, int val );
00579   void stg_model_set_gui_nose( stg_model_t* mod, int val );
00580   void stg_model_set_gui_mask( stg_model_t* mod, int val );
00581   void stg_model_set_gui_grid( stg_model_t* mod, int val );
00582   void stg_model_set_gui_outline( stg_model_t* mod, int val );
00583   void stg_model_set_watts( stg_model_t* mod, stg_watts_t watts );
00584   void stg_model_set_map_resolution( stg_model_t* mod, stg_meters_t res );
00585 
00586 #define STG_MP_PREFIX          "_mp_"
00587 
00588 #define STG_MP_POSE                     "_mp_pose"
00589 #define STG_MP_VELOCITY                 "_mp_velocity"
00590 #define STG_MP_GEOM                     "_mp_geom"
00591 #define STG_MP_COLOR                    "_mp_color"
00592 #define STG_MP_WATTS                    "_mp_watts"
00593 #define STG_MP_FIDUCIAL_RETURN          "_mp_fiducial_return"
00594 #define STG_MP_LASER_RETURN             "_mp_laser_return"
00595 #define STG_MP_OBSTACLE_RETURN          "_mp_obstacle_return"
00596 #define STG_MP_RANGER_RETURN            "_mp_ranger_return"
00597 #define STG_MP_GRIPPER_RETURN           "_mp_gripper_return"
00598 #define STG_MP_AUDIO_RETURN             "_mp_audio_return"
00599 #define STG_MP_MASS                     "_mp_mass"
00600   
00601   /* TODO - complete the set of named properties */
00602 
00633   int stg_model_set_property( stg_model_t* mod, 
00634                               char* propname, 
00635                               void* data );
00636   
00643   void stg_model_unset_property( stg_model_t* mod,
00644                                  char* propname );
00645 
00648   void* stg_model_get_property( stg_model_t* mod, char* key );
00649   
00650 
00651 /*   /\** @TODO The callback cb will be called with argument arg when the */
00652 /*       property identified by key is set. *\/ */
00653 /*   void stg_model_set_property_callback( stg_model_t* mod, */
00654 /*                                      char* key, */
00655 /*                                      stg_property_callback cb, */
00656 /*                                      void* argn ); */
00657  
00661   void stg_model_print( stg_model_t* mod, char* prefix );
00662   
00665   int stg_model_is_antecedent( stg_model_t* mod, stg_model_t* testmod );
00666   
00669   int stg_model_is_descendent( stg_model_t* mod, stg_model_t* testmod );
00670   
00674   int stg_model_is_related( stg_model_t* mod1, stg_model_t* mod2 );
00675 
00677   stg_model_t* stg_model_root( stg_model_t* mod );
00678   
00680   GPtrArray* stg_model_array_from_tree( stg_model_t* root );
00681   
00683   int stg_model_startup( stg_model_t* mod );
00684 
00686   int stg_model_shutdown( stg_model_t* mod );
00687 
00690   int stg_model_update( stg_model_t* model );
00691   
00695   void stg_model_global_to_local( stg_model_t* mod, stg_pose_t* pose );
00696   
00700   void stg_model_local_to_global( stg_model_t* mod, stg_pose_t* pose );
00701 
00702   int stg_model_fig_clear_cb( stg_model_t* mod, void* data, size_t len, 
00703                               void* userp );
00704 
00705   void stg_model_set_data( stg_model_t* mod, void* data, size_t len );
00706   void stg_model_set_cmd( stg_model_t* mod, void* cmd, size_t len );
00707   void stg_model_set_cfg( stg_model_t* mod, void* cfg, size_t len );
00708   void* stg_model_get_cfg( stg_model_t* mod, size_t* lenp );
00709   void* stg_model_get_data( stg_model_t* mod, size_t* lenp );
00710   void* stg_model_get_cmd( stg_model_t* mod, size_t* lenp );
00711   
00712   void stg_model_draw_polygons( stg_model_t* mod, const char* group,
00713                                 double x, double y, double a, 
00714                                 stg_polygon_t* polys, size_t polycount );
00715   
00716   void stg_model_draw_polylines( stg_model_t* mod, const char* group, 
00717                                  double x, double y, double a, 
00718                                  stg_polyline_t* lines, size_t linecount,
00719                                  double thickness, stg_color_t colot );
00720   
00721   void stg_model_draw_points( stg_model_t* mod, const char* group,
00722                               double x, double y, double a, 
00723                               stg_point_t* points, size_t point, 
00724                               double size, stg_color_t color );
00725   
00726 
00730   void stg_model_add_property_toggles( stg_model_t* mod,
00731                                        void* member,
00732                                        stg_model_callback_t callback_on,
00733                                        void* arg_on,
00734                                        stg_model_callback_t callback_off,
00735                                        void* arg_off,
00736                                        const char* name,
00737                                        const char* label,
00738                                        gboolean enabled );
00739 
00740 
00741   // BLOBFINDER MODEL --------------------------------------------------------
00742   
00743 #define STG_BLOB_CHANNELS_MAX 16
00744   
00747   typedef struct
00748   {
00749     int channel_count; // 0 to STG_BLOBFINDER_CHANNELS_MAX
00750     stg_color_t channels[STG_BLOB_CHANNELS_MAX];
00751     int scan_width;
00752     int scan_height;
00753     stg_meters_t range_max;
00754   } stg_blobfinder_config_t;
00755   
00758   typedef struct
00759   {
00760     int channel;
00761     stg_color_t color;
00762     int xpos, ypos;   // all values are in pixels
00763     //int width, height;
00764     int left, top, right, bottom;
00765     int area;
00766     stg_meters_t range;
00767   } stg_blobfinder_blob_t;
00768 
00769 
00770 // ENERGY model --------------------------------------------------------------
00771   
00773   typedef struct
00774   {
00776     stg_joules_t stored;
00777 
00779     stg_bool_t charging;
00780 
00782     stg_meters_t range;
00783 
00785     GPtrArray* connections;
00786   } stg_energy_data_t;
00787 
00789   typedef struct
00790   {
00792     stg_joules_t capacity;
00793 
00795     stg_watts_t give_rate;
00796 
00798     stg_watts_t take_rate;
00799 
00801     stg_meters_t probe_range;
00802     
00804     stg_bool_t give;
00805 
00806   } stg_energy_config_t;
00807 
00808   // there is currently no energy command packet
00809 
00810 // BLINKENLIGHT -------------------------------------------------------
00811 
00812   //typedef struct
00813   //{
00814   //int enable;
00815   //stg_msec_t period;
00816   //} stg_blinkenlight_t;
00817 
00818 // PTZ MODEL --------------------------------------------------------
00819   
00822   typedef stg_ptz_t stg_ptz_cmd_t;
00823 
00826   typedef stg_ptz_t stg_ptz_data_t;
00827 
00830   typedef struct
00831   {
00832     stg_ptz_t min; 
00833     stg_ptz_t max; 
00834     stg_ptz_t goal; 
00835     stg_ptz_t speed; 
00836     stg_bool_t position_mode; 
00837   } stg_ptz_config_t;
00838 
00839 
00840   // LASER MODEL --------------------------------------------------------
00841   
00844   typedef struct
00845   {
00846     stg_meters_t range; 
00847     double reflectance; 
00848   } stg_laser_sample_t;
00849   
00852   typedef struct
00853   {
00854     stg_radians_t fov; 
00855     stg_meters_t range_max; 
00856     stg_meters_t range_min; 
00857 
00860     int samples;
00861 
00865     int resolution;
00866     } stg_laser_config_t;
00867     
00868   // GRIPPER MODEL --------------------------------------------------------
00869   
00870   typedef enum {
00871     STG_GRIPPER_PADDLE_OPEN = 0, // default state
00872     STG_GRIPPER_PADDLE_CLOSED, 
00873     STG_GRIPPER_PADDLE_OPENING,
00874     STG_GRIPPER_PADDLE_CLOSING,
00875   } stg_gripper_paddle_state_t;
00876 
00877   typedef enum {
00878     STG_GRIPPER_LIFT_DOWN = 0, // default state
00879     STG_GRIPPER_LIFT_UP, 
00880     STG_GRIPPER_LIFT_UPPING, // verbed these to match the paddle state
00881     STG_GRIPPER_LIFT_DOWNING, 
00882   } stg_gripper_lift_state_t;
00883   
00884   typedef enum {
00885     STG_GRIPPER_CMD_NOP = 0, // default state
00886     STG_GRIPPER_CMD_OPEN, 
00887     STG_GRIPPER_CMD_CLOSE,
00888     STG_GRIPPER_CMD_UP, 
00889     STG_GRIPPER_CMD_DOWN    
00890   } stg_gripper_cmd_type_t;
00891   
00894   typedef struct
00895   {
00896     stg_size_t paddle_size; 
00897 
00898     stg_gripper_paddle_state_t paddles; 
00899     stg_gripper_lift_state_t lift;
00900 
00901     double paddle_position; 
00902     double lift_position; 
00903 
00904     stg_meters_t inner_break_beam_inset; 
00905     stg_meters_t outer_break_beam_inset; 
00906     stg_bool_t paddles_stalled; // true iff some solid object stopped
00907                                 // the paddles closing or opening
00908     
00909     GSList *grip_stack;  
00910     int grip_stack_size; 
00911 
00912     double close_limit; 
00913 
00914   } stg_gripper_config_t;
00915 
00918   typedef struct
00919   {
00920     stg_gripper_cmd_type_t cmd;
00921     int arg;
00922   } stg_gripper_cmd_t;
00923 
00924 
00927   typedef struct
00928   {
00929     stg_gripper_paddle_state_t paddles; 
00930     stg_gripper_lift_state_t lift;
00931     
00932     double paddle_position; 
00933     double lift_position; 
00934 
00935     stg_bool_t inner_break_beam; 
00936     stg_bool_t outer_break_beam; 
00937     
00938     stg_bool_t paddle_contacts[2]; 
00939 
00940     stg_bool_t paddles_stalled; // true iff some solid object stopped
00941                                 // the paddles closing or opening
00942 
00943     int stack_count; 
00944 
00945 
00946   } stg_gripper_data_t;
00947 
00948 
00949   // FIDUCIAL MODEL --------------------------------------------------------
00950   
00953   typedef struct
00954   {
00955     stg_meters_t max_range_anon; //< maximum detection range
00956     stg_meters_t max_range_id; 
00957     stg_meters_t min_range; 
00958     stg_radians_t fov; 
00959     stg_radians_t heading; 
00960     
00963     char* key;
00964   } stg_fiducial_config_t;
00965   
00968   typedef struct
00969   {
00970     stg_meters_t range; 
00971     stg_radians_t bearing; 
00972     stg_pose_t geom; 
00973     int id; 
00974     
00975   } stg_fiducial_t;
00976 
00977   // RANGER MODEL --------------------------------------------------------
00978 
00979   typedef struct
00980   {
00981     stg_pose_t pose;
00982     stg_size_t size;
00983     stg_bounds_t bounds_range;
00984     stg_radians_t fov;
00985     int ray_count;
00986   } stg_ranger_config_t;
00987   
00988   typedef struct
00989   {
00990     stg_meters_t range;
00991     //double error; // TODO
00992   } stg_ranger_sample_t;
00993   
00994   // BUMPER MODEL --------------------------------------------------------
00995 
00996   typedef struct
00997   {
00998     stg_pose_t pose;
00999     stg_meters_t length;
01000   } stg_bumper_config_t;
01001   
01002   typedef struct
01003   {
01004     stg_model_t* hit;
01005     stg_point_t hit_point;
01006   } stg_bumper_sample_t;
01007   
01008   // POSITION MODEL --------------------------------------------------------
01009   
01010   typedef enum
01011     { STG_POSITION_CONTROL_VELOCITY, STG_POSITION_CONTROL_POSITION }
01012   stg_position_control_mode_t;
01013   
01014 #define STG_POSITION_CONTROL_DEFAULT STG_POSITION_CONTROL_VELOCITY
01015   
01016   typedef enum
01017     { STG_POSITION_LOCALIZATION_GPS, STG_POSITION_LOCALIZATION_ODOM }
01018   stg_position_localization_mode_t;
01019   
01020 #define STG_POSITION_LOCALIZATION_DEFAULT STG_POSITION_LOCALIZATION_GPS
01021   
01023   typedef enum
01024     { STG_POSITION_DRIVE_DIFFERENTIAL, STG_POSITION_DRIVE_OMNI, STG_POSITION_DRIVE_CAR }
01025   stg_position_drive_mode_t;
01026   
01027 #define STG_POSITION_DRIVE_DEFAULT STG_POSITION_DRIVE_DIFFERENTIAL
01028   
01030   typedef struct
01031   {
01032     stg_meters_t x,y,a;
01033     stg_position_control_mode_t mode;
01034   } stg_position_cmd_t;
01035   
01037   typedef struct
01038   {
01039     stg_pose_t pose; 
01040     stg_pose_t pose_error; 
01041     stg_pose_t origin; 
01042     stg_velocity_t velocity; 
01043     stg_velocity_t integration_error; 
01044     //stg_bool_t stall; ///< TRUE iff the robot can't move due to a collision
01045     stg_position_localization_mode_t localization; 
01046     stg_msec_t watchdog_timeout; 
01047   } stg_position_data_t;
01048   
01050   typedef struct
01051   {
01052     stg_position_drive_mode_t drive_mode;
01053     stg_position_localization_mode_t localization_mode;
01054   } stg_position_cfg_t;
01055 
01057   void stg_model_position_set_odom( stg_model_t* mod, stg_pose_t* odom ); 
01058 
01059   // WIFI MODEL --------------------------------------------------------
01060 
01063   typedef struct
01064   {
01065                 char essid[32];
01066                 char mac[32];
01067     char ip[32];
01068     double power;
01069     double sensitivity;
01070                 double freq;
01071     stg_meters_t range;
01072                 char model[32];
01073                 double plc; // distance power loss coefficient
01074                 double ple; // path loss distance exponent
01075                 double sigma; // standard derivation of gaussian random variable
01076                 double range_db; // setting the individual ranges to render in render_cfg 
01077                 double wall_factor;
01078   } stg_wifi_config_t;
01079 
01082   typedef struct
01083   {
01084     // this is how an entry in neighbours looks like
01085     stg_pose_t pose; // global pose of corresponding neighbour
01086                 char essid[32];
01087                 char mac[32];    
01088                 char ip[32]; // IP adress of corresponding card
01089                 double freq;
01090     double db; // signal-strength
01091                 
01092   } stg_wifi_sample_t;
01093 
01096   typedef struct
01097   {
01098     // Simulated wifi data goes here.  E.g., for each neighbor within
01099     // range, record the corresponding signal strength.
01100   GArray* neighbours;
01101   } stg_wifi_data_t;
01102 
01103   // SPEECH MODEL --------------------------------------------------------
01104 
01105 #define STG_SPEECH_MAX_STRING_LEN 256
01106 
01107   typedef enum {
01108     STG_SPEECH_CMD_NOP = 0, // default state
01109     STG_SPEECH_CMD_SAY
01110   } stg_speech_cmd_type_t;
01111 
01114   typedef struct
01115   {
01116     char string[STG_SPEECH_MAX_STRING_LEN];
01117   } stg_speech_config_t;
01118 
01121   typedef struct
01122   {
01123     char string[STG_SPEECH_MAX_STRING_LEN];
01124   } stg_speech_data_t;
01125 
01128   typedef struct
01129   {
01130     stg_speech_cmd_type_t cmd;
01131     char string[STG_SPEECH_MAX_STRING_LEN];
01132   } stg_speech_cmd_t;
01133 
01134   // AUDIO MODEL --------------------------------------------------------
01135 
01136 #define STG_AUDIO_MAX_STRING_LEN 256
01137 
01138   typedef enum {
01139     STG_AUDIO_CMD_NOP = 0, // default state
01140     STG_AUDIO_CMD_SAY
01141   } stg_audio_cmd_type_t;
01142 
01145   typedef struct
01146   {
01147     char string[STG_AUDIO_MAX_STRING_LEN];
01148     char say_string[STG_AUDIO_MAX_STRING_LEN];
01149     stg_msec_t say_period;
01150     stg_msec_t say_last_time;
01151   } stg_audio_config_t;
01152 
01155   typedef struct
01156   {
01157     char string[STG_AUDIO_MAX_STRING_LEN];
01158     char recv[STG_AUDIO_MAX_STRING_LEN];
01159     GList *audio_paths;
01160   } stg_audio_data_t;
01161 
01164   typedef struct
01165   {
01166     stg_audio_cmd_type_t cmd;
01167     char string[STG_AUDIO_MAX_STRING_LEN];
01168   } stg_audio_cmd_t;
01169 
01170   // end the group of all models
01175 // MACROS ------------------------------------------------------
01176 // Some useful macros
01177   
01188   stg_color_t stg_lookup_color(const char *name);
01189 
01192   void stg_pose_sum( stg_pose_t* result, stg_pose_t* p1, stg_pose_t* p2 );
01193 
01194   // PRETTY PRINTING -------------------------------------------------
01195   
01197   void stg_print_err( const char* err );
01199   void stg_print_geom( stg_geom_t* geom );
01201   void stg_print_pose( stg_pose_t* pose );
01203   void stg_print_velocity( stg_velocity_t* vel );
01205   void stg_print_gripper_config( stg_gripper_config_t* slc );
01207   void stg_print_laser_config( stg_laser_config_t* slc );
01208   
01209 
01210 
01226 #define PRECISION 100000.0
01227 
01229 #define EQ(A,B) ((lrint(A*PRECISION))==(lrint(B*PRECISION)))
01230 
01232 #define LT(A,B) ((lrint(A*PRECISION))<(lrint(B*PRECISION)))
01233 
01235 #define GT(A,B) ((lrint(A*PRECISION))>(lrint(B*PRECISION)))
01236 
01238 #define GTE(A,B) ((lrint(A*PRECISION))>=(lrint(B*PRECISION)))
01239 
01241 #define LTE(A,B) ((lrint(A*PRECISION))<=(lrint(B*PRECISION)))
01242 
01243 
01244 
01247 #ifndef TRUE
01248 #define TRUE 1
01249 #endif
01250 
01251 #ifndef FALSE
01252 #define FALSE 0
01253 #endif
01254 
01255 #define MILLION 1e6
01256 #define BILLION 1e9
01257 
01258 #ifndef M_PI
01259 #define M_PI 3.14159265358979323846
01260 #endif
01261 
01262 #ifndef TWOPI
01263 #define TWOPI (2.0*M_PI)
01264 #endif
01265   
01266 #ifndef RTOD
01267 
01268 #define RTOD(r) ((r) * 180.0 / M_PI)
01269 #endif
01270   
01271 #ifndef DTOR
01272 
01273 #define DTOR(d) ((d) * M_PI / 180.0)
01274 #endif
01275   
01276 #ifndef NORMALIZE
01277 
01278 #define NORMALIZE(z) atan2(sin(z), cos(z))
01279 #endif
01280 
01281 // end doc group libstage_utilities
01284 #ifdef __cplusplus
01285 }
01286 #endif 
01287 
01288 // end documentation group libstage
01291 #endif

Generated on Thu Dec 13 13:55:21 2007 for Stage by  doxygen 1.4.6