Main Page
Files
File List
File Members
src
rand_world.cpp
Go to the documentation of this file.
1
#include <iostream>
2
#include <fstream>
3
#include <sstream>
4
#include <ctime>
5
#include <stdlib.h>
6
#include <
time.h
>
7
8
using namespace
std
;
9
10
string
world_head
=
11
"include \"swarm.inc\"\n\
12
include \"turtlebot_intruder.inc\"\n\
13
\n\
14
define floorplan model \n\
15
(\n\
16
# sombre, sensible, artistic\n\
17
color \"gray30\"\n\
18
\n\
19
# most maps will need a bounding box \n\
20
boundary 1\n\
21
\n\
22
gui_nose 0\n\
23
gui_grid 0\n\
24
gui_outline 0\n\
25
gripper_return 0\n\
26
fiducial_return 0\n\
27
laser_return 1\n\
28
)\n\
29
\n\
30
resolution 0.02\n\
31
interval_sim 10 # simulation timestep in milliseconds\n\
32
\n\
33
window\n\
34
(\n\
35
size [ 600.0 700.0 ]\n\
36
center [ 0.0 0.0 ]\n\
37
rotate [ 0.0 0.0 ]\n\
38
scale 60\n\
39
)\n\
40
\n\
41
floorplan\n\
42
(\n\
43
name \"rand\"\n\
44
bitmap \"../maps/rand.png\"\n\
45
size [ 100.0 100.0 2.0 ]\n\
46
pose [ 50.0 50.0 0.0 0.0 ]\n\
47
#size [ 40.0 40.0 2.0 ]\n\
48
#pose [ 20.0 20.0 0.0 0.0]\n\
49
)\n\
50
\n\
51
define block model\n\
52
(\n\
53
size [0.5 7 0.5]\n\
54
gui_nose 1\n\
55
)\n\
56
\n"
;
57
58
float
random_float
(
float
min,
float
max)
59
{
60
float
tmp_rand = rand() / float(RAND_MAX);
61
return
min + max * tmp_rand;
62
}
63
64
int
main
()
65
{
66
srand(time(NULL));
67
int
num = 10;
68
float
min_pos = 0;
69
float
max_pos = 20;
70
ofstream file;
71
file.open(
"rand.world"
);
72
stringstream ss;
73
74
ss<<
world_head
;
75
76
for
(
int
i = 0; i < num; i++) {
77
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;
78
}
79
file<<ss.str();
80
81
return
0;
82
}
time.h
world_head
string world_head
Definition:
rand_world.cpp:10
random_float
float random_float(float min, float max)
Definition:
rand_world.cpp:58
std
main
int main()
Definition:
rand_world.cpp:64
micros_swarm_stage
Author(s):
autogenerated on Mon Jun 10 2019 14:02:20