rand_world.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 #include <sstream>
00004 #include <ctime>
00005 #include <stdlib.h>
00006 #include <time.h>
00007 
00008 using namespace std;
00009 
00010 string world_head = 
00011 "include \"swarm.inc\"\n\
00012 include \"turtlebot_intruder.inc\"\n\
00013 \n\
00014 define floorplan model \n\
00015 (\n\
00016   # sombre, sensible, artistic\n\
00017   color \"gray30\"\n\
00018   \n\
00019   # most maps will need a bounding box \n\
00020   boundary 1\n\
00021   \n\
00022   gui_nose 0\n\
00023   gui_grid 0\n\
00024   gui_outline 0\n\
00025   gripper_return 0\n\
00026   fiducial_return 0\n\
00027   laser_return 1\n\
00028 )\n\
00029 \n\
00030 resolution 0.02\n\
00031 interval_sim 10  # simulation timestep in milliseconds\n\
00032 \n\
00033 window\n\
00034 (\n\
00035   size [ 600.0 700.0 ]\n\
00036   center [ 0.0 0.0 ]\n\
00037   rotate [ 0.0 0.0 ]\n\
00038   scale 60\n\
00039 )\n\
00040 \n\
00041 floorplan\n\
00042 (\n\
00043   name \"rand\"\n\
00044   bitmap \"../maps/rand.png\"\n\
00045   size [ 100.0 100.0 2.0 ]\n\
00046   pose [  50.0  50.0 0.0 0.0 ]\n\
00047   #size [ 40.0 40.0 2.0 ]\n\
00048   #pose [ 20.0 20.0 0.0 0.0]\n\
00049 )\n\
00050 \n\
00051 define block model\n\
00052 (\n\
00053 size [0.5 7 0.5]\n\
00054 gui_nose 1\n\
00055 )\n\
00056 \n";
00057 
00058 float random_float(float min, float max)
00059 {
00060     float tmp_rand = rand() / float(RAND_MAX);
00061     return min + max * tmp_rand;
00062 }
00063 
00064 int main()
00065 {
00066     srand(time(NULL));
00067     int num = 10;
00068     float min_pos = 0;
00069     float max_pos = 20;
00070     ofstream file;
00071         file.open("rand.world");
00072     stringstream ss;
00073     
00074     ss<<world_head;
00075     
00076     for(int i = 0; i < num; i++) {
00077         ss<<"swarm( pose ["<<random_float(min_pos+5, max_pos-5)<<" "<<random_float(min_pos+5, max_pos-5)<<" 0 0 ] name \"era"<<i<<"\" "<<"color \"red\")"<<endl;
00078     }
00079     file<<ss.str();
00080     
00081     return 0;
00082 }


micros_swarm_stage
Author(s):
autogenerated on Thu Jun 6 2019 18:52:29