Files
vslam_cpp/libs/vslam_sim/include/vslam/occupancy_map_io.h
trung09122002 48bd5377dc upload
2026-09-18 18:14:42 +07:00

50 lines
1.5 KiB
C++

#ifndef VSLAM_OCCUPANCY_MAP_IO_H
#define VSLAM_OCCUPANCY_MAP_IO_H
// Doc/ghi occupancy grid dang PGM + YAML -- dung dinh dang cua map_server ROS.
//
// Giu dinh dang cu co y: nguoi dung da quen no, `rtabmap-export` sinh ra no,
// va moi map cu trong vSLAM_ws/maps/ deu o dang nay. Bo ROS khong co nghia la
// phai bo moi thu ROS cham vao.
//
// map.yaml:
// image: map.pgm
// resolution: 0.05
// origin: [-5.0, -13.0, 0.0]
// negate: 0
// occupied_thresh: 0.65
// free_thresh: 0.196
//
// PGM P5 (nhi phan, 8 bit): 0 = den = bi chiem, 255 = trang = trong.
// Quy uoc nay NGUOC voi truc quan, va dao nguoc no la mot trong nhung loi
// hay gap nhat khi doc map -- ket qua la robot coi tuong la duong di.
#include <string>
#include "vslam/vslam_common.h"
namespace vslam {
struct MapLoadResult {
OccupancyGrid grid;
std::string image_path;
double occupied_thresh = 0.65;
double free_thresh = 0.196;
};
// Doc map.yaml va file PGM di kem. Duong dan anh trong YAML duoc hieu la
// tuong doi so voi thu muc chua YAML.
StatusResponse LoadOccupancyMap(const std::string& yaml_path, MapLoadResult* out);
// Ghi ra PGM + YAML. Dung cho tools/vslam_map_export.
StatusResponse SaveOccupancyMap(const OccupancyGrid& grid,
const std::string& yaml_path);
// Sinh mot the gioi tong hop: hanh lang chinh + phong hai ben.
// Dung khi chua co map that, de chay thu duong ong ngay lap tuc.
OccupancyGrid MakeSyntheticWorld(uint32_t width, uint32_t height, float resolution);
} // namespace vslam
#endif // VSLAM_OCCUPANCY_MAP_IO_H