sim: camera ve bang GPU (lib tuy chon vslam_sim_gl, EGL + GLES3 + assimp) -- anh IR co texture that + depth khop tung pixel, vslam_node --sim-gl, tool vslam_render_preview

This commit is contained in:
trung09122002
2026-10-03 19:13:50 +07:00
parent 0dd2546ab1
commit f9fd18b5aa
17 changed files with 1329 additions and 22 deletions

View File

@@ -0,0 +1,69 @@
#ifndef VSLAM_SIM_GL_RENDERER_H
#define VSLAM_SIM_GL_RENDERER_H
// Ve anh camera mo phong bang GPU: EGL KHONG man hinh + OpenGL ES 3, mesh
// HIEN THI cua world voi texture THAT cua model (assimp: OBJ/MTL, COLLADA).
//
// ================== VI SAO CAN ==================
// Raycast CPU cua bo mo phong chi ra DEPTH, tren tuong ep tu luoi 2D: khong co
// anh, va hinh hoc chi la 2.5D. VO/VIO (F2M, DM-VIO) can ANH co van that de
// bam diem, va can depth KHOP voi anh do. Ve ca hai tu CUNG mot mesh trong
// MOT luot GPU thi chung khop tung pixel.
//
// ================== GIOI HAN (noi ro) ==================
// * Anh "IR" la do sang texture * chieu sang don gian (ambient + den chieu
// theo huong camera), emitter TAT: khong co cham laser, khong rolling
// shutter, khong nhoe chuyen dong, khong tu dong phoi sang. Anh sach hon
// camera that -- ket qua VO trong sim LAC QUAN.
// * Model khong co texture (tuong/san tu sinh) duoc phu mot texture anh
// that theo toa do the gioi (triplanar). Van that, nhung khong dung nghia.
// * Chi xet yaw cua model (giong bo doc world): do doc phai nam san trong
// dinh mesh.
//
// ⚠️ Context GPU tao LUOI o lan Render() dau tien, tren luong goi, va moi lan
// goi sau phai tren CUNG luong do (luong vong mo phong).
#include <memory>
#include <string>
#include "vslam/gazebo_world.h"
#include "vslam/sim_camera_renderer.h"
namespace vslam {
struct GlRendererConfig {
// Texture cho model KHONG co texture: dia hinh (`vslam_terrain_*`) va vat
// khac. Phu theo toa do THE GIOI (triplanar), moi lan lap `texture_tile_m`
// met. Rong = mau dac (khong co van -- VO se khong bam duoc).
std::string fallback_floor_texture;
std::string fallback_wall_texture;
double texture_tile_m = 2.0;
// Chieu sang anh IR: ambient + den chieu dat tai camera (emitter TAT).
double ambient = 0.55;
double headlight = 0.45;
// Cho phep renderer PHAN MEM (Mesa llvmpipe). Mac dinh tu choi: may co ca
// driver Mesa, va chon nham thiet bi la cham ~100 lan ma khong bao loi.
bool allow_software = false;
};
// Cau hinh mac dinh: texture cho model khong co texture lay tu bo model AWS
// tren may (~/gazebo_models/aws_hospital): san/doc = anh THAM that, vat khac =
// anh VAI rem that -- ca hai lap duoc, co van cho VO bam. Bien moi truong
// VSLAM_SIM_FLOOR_TEXTURE / VSLAM_SIM_WALL_TEXTURE ghi de (duong dan anh).
// Khong tim thay anh nao thi de rong (mau dac) va log canh bao.
GlRendererConfig DefaultGlRendererConfig();
// Nap mesh + texture cua `world` NGAY (CPU), dua len GPU o lan Render() dau.
// Tra nullptr va dien `error` neu khong nap duoc mesh nao.
std::shared_ptr<SimCameraRenderer> CreateGlCameraRenderer(const GazeboWorld& world,
const GlRendererConfig& cfg,
std::string* error);
// Hop bao he WORLD cua mesh HIEN THI cua mot model, doc bang assimp voi CUNG
// quy uoc nhu renderer (ti le `<scale>`, yaw, tinh tien). Cho bai kiem so voi
// bo doc world cua vslam_sim. false neu khong doc duoc.
bool AssimpModelBounds(const WorldModel& m, double mn[3], double mx[3]);
} // namespace vslam
#endif // VSLAM_SIM_GL_RENDERER_H