Revision 5847a728
Planning for current week
buggysim/src/sim_frame.cpp | ||
---|---|---|
45 | 45 |
|
46 | 46 |
TurtleFrame::TurtleFrame(QWidget* parent, Qt::WindowFlags f) |
47 | 47 |
: QFrame(parent, f) |
48 |
// TODO: reintegrate these into the initialization list |
|
49 |
//, map_image_(700, 500, QImage::Format_ARGB32) |
|
50 |
//, path_painter_(&map_image_) |
|
51 | 48 |
, frame_count_(0) |
52 | 49 |
, id_counter_(0) |
53 | 50 |
{ |
54 | 51 |
|
55 | 52 |
|
56 |
// TODO: figure out why 500,500 path_image is being sent in.
|
|
53 |
// Same as image size
|
|
57 | 54 |
setFixedSize(700, 500); |
58 | 55 |
setWindowTitle("BuggySim Frame!"); |
59 | 56 |
|
60 | 57 |
srand(time(NULL)); |
61 | 58 |
|
62 |
// QT updater
|
|
59 |
// QT window updater/timer
|
|
63 | 60 |
update_timer_ = new QTimer(this); |
64 | 61 |
update_timer_->setInterval(16); |
65 | 62 |
update_timer_->start(); |
... | ... | |
80 | 77 |
toBeRemovedMapName + "_walls.bmp").c_str(); |
81 | 78 |
wall_image_.load(wall_path_); |
82 | 79 |
|
83 |
/* BEGIN: Reinitialization */ |
|
84 |
//base_bitmap.load(map_base_path); |
|
85 |
//map_image_.load(map_path_); |
|
86 |
|
|
87 | 80 |
map_image_ = new QImage(700, 500, QImage::Format_ARGB32); |
88 | 81 |
|
89 |
//QPainter tempqp = QPainter(); |
|
90 |
//QPainter tempsq = QPainter tempsq(&map_image_); |
|
91 |
|
|
92 |
// =(QPaitner&) is private |
|
93 |
|
|
94 |
//path_painter_ = new QPainter(map_image_); |
|
95 |
//path_painter_ = new QPainter(); |
|
96 |
//path_painter_.begin(&map_image_); |
|
97 |
|
|
98 |
//wall_image_.load(wall_path_); |
|
99 |
/* END: Reinitialization */ |
|
100 |
|
|
101 |
|
|
102 | 82 |
// TODO: paint waypoints |
103 |
|
|
104 |
// TODO: load all turtles in directory |
|
105 |
/* Choose turtles */ |
|
106 |
// TODO: make it automatically pick up turtles? |
|
83 |
// TODO: load turtles automatically/change to buggy images |
|
84 |
|
|
85 |
/* Load turtle images */ |
|
107 | 86 |
// Note: buggies must be added here to be chosen. |
108 | 87 |
// TODO: associate buggy with specific model. |
109 | 88 |
QVector<QString> turtles; |
... | ... | |
113 | 92 |
//turtles.append("groovy.png"); |
114 | 93 |
//turtles.append("hydro.svg"); |
115 | 94 |
|
116 |
|
|
117 |
// Load turtles |
|
118 | 95 |
QString images_path = (ros::package::getPath("buggysim") + "/images/").c_str(); |
119 | 96 |
for (size_t i = 0; i < turtles.size(); ++i) { |
120 | 97 |
QImage img; |
... | ... | |
122 | 99 |
turtle_images_.append(img); |
123 | 100 |
} |
124 | 101 |
|
125 |
// TODO: redefine meter to pixel. or GPS coordinate, actually. |
|
126 |
// add sophistication to the maploading code. |
|
127 |
// 10 pixels to the meter. |
|
128 |
// TODO: move this up. |
|
102 |
// TODO: load meter/pixel ratio from parameter server |
|
129 | 103 |
meter_ = turtle_images_[0].height(); |
130 | 104 |
|
131 | 105 |
|
... | ... | |
143 | 117 |
height_in_meters_ = (height() - 1) / meter_; |
144 | 118 |
|
145 | 119 |
// Spawn turtle in a specific location. |
146 |
//spawnTurtle("", width_in_meters_ / 2.0, height_in_meters_ / 2.0, 0); |
|
147 | 120 |
spawnTurtle("", width_in_meters_ / 2.0, height_in_meters_ / 2.0, 0); |
148 | 121 |
|
149 | 122 |
ROS_INFO("Past constructor!\n"); |
... | ... | |
152 | 125 |
TurtleFrame::~TurtleFrame() |
153 | 126 |
{ |
154 | 127 |
delete update_timer_; |
155 |
//delete path_painter_; |
|
156 | 128 |
} |
157 | 129 |
|
158 | 130 |
bool TurtleFrame::spawnCallback(buggysim::Spawn::Request& req, |
... | ... | |
189 | 161 |
return turtles_.find(name) != turtles_.end(); |
190 | 162 |
} |
191 | 163 |
|
192 |
std::string TurtleFrame::spawnTurtle(const std::string& name, float x, float y, |
|
164 |
std::string TurtleFrame::spawnTurtle(const std::string& name, |
|
165 |
float x, |
|
166 |
float y, |
|
193 | 167 |
float angle) |
194 | 168 |
{ |
195 | 169 |
std::string real_name = name; |
... | ... | |
233 | 207 |
nh_.param("background_g", g, g); |
234 | 208 |
nh_.param("background_b", b, b); |
235 | 209 |
// TODO: reload the map image |
236 |
//path_image_.fill(qRgb(r, g, b)); |
|
237 | 210 |
//map_image_.fill(qRgb(r, g, b)); |
238 | 211 |
map_image_->load(map_path_); |
239 | 212 |
update(); |
... | ... | |
314 | 287 |
int a = 1/0; |
315 | 288 |
return true; |
316 | 289 |
} |
317 |
|
|
318 | 290 |
} |
Also available in: Unified diff