fix map origin bug on mapping

This commit is contained in:
chengyangkj 2024-09-11 22:53:29 +08:00
parent f7dbf4fae4
commit ff69a69c6a
4 changed files with 7 additions and 13 deletions

View File

@ -34,6 +34,7 @@ class DisplayOccMap : public VirtualDisplay {
Eigen::Vector3f sub_map_center_pose_;
double sub_map_value_ = 1;
bool is_draw_line_ = false;
bool init_flag_{false};
QPointF line_start_pose_;
QImage line_tmp_image_; // 用于存储绘制线条的图像,以便在绘制完成后进行处理
private:

View File

@ -103,7 +103,6 @@ class DisplayManager : public QObject {
void SetFocusOn(const std::string &display_type) {
focus_display_ = display_type;
}
void FocusOnMapCenter();
};
} // namespace Display

View File

@ -70,13 +70,12 @@ void DisplayOccMap::ParseOccupyMap() {
color = Qt::black; // black
} else if (map_value == 0) {
color = Qt::white; // gray
} else if(map_value == 255){
} else if (map_value == 255) {
color = Qt::gray; // white
}else{
} else {
color = Qt::white;
}
map_image_.setPixel(i, j, color.rgb());
}
@ -85,7 +84,10 @@ void DisplayOccMap::ParseOccupyMap() {
//以0 0点为中心
double x, y;
map_data_.xy2ScenePose(0, 0, x, y);
CenterOnScene(mapToScene(x,y));
if (not init_flag_) {
CenterOnScene(mapToScene(x, y));
init_flag_ = true;
}
});
}
void DisplayOccMap::EraseMapRange(const QPointF &pose, double range) {

View File

@ -144,7 +144,6 @@ bool DisplayManager::UpdateDisplay(const std::string &display_type,
init_flag_ = true;
}
FocusOnMapCenter();
} else if (display_type == DISPLAY_ROBOT) {
//重定位时屏蔽位置更新
if (!is_reloc_mode_) {
@ -179,13 +178,6 @@ bool DisplayManager::UpdateDisplay(const std::string &display_type,
return true;
}
void DisplayManager::FocusOnMapCenter(){
QTimer::singleShot(1000,[this](){ //地图更新时聚焦在map 0,0 点
double x, y;
map_data_.xy2ScenePose(0, 0, x, y);
graphics_view_ptr_->centerOn(FactoryDisplay::Instance()->GetDisplay(DISPLAY_MAP)->mapToScene(x,y));});
}
/**
* @description: