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.179 2006/02/28 05:11:57 rtv Exp $ 00033 */ 00034 00035 00043 #include "config.h" // results of autoconf's system configuration tests 00044 #include "replace.h" // Stage's implementations of missing system calls 00045 00046 #include <stdlib.h> 00047 #include <stdio.h> 00048 #include <sys/socket.h> 00049 #include <netdb.h> 00050 #include <string.h> 00051 #include <unistd.h> 00052 #include <stdint.h> // for portable int types eg. uint32_t 00053 #include <sys/types.h> 00054 #include <sys/time.h> 00055 #include <assert.h> 00056 #include <pthread.h> 00057 #include <semaphore.h> 00058 00059 #include <glib.h> // we use GLib's data structures extensively 00060 #include <rtk.h> // and graphics stuff pulled from Andrew Howard's RTK2 library 00061 00062 #ifdef __cplusplus 00063 extern "C" { 00064 #endif 00065 00104 #define FiducialNone 0 00105 00106 #define STG_TOKEN_MAX 64 00107 00116 typedef int stg_id_t; 00117 00119 typedef double stg_meters_t; 00120 00122 typedef double stg_radians_t; 00123 00125 typedef unsigned long stg_msec_t; 00126 00128 typedef double stg_kg_t; // Kilograms (mass) 00129 00131 typedef double stg_joules_t; 00132 00134 typedef double stg_watts_t; 00135 00137 typedef int stg_bool_t; 00138 00139 //typedef double stg_friction_t; 00140 00142 typedef uint32_t stg_color_t; 00143 00146 //typedef int stg_obstacle_return_t; 00147 00150 //typedef int stg_blob_return_t; 00151 00153 //typedef int stg_fiducial_return_t; 00154 00155 //typedef int stg_ranger_return_t; 00156 00157 //typedef enum { STG_GRIP_NO = 0, STG_GRIP_YES } stg_gripper_return_t; 00158 00161 typedef struct 00162 { 00163 stg_meters_t x, y; 00164 } stg_size_t; 00165 00169 typedef struct 00170 { 00171 stg_meters_t x, y, a; 00172 } stg_pose_t; 00173 00176 typedef stg_pose_t stg_velocity_t; 00177 00181 typedef struct 00182 { 00183 stg_pose_t pose; 00184 stg_size_t size; 00185 } stg_geom_t; 00186 00188 typedef struct 00189 { 00190 double min; //< smallest value in range 00191 double max; //< largest value in range 00192 } stg_bounds_t; 00193 00195 typedef struct 00196 { 00197 stg_bounds_t range; //< min and max range of sensor 00198 stg_radians_t angle; //< width of viewing angle of sensor 00199 } stg_fov_t; 00200 00202 typedef struct 00203 { 00204 stg_radians_t pan; 00205 stg_radians_t tilt; 00206 stg_radians_t zoom; 00207 } stg_ptz_t; 00208 // end types 00210 00211 00212 // GUIFEATURES ------------------------------------------------------- 00213 00214 00215 // forward declare struct types from player_internal.h 00216 struct _stg_model; 00217 struct _stg_matrix; 00218 struct _gui_window; 00219 struct _stg_world; 00220 00221 typedef struct _stg_model stg_model_t; // defined in stage_internal. 00222 typedef struct _stg_world stg_world_t; 00223 00224 00225 00228 stg_msec_t stg_timenow( void ); 00229 00235 int stg_init( int argc, char** argv ); 00236 00237 00239 int stg_quit_test( void ); 00240 00243 void stg_quit_request( void ); 00244 00245 00249 const char* stg_version_string( void ); 00250 00251 00252 // POINTS --------------------------------------------------------- 00260 typedef struct 00261 { 00262 stg_meters_t x, y; 00263 } stg_point_t; 00264 00267 stg_point_t* stg_points_create( size_t count ); 00268 00270 void stg_points_destroy( stg_point_t* pts ); 00271 00274 // POLYLINES --------------------------------------------------------- 00275 00283 typedef struct 00284 { 00285 stg_point_t* points; 00286 size_t points_count; 00287 } stg_polyline_t; 00288 00291 // POLYGONS --------------------------------------------------------- 00292 00301 typedef struct 00302 { 00304 GArray* points; 00305 00307 stg_bool_t unfilled; 00308 00310 stg_color_t color; 00311 00313 stg_size_t bbox; 00314 00315 void* _data; // temporary internal use only 00316 } stg_polygon_t; 00317 00318 00320 stg_polygon_t* stg_polygons_create( int count ); 00321 00323 void stg_polygons_destroy( stg_polygon_t* p, size_t count ); 00324 00326 stg_polygon_t* stg_unit_polygon_create( void ); 00327 00331 void stg_polygon_set_points( stg_polygon_t* poly, stg_point_t* pts, size_t count ); 00334 void stg_polygon_append_points( stg_polygon_t* poly, stg_point_t* pts, size_t count ); 00335 00338 void stg_polygons_normalize( stg_polygon_t* polys, int num, 00339 double width, double height ); 00340 00342 void stg_polygon_print( stg_polygon_t* poly ); 00343 00345 void stg_polygons_print( stg_polygon_t* polys, unsigned int count ); 00346 00351 stg_polygon_t* stg_polygons_from_image_file( const char* filename, 00352 size_t* poly_count ); 00353 00356 // end property typedefs ------------------------------------------------- 00357 00358 00359 // WORLD -------------------------------------------------------- 00360 00379 stg_world_t* stg_world_create( stg_id_t id, 00380 const char* token, 00381 int sim_interval, 00382 int real_interval, 00383 double ppm, 00384 double width, 00385 double height ); 00386 00390 stg_world_t* stg_world_create_from_file( const char* worldfile_path ); 00391 00394 void stg_world_destroy( stg_world_t* world ); 00395 00398 void stg_world_stop( stg_world_t* world ); 00399 00402 void stg_world_start( stg_world_t* world ); 00403 00410 int stg_world_update( stg_world_t* world, int sleepflag ); 00411 00413 void stg_world_load( stg_world_t* mod ); 00414 00416 void stg_world_save( stg_world_t* mod ); 00417 00420 void stg_world_print( stg_world_t* world ); 00421 00424 void stg_world_set_interval_real( stg_world_t* world, unsigned int val ); 00425 00429 void stg_world_set_interval_sim( stg_world_t* world, unsigned int val ); 00430 00433 stg_model_t* stg_world_get_model( stg_world_t* world, stg_id_t mid ); 00434 00436 stg_model_t* stg_world_model_name_lookup( stg_world_t* world, const char* name ); 00437 00440 // MODEL -------------------------------------------------------- 00441 00442 // group the docs of all the model types 00449 // Movement masks for figures 00450 #define STG_MOVE_TRANS (1 << 0) 00451 #define STG_MOVE_ROT (1 << 1) 00452 #define STG_MOVE_SCALE (1 << 2) 00453 00454 typedef int stg_movemask_t; 00455 00466 typedef int (*stg_model_callback_t)(stg_model_t* mod, void* user ); 00467 00468 void stg_model_add_callback( stg_model_t* mod, 00469 void* member, 00470 stg_model_callback_t cb, 00471 void* user ); 00472 00473 int stg_model_remove_callback( stg_model_t* mod, 00474 void* member, 00475 stg_model_callback_t callback ); 00476 00477 00484 typedef int(*stg_model_initializer_t)(stg_model_t*); 00485 00486 00487 00489 typedef enum 00490 { 00491 LaserTransparent, 00492 LaserVisible, 00493 LaserBright 00494 } stg_laser_return_t; 00495 00497 stg_model_t* stg_model_create( stg_world_t* world, 00498 stg_model_t* parent, 00499 stg_id_t id, 00500 char* typestr ); 00501 00503 void stg_model_destroy( stg_model_t* mod ); 00504 00506 void stg_model_get_global_pose( stg_model_t* mod, stg_pose_t* pose ); 00507 00509 void stg_model_get_global_velocity( stg_model_t* mod, stg_velocity_t* gvel ); 00510 00511 /* set the velocity of a model in the global coordinate system */ 00512 void stg_model_set_global_velocity( stg_model_t* mod, stg_velocity_t* gvel ); 00513 00515 void stg_model_subscribe( stg_model_t* mod ); 00516 00518 void stg_model_unsubscribe( stg_model_t* mod ); 00519 00521 void stg_model_load( stg_model_t* mod ); 00522 00524 void stg_model_save( stg_model_t* mod ); 00525 00527 //const char* stg_model_type_string( stg_model_type_t type ); 00528 00529 // SET properties - use these to set props, don't set them directly 00530 00532 void stg_model_set_global_pose( stg_model_t* mod, stg_pose_t* gpose ); 00533 00535 void stg_model_set_velocity( stg_model_t* mod, stg_velocity_t* vel ); 00536 00538 void stg_model_set_pose( stg_model_t* mod, stg_pose_t* pose ); 00539 00541 void stg_model_set_geom( stg_model_t* mod, stg_geom_t* src ); 00542 00544 void stg_model_set_fiducial_return( stg_model_t* mod, int fid ); 00545 00547 int stg_model_set_parent( stg_model_t* mod, stg_model_t* newparent); 00548 00551 void stg_model_get_geom( stg_model_t* mod, stg_geom_t* dest ); 00552 00554 void stg_model_get_pose( stg_model_t* mod, stg_pose_t* dest ); 00555 00557 void stg_model_get_velocity( stg_model_t* mod, stg_velocity_t* dest ); 00558 00561 stg_polygon_t* stg_model_get_polygons( stg_model_t* mod, size_t* poly_count ); 00562 void stg_model_set_polygons( stg_model_t* mod, 00563 stg_polygon_t* polys, 00564 size_t poly_count ); 00565 00567 void stg_model_set_lines( stg_model_t* mod, 00568 stg_polyline_t* lines, 00569 size_t lines_count ); 00570 00571 // guess what these do? 00572 void stg_model_get_velocity( stg_model_t* mod, stg_velocity_t* dest ); 00573 void stg_model_set_velocity( stg_model_t* mod, stg_velocity_t* vel ); 00574 void stg_model_set_pose( stg_model_t* mod, stg_pose_t* pose ); 00575 void stg_model_get_geom( stg_model_t* mod, stg_geom_t* dest ); 00576 void stg_model_set_geom( stg_model_t* mod, stg_geom_t* geom ); 00577 void stg_model_set_color( stg_model_t* mod, stg_color_t col ); 00578 void stg_model_set_mass( stg_model_t* mod, stg_kg_t mass ); 00579 void stg_model_set_stall( stg_model_t* mod, stg_bool_t stall ); 00580 void stg_model_set_gripper_return( stg_model_t* mod, int val ); 00581 void stg_model_set_fiducial_return( stg_model_t* mod, int val ); 00582 void stg_model_set_laser_return( stg_model_t* mod, int val ); 00583 void stg_model_set_obstacle_return( stg_model_t* mod, int val ); 00584 void stg_model_set_blob_return( stg_model_t* mod, int val ); 00585 void stg_model_set_ranger_return( stg_model_t* mod, int val ); 00586 void stg_model_set_boundary( stg_model_t* mod, int val ); 00587 void stg_model_set_gui_nose( stg_model_t* mod, int val ); 00588 void stg_model_set_gui_mask( stg_model_t* mod, int val ); 00589 void stg_model_set_gui_grid( stg_model_t* mod, int val ); 00590 void stg_model_set_gui_outline( stg_model_t* mod, int val ); 00591 void stg_model_set_watts( stg_model_t* mod, stg_watts_t watts ); 00592 void stg_model_set_map_resolution( stg_model_t* mod, stg_meters_t res ); 00593 00594 00598 void stg_model_print( stg_model_t* mod, char* prefix ); 00599 00602 int stg_model_is_antecedent( stg_model_t* mod, stg_model_t* testmod ); 00603 00606 int stg_model_is_descendent( stg_model_t* mod, stg_model_t* testmod ); 00607 00611 int stg_model_is_related( stg_model_t* mod1, stg_model_t* mod2 ); 00612 00614 stg_model_t* stg_model_root( stg_model_t* mod ); 00615 00617 GPtrArray* stg_model_array_from_tree( stg_model_t* root ); 00618 00620 int stg_model_startup( stg_model_t* mod ); 00621 00623 int stg_model_shutdown( stg_model_t* mod ); 00624 00627 int stg_model_update( stg_model_t* model ); 00628 00632 void stg_model_global_to_local( stg_model_t* mod, stg_pose_t* pose ); 00633 00637 void stg_model_local_to_global( stg_model_t* mod, stg_pose_t* pose ); 00638 00639 int stg_model_fig_clear_cb( stg_model_t* mod, void* data, size_t len, 00640 void* userp ); 00641 00642 void stg_model_set_data( stg_model_t* mod, void* data, size_t len ); 00643 void stg_model_set_cmd( stg_model_t* mod, void* cmd, size_t len ); 00644 void stg_model_set_cfg( stg_model_t* mod, void* cfg, size_t len ); 00645 void* stg_model_get_cfg( stg_model_t* mod, size_t* lenp ); 00646 void* stg_model_get_data( stg_model_t* mod, size_t* lenp ); 00647 void* stg_model_get_cmd( stg_model_t* mod, size_t* lenp ); 00648 00649 00653 void stg_model_add_property_toggles( stg_model_t* mod, 00654 void* member, 00655 stg_model_callback_t callback_on, 00656 void* arg_on, 00657 stg_model_callback_t callback_off, 00658 void* arg_off, 00659 const char* name, 00660 const char* label, 00661 gboolean enabled ); 00662 00663 00664 // BLOBFINDER MODEL -------------------------------------------------------- 00665 00666 #define STG_BLOB_CHANNELS_MAX 16 00667 00670 typedef struct 00671 { 00672 int channel_count; // 0 to STG_BLOBFINDER_CHANNELS_MAX 00673 stg_color_t channels[STG_BLOB_CHANNELS_MAX]; 00674 int scan_width; 00675 int scan_height; 00676 stg_meters_t range_max; 00677 } stg_blobfinder_config_t; 00678 00681 typedef struct 00682 { 00683 int channel; 00684 stg_color_t color; 00685 int xpos, ypos; // all values are in pixels 00686 //int width, height; 00687 int left, top, right, bottom; 00688 int area; 00689 stg_meters_t range; 00690 } stg_blobfinder_blob_t; 00691 00692 00693 // ENERGY model -------------------------------------------------------------- 00694 00696 typedef struct 00697 { 00699 stg_joules_t stored; 00700 00702 stg_bool_t charging; 00703 00705 stg_meters_t range; 00706 00708 GPtrArray* connections; 00709 } stg_energy_data_t; 00710 00712 typedef struct 00713 { 00715 stg_joules_t capacity; 00716 00718 stg_watts_t give_rate; 00719 00721 stg_watts_t take_rate; 00722 00724 stg_meters_t probe_range; 00725 00727 stg_bool_t give; 00728 00729 } stg_energy_config_t; 00730 00731 // there is currently no energy command packet 00732 00733 // BLINKENLIGHT ------------------------------------------------------- 00734 00735 //typedef struct 00736 //{ 00737 //int enable; 00738 //stg_msec_t period; 00739 //} stg_blinkenlight_t; 00740 00741 // PTZ MODEL -------------------------------------------------------- 00742 00745 typedef stg_ptz_t stg_ptz_cmd_t; 00746 00749 typedef stg_ptz_t stg_ptz_data_t; 00750 00753 typedef struct 00754 { 00755 stg_ptz_t min; 00756 stg_ptz_t max; 00757 stg_ptz_t goal; 00758 stg_ptz_t speed; 00759 } stg_ptz_config_t; 00760 00761 00762 // LASER MODEL -------------------------------------------------------- 00763 00766 typedef struct 00767 { 00768 uint32_t range; 00769 char reflectance; 00770 } stg_laser_sample_t; 00771 00774 typedef struct 00775 { 00776 stg_radians_t fov; 00777 stg_meters_t range_max; 00778 stg_meters_t range_min; 00779 00782 int samples; 00783 } stg_laser_config_t; 00784 00785 // GRIPPER MODEL -------------------------------------------------------- 00786 00787 typedef enum { 00788 STG_GRIPPER_PADDLE_OPEN = 0, // default state 00789 STG_GRIPPER_PADDLE_CLOSED, 00790 STG_GRIPPER_PADDLE_OPENING, 00791 STG_GRIPPER_PADDLE_CLOSING, 00792 } stg_gripper_paddle_state_t; 00793 00794 typedef enum { 00795 STG_GRIPPER_LIFT_DOWN = 0, // default state 00796 STG_GRIPPER_LIFT_UP, 00797 STG_GRIPPER_LIFT_UPPING, // verbed these to match the paddle state 00798 STG_GRIPPER_LIFT_DOWNING, 00799 } stg_gripper_lift_state_t; 00800 00801 typedef enum { 00802 STG_GRIPPER_CMD_NOP = 0, // default state 00803 STG_GRIPPER_CMD_OPEN, 00804 STG_GRIPPER_CMD_CLOSE, 00805 STG_GRIPPER_CMD_UP, 00806 STG_GRIPPER_CMD_DOWN 00807 } stg_gripper_cmd_type_t; 00808 00811 typedef struct 00812 { 00813 stg_size_t paddle_size; 00814 00815 stg_gripper_paddle_state_t paddles; 00816 stg_gripper_lift_state_t lift; 00817 00818 double paddle_position; 00819 double lift_position; 00820 00821 stg_meters_t inner_break_beam_inset; 00822 stg_meters_t outer_break_beam_inset; 00823 stg_bool_t paddles_stalled; // true iff some solid object stopped 00824 // the paddles closing or opening 00825 00826 GSList *grip_stack; 00827 int grip_stack_size; 00828 00829 double close_limit; 00830 00831 } stg_gripper_config_t; 00832 00835 typedef struct 00836 { 00837 stg_gripper_cmd_type_t cmd; 00838 int arg; 00839 } stg_gripper_cmd_t; 00840 00841 00844 typedef struct 00845 { 00846 stg_gripper_paddle_state_t paddles; 00847 stg_gripper_lift_state_t lift; 00848 00849 double paddle_position; 00850 double lift_position; 00851 00852 stg_bool_t inner_break_beam; 00853 stg_bool_t outer_break_beam; 00854 00855 stg_bool_t paddle_contacts[2]; 00856 00857 stg_bool_t paddles_stalled; // true iff some solid object stopped 00858 // the paddles closing or opening 00859 00860 int stack_count; 00861 00862 00863 } stg_gripper_data_t; 00864 00865 00866 // FIDUCIAL MODEL -------------------------------------------------------- 00867 00870 typedef struct 00871 { 00872 stg_meters_t max_range_anon; 00873 stg_meters_t max_range_id; 00874 stg_meters_t min_range; 00875 stg_radians_t fov; // field of view 00876 stg_radians_t heading; // center of field of view 00877 00878 } stg_fiducial_config_t; 00879 00882 typedef struct 00883 { 00884 stg_meters_t range; // range to the target 00885 stg_radians_t bearing; // bearing to the target 00886 stg_pose_t geom; // size and relative angle of the target 00887 int id; // the identifier of the target, or -1 if none can be detected. 00888 00889 } stg_fiducial_t; 00890 00891 // RANGER MODEL -------------------------------------------------------- 00892 00893 typedef struct 00894 { 00895 stg_pose_t pose; 00896 stg_size_t size; 00897 stg_bounds_t bounds_range; 00898 stg_radians_t fov; 00899 } stg_ranger_config_t; 00900 00901 typedef struct 00902 { 00903 stg_meters_t range; 00904 //double error; // TODO 00905 } stg_ranger_sample_t; 00906 00907 00908 // POSITION MODEL -------------------------------------------------------- 00909 00910 typedef enum 00911 { STG_POSITION_CONTROL_VELOCITY, STG_POSITION_CONTROL_POSITION } 00912 stg_position_control_mode_t; 00913 00914 #define STG_POSITION_CONTROL_DEFAULT STG_POSITION_CONTROL_VELOCITY 00915 00916 typedef enum 00917 { STG_POSITION_LOCALIZATION_GPS, STG_POSITION_LOCALIZATION_ODOM } 00918 stg_position_localization_mode_t; 00919 00920 #define STG_POSITION_LOCALIZATION_DEFAULT STG_POSITION_LOCALIZATION_GPS 00921 00923 typedef enum 00924 { STG_POSITION_DRIVE_DIFFERENTIAL, STG_POSITION_DRIVE_OMNI, STG_POSITION_DRIVE_CAR } 00925 stg_position_drive_mode_t; 00926 00927 #define STG_POSITION_DRIVE_DEFAULT STG_POSITION_DRIVE_DIFFERENTIAL 00928 00930 typedef struct 00931 { 00932 stg_meters_t x,y,a; 00933 stg_position_control_mode_t mode; 00934 } stg_position_cmd_t; 00935 00937 typedef struct 00938 { 00939 stg_pose_t pose; 00940 stg_pose_t pose_error; 00941 stg_pose_t origin; 00942 stg_velocity_t velocity; 00943 stg_velocity_t integration_error; 00944 //stg_bool_t stall; ///< TRUE iff the robot can't move due to a collision 00945 stg_position_localization_mode_t localization; 00946 } stg_position_data_t; 00947 00949 typedef struct 00950 { 00951 stg_position_drive_mode_t drive_mode; 00952 stg_position_localization_mode_t localization_mode; 00953 } stg_position_cfg_t; 00954 00956 void stg_model_position_set_odom( stg_model_t* mod, stg_pose_t* odom ); 00957 00958 // end the group of all models 00963 // MACROS ------------------------------------------------------ 00964 // Some useful macros 00965 00976 stg_color_t stg_lookup_color(const char *name); 00977 00980 void stg_pose_sum( stg_pose_t* result, stg_pose_t* p1, stg_pose_t* p2 ); 00981 00982 // PRETTY PRINTING ------------------------------------------------- 00983 00985 void stg_print_err( const char* err ); 00987 void stg_print_geom( stg_geom_t* geom ); 00989 void stg_print_pose( stg_pose_t* pose ); 00991 void stg_print_velocity( stg_velocity_t* vel ); 00993 void stg_print_gripper_config( stg_gripper_config_t* slc ); 00995 void stg_print_laser_config( stg_laser_config_t* slc ); 00996 00997 00998 00999 // Error macros - output goes to stderr 01000 #define PRINT_ERR(m) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", __FILE__, __FUNCTION__) 01001 #define PRINT_ERR1(m,a) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 01002 #define PRINT_ERR2(m,a,b) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 01003 #define PRINT_ERR3(m,a,b,c) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 01004 #define PRINT_ERR4(m,a,b,c,d) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 01005 #define PRINT_ERR5(m,a,b,c,d,e) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, d, e, __FILE__, __FUNCTION__) 01006 01007 // Warning macros 01008 #define PRINT_WARN(m) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", __FILE__, __FUNCTION__) 01009 #define PRINT_WARN1(m,a) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 01010 #define PRINT_WARN2(m,a,b) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 01011 #define PRINT_WARN3(m,a,b,c) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 01012 #define PRINT_WARN4(m,a,b,c,d) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 01013 #define PRINT_WARN5(m,a,b,c,d,e) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, d, e, __FILE__, __FUNCTION__) 01014 01015 // Message macros 01016 #ifdef DEBUG 01017 #define PRINT_MSG(m) printf( "Stage: "m" (%s %s)\n", __FILE__, __FUNCTION__) 01018 #define PRINT_MSG1(m,a) printf( "Stage: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 01019 #define PRINT_MSG2(m,a,b) printf( "Stage: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 01020 #define PRINT_MSG3(m,a,b,c) printf( "Stage: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 01021 #define PRINT_MSG4(m,a,b,c,d) printf( "Stage: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 01022 #define PRINT_MSG5(m,a,b,c,d,e) printf( "Stage: "m" (%s %s)\n", a, b, c, d, e,__FILE__, __FUNCTION__) 01023 #else 01024 #define PRINT_MSG(m) printf( "Stage: "m"\n" ) 01025 #define PRINT_MSG1(m,a) printf( "Stage: "m"\n", a) 01026 #define PRINT_MSG2(m,a,b) printf( "Stage: "m"\n,", a, b ) 01027 #define PRINT_MSG3(m,a,b,c) printf( "Stage: "m"\n", a, b, c ) 01028 #define PRINT_MSG4(m,a,b,c,d) printf( "Stage: "m"\n", a, b, c, d ) 01029 #define PRINT_MSG5(m,a,b,c,d,e) printf( "Stage: "m"\n", a, b, c, d, e ) 01030 #endif 01031 01032 // DEBUG macros 01033 #ifdef DEBUG 01034 #define PRINT_DEBUG(m) printf( "debug: "m" (%s %s)\n", __FILE__, __FUNCTION__) 01035 #define PRINT_DEBUG1(m,a) printf( "debug: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 01036 #define PRINT_DEBUG2(m,a,b) printf( "debug: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 01037 #define PRINT_DEBUG3(m,a,b,c) printf( "debug: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 01038 #define PRINT_DEBUG4(m,a,b,c,d) printf( "debug: "m" (%s %s)\n", a, b, c ,d, __FILE__, __FUNCTION__) 01039 #define PRINT_DEBUG5(m,a,b,c,d,e) printf( "debug: "m" (%s %s)\n", a, b, c ,d, e, __FILE__, __FUNCTION__) 01040 #else 01041 #define PRINT_DEBUG(m) 01042 #define PRINT_DEBUG1(m,a) 01043 #define PRINT_DEBUG2(m,a,b) 01044 #define PRINT_DEBUG3(m,a,b,c) 01045 #define PRINT_DEBUG4(m,a,b,c,d) 01046 #define PRINT_DEBUG5(m,a,b,c,d,e) 01047 #endif 01048 01049 01065 #define PRECISION 100000.0 01066 01068 #define EQ(A,B) ((lrint(A*PRECISION))==(lrint(B*PRECISION))) 01069 01071 #define LT(A,B) ((lrint(A*PRECISION))<(lrint(B*PRECISION))) 01072 01074 #define GT(A,B) ((lrint(A*PRECISION))>(lrint(B*PRECISION))) 01075 01077 #define GTE(A,B) ((lrint(A*PRECISION))>=(lrint(B*PRECISION))) 01078 01080 #define LTE(A,B) ((lrint(A*PRECISION))<=(lrint(B*PRECISION))) 01081 01082 01083 01086 #ifndef TRUE 01087 #define TRUE 1 01088 #endif 01089 01090 #ifndef FALSE 01091 #define FALSE 0 01092 #endif 01093 01094 #define MILLION 1e6 01095 #define BILLION 1e9 01096 01097 #ifndef M_PI 01098 #define M_PI 3.14159265358979323846 01099 #endif 01100 01101 #ifndef TWOPI 01102 #define TWOPI (2.0*M_PI) 01103 #endif 01104 01105 #ifndef RTOD 01106 01107 #define RTOD(r) ((r) * 180.0 / M_PI) 01108 #endif 01109 01110 #ifndef DTOR 01111 01112 #define DTOR(d) ((d) * M_PI / 180.0) 01113 #endif 01114 01115 #ifndef NORMALIZE 01116 01117 #define NORMALIZE(z) atan2(sin(z), cos(z)) 01118 #endif 01119 01120 // end doc group libstage_utilities 01123 #ifdef __cplusplus 01124 } 01125 #endif 01126 01127 // end documentation group libstage 01130 #endif
Generated on Mon Feb 27 23:30:51 2006 for Stage by
