voxel_map.h 1.3 KB
Newer Older
wangdawei's avatar
wangdawei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#pragma once

#include <Eigen/Core>
#include <Eigen/Geometry>
#include <boost/shared_ptr.hpp>

#include "voxel_map_define.h"

class StreamManager;

namespace juefx {

class VoxelMap {
public:
    VoxelMap();
    bool SetMapPath(std::string path_name);
    bool LoadMap();
    void loadArea(const Eigen::Vector3d pose);
    bool IsMapLoaded(const GnssPoint blh_pose);
    bool IsMapLoaded(const Eigen::Vector3d pose);
    bool GuessPosition(const GnssPoint &init_pose, Eigen::Isometry3d &pose_in_map);
    void ConfirmPosition(const Eigen::Vector3d &pose_in_map, GnssPoint &final_pose);

public:
    float GetResolution(uint8_t type) const;

    BlockGridIndex GetCellIndex(float x, float y) const;
    BlockGridIndex GetPymdCellIndex(float x, float y) const {
        return GetCellIndex(x, y);
    }

    Distribution* GetCellValue(uint8_t type, const BlockGridIndex &index, uint8_t &length) const;
    Distribution* GetPymdCellValue(uint8_t type, BlockGridIndex index, uint8_t &length) const
    {
        index.x.gridId &= mask[type];
        index.y.gridId &= mask[type];
        return GetCellValue(type, index, length);
    }

    Eigen::Vector2f GetCenterOfCell(uint8_t type, float x, float y) const;

    Eigen::Vector3f GetOffset() const;
private:
    const uint8_t mask[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0, 0, 0};
};

}