地图格式

注 1: 地图中的坐标点的单位均为米,最多会保留三位小数,即精确到 0.001 米

注 2: 地图的坐标系即为世界坐标系

地图的 protobuf 格式

Protobuf3 请参阅 Google

syntax = "proto3";
package rbk.protocol;
import "google/protobuf/wrappers.proto";

message Message_MapProperty {
    string key = 1;  // 属性名
     string type = 2; // 属性值的类型, 这里 type 一定是 string, bool, int32, uint32, int64, uint64, float, double, bytes 中的一个
    bytes value = 3; // 属性值 (for backward compatibility)
    oneof oneof_value { // 属性值
        string string_value = 4;
        bool bool_value = 5;
        int32 int32_value = 6;
        uint32 uint32_value = 7;
        int64 int64_value = 8;
        uint64 uint64_value = 9;
        float float_value = 10;
        double double_value = 11;
        bytes bytes_value = 12;
    }
}

// 普通点
message Message_MapPos {
    double x = 1;
    double y = 2;
}

// 普通线
message Message_MapLine {
    Message_MapPos start_pos = 1; // 线的起始点
    Message_MapPos end_pos = 2;   // 线的终止点
}

// 地图元数据
message Message_MapHeader {
    string map_type = 1;    //type of map: 2D-map or 3D-map
    string map_name = 2;    //name of map: the map file name
    Message_MapPos min_pos = 3; // 地图中 x,y 最小值, 该点不一定存在, 只是指示包含增长地图的矩形的左下点
    Message_MapPos max_pos = 4; // 地图中 x,y 最大值, 该点不一定存在, 只是指示包含增长地图的矩形的右上点
    double resolution = 5; // 分辨率 (m)
    string version = 8; // 地图的格式的版本号
}

// 特征, 用户不必关注该条目
message Message_MapAttribute {
    string description = 1; // description of the this class
    uint32 color_pen = 2;
    uint32 color_brush = 3;
    uint32 color_font = 4;
}

// 高级点
message Message_AdvancedPoint {
    string class_name = 1;      // 高级点的类型, 目前只有 LandMark(普通站点), ChargePoint(充电点), ReturnPoint(返航点), GyroCaliPoint(陀螺仪标定点), RobotHome(出生点)
    string instance_name = 2; // 唯一标识名
    Message_MapPos pos = 3;   // 点坐标
    double dir = 4;           // 方向
    repeated Message_MapProperty property = 5; // 高级点的属性
    bool ignore_dir = 6;  // 是否忽略朝向
    bytes desc = 8;
    Message_MapAttribute attribute = 10; // 特征
}

// 高级线
message Message_AdvancedLine {
    string class_name = 1;    // 高级线的类型, 目前只有 ForbiddenLine, NormalLine, VirtualLine
    string instance_name = 2; // 唯一标识名
    Message_MapLine line = 3; // 线坐标
    repeated Message_MapProperty property = 4; // 高级线的属性
    bytes desc = 8;
    Message_MapAttribute attribute = 10; // 特征
}

// 高级曲线(用于连接两个高级点), 目前只有 BezierPath(三阶贝塞尔曲线) 一种
message Message_AdvancedCurve {
    string class_name = 1;   // 高级曲线的类型, 目前只有 BezierPath(贝塞尔曲线) 一种
    string instance_name = 2;  // 唯一标识名
    Message_AdvancedPoint start_pos = 3; // 曲线起始点(是某个高级点,一定是地图中出现过的某个高级点)
    Message_AdvancedPoint end_pos = 4;   // 曲线终止点(是某个高级点,一定是地图中出现过的某个高级点)
    Message_MapPos control_pos1 = 5;     // 曲线控制点1
    Message_MapPos control_pos2 = 6;     // 曲线控制点2
    repeated Message_MapProperty property = 7; // 高级曲线的属性
    bytes desc = 8;
    repeated Message_Device devices = 12;   // 设备模型相关信息
    Message_MapAttribute attribute = 15; // 特征
}

// 高级区域
message Message_AdvancedArea {
    string class_name = 1;    // 高级曲线的类型,
    string instance_name = 2; // 唯一标识名
    repeated Message_MapPos pos_group = 3; // 区域边界线
    double dir = 4; // 方向
    repeated Message_MapProperty property = 5; // 高级区域的属性
    bytes desc = 8;
    repeated Message_Device devices = 10;  // 设备模型相关信息
    Message_MapAttribute attribute = 15; // 特征
}

// 激光设备, 用户不必关注
message Message_LaserDevice {
    uint32 id = 1;
    repeated Message_MapPos laser_margin_pos = 2;
}

// 设备模型信息, 用户不必关注
message Message_Device {
    string model_name = 1;
    repeated Message_LaserDevice laser_devices = 5;
    repeated double ultrasonic_dist = 6; // dist = -1 means not used
    repeated double fallingdown_dist = 7; // dist = -1 means not used
}

// 巡检站点
message Message_PatrolRouteStation {
    string id = 1; // 站点 ID
}

// 巡检线路
message Message_PatrolRoute {
    string name = 1; // 线路名称
    repeated Message_PatrolRouteStation station_list = 2; // 线路上的站点列表
    google.protobuf.DoubleValue max_speed = 4;   // 巡检线路上的最大速度, 若缺省则使用地图中的设置
    google.protobuf.DoubleValue max_acc = 5;     // 巡检线路上的最大加速度, 若缺省则使用地图中的设置
    google.protobuf.DoubleValue max_rot = 6;     // 巡检线路上的最大角速度, 若缺省则使用地图中的设置
    google.protobuf.DoubleValue max_rot_acc = 7; // 巡检线路上的最大角加速度, 若缺省则使用地图中的设置
    bytes desc = 8;
}

// 地图
message Message_Map {
    string map_directory = 1;
    Message_MapHeader header = 2; // 元数据
    repeated Message_MapPos normal_pos_list = 3; // 普通点数组
    repeated Message_MapLine normal_line_list = 4; // 普通线数组
    repeated Message_AdvancedPoint advanced_point_list = 6; // 高级点数组
    repeated Message_AdvancedLine  advanced_line_list = 7;  // 高级线数组
    repeated Message_AdvancedCurve advanced_curve_list = 8; // 高级曲线数组
    repeated Message_AdvancedArea  advanced_area_list = 9;  // 高级区域数组
    repeated Message_PatrolRoute patrol_route_list = 10;    // 巡检线路数组
}

地图的 JSON 格式

地图的 JSON 格式是从 protobuf 格式转换而来, JSON 和 protobuf 格式可以相互转换, 转换按照 protobuf3 的规则

首先是对地图中会出现的一些类型的说明:

注: 注释中 [] 表示这个 key 一定存在,() 小括号表示可缺省

MapProperty 属性:

属性都是跟软件GUI或者算法相关的,用户不必理会

{
    "key": "spin",   // [string]
    "type": "int32",   // [string]
    "value": "MQ==",  // [string] 这里的值需要将类型转换为 string, 再进行 base64 编码, 如 int32 = 1, 转换为 string 是 "1", 进行 base64 编码后为 "MQ=="
    "int32Value": 1  // 该字段会根据 type 变化, 可能为 stringValue, boolValue, int32Value, uint32Value, int64Value, uint64Value, floatValue, doubleValue, bytesValue
}

MapPos 普通点:

{
    "x": 10.111,  // [double] 世界坐标系中 x 坐标
    "y": 2.222,   // [double] 世界坐标系中 y 坐标
}

MapLine 普通线段:

{
    "startPos": {      // [MapPos], 是该线段的起始点,类型也就是一个 MapPos
        "x": 1.123,
        "y": 2.123
    },
    "endPos": {        // [MapPos], 是该线段的终止点,类型也就是一个 MapPos
        "x": 3.321,
        "y": 5.123
    }
}

MapHeader 地图头部:

{
    "mapType": "2D-map",      // [string] 2D-map or 3D-map,目前只会是 2D-map
    "mapName": "seer.map",    // [string] 地图的名字
     "minPos": {              // [MapPos] 地图中可以囊括整个地图的左上点(不一定实际存在这个点),类型也就是一个 MapPos
         "x": -43.812,
         "y": -70.232
     },
     "maxPos": {              // [MapPos] 地图中可以囊括整个地图的右下点(不一定实际存在这个点),类型也就是一个 MapPos
         "x": 166.321,
         "y": 86.600
    },
    "resolution": 0.02,        // [double] 分辨率(m)
    "version": "1.0.0"
}

AdvancedPoint 高级点:

{
    "className": "LandMark",           // [string] 高级点类型, 目前只有 LandMark(普通站点), ChargePoint(充电点), ReturnPoint(返航点), GyroCaliPoint(陀螺仪标定点), RobotHome(出生点)
    "instanceName": "0",               // [string] 高级点唯一标识名
    "pos": {"x": 18.420, "y": 9.270},  // [MapPos]
    "dir": 0.894,                      // (double) 方向
    "property": [{                     // (MapProperty[]) 属性数组
         "key": "spin",
         "type": "int32",
         "value": "MQ==",
         "int32Value": 1
    }]
}

AdvancedLine 高级线:

{
    "className": "ForbiddenLine",      // [string] 高级线类型, 目前只有 ForbiddenLine, NormalLine, VirtualLine
    "instanceName": "2",               // [string] 高级线唯一标识名
    "line": {                          // [MapLine]
        "startPos": {"x": 50.970,"y": 28.460},
        "endPos": {"x": 74.690, "y": 28.460}
    },
    "property": [{                     // (MapProperty[]) 属性数组
        "key": "spin",
        "type": "int32",
        "value": "MQ==",
        "int32Value": 1
    }]
}

AdvancedCurve 高级曲线:

{
    "className": "BezierPath",         // [string] 高级曲线类型
    "instanceName": "3",               // (string) 曲线唯一标识名
    "startPos": {                      // [AdvancedPoint] 贝塞尔曲线起始点,一定是地图中出现过的某个高级点
        "className": "LandMark",
        "instanceName": "10",
        "pos": {"x": 22.415, "y": 38.104}
    },
    "endPos": {                        // [AdvancedPoint] 贝塞尔曲线终止点曲线起始点,一定是地图中出现过的某个高级点
        "className": "LandMark",
        "instanceName": "2",
        "pos": {"x": 22.297, "y": 14.284}
    },
    "controlPos1": {"x": 22.009, "y": 28.664},  // [MapPos] 贝塞尔曲线控制点1
    "controlPos2": {"x": 22.369, "y": 20.501},  // [MapPos] 贝塞尔曲线控制点2
    "property": [],                             // (MapProperty[]) 属性数组
    "devices": []                               // (Message_Device[]) 设备模型相关
}

AdvancedArea 高级区域:

{
    "className":"AdvancedArea",   // [string] 高级曲线类型, 目前都为 AdvanceArea
    "instanceName":"1", // [string] 区域唯一标识名
    "posGroup":[        // [MapPos[]] 区域顶点,首尾相连
        {"x":1.889,"y":2.250},
        {"x":2.380,"y":2.250},
        {"x":2.380,"y":1.751},
        {"x":1.889,"y":1.751}],
    "property":[], // (MapProperty[]) 属性数组
    "devices": []  // (Message_Device[]) 设备模型相关
}

巡检站点:

{
    "id": "LM1"
}

巡检线路:

{
    "name": "route1",
    "stationList": [
        {
            "id": "LM1"
        },
        {
            "id": "LM2"
        }
    ]
}

Map 地图:

实际的地图对象,以上只是地图中会用到的对象的说明

{
    "mapDirectory": "",  // (string) 地图路径, 目前不用
    "header": {          // [MapHeader] 地图头部
        "mapType": "2D-map",
        "mapName": "test",
        "minPos": {"x": -43.800, "y": -70.200},
        "maxPos": {"x": 166.000, "y": 86.600},
        "resolution": 0.02,
        "version": "1.0.0"
    },
    "normalPosList": [   // (MapPos[]) 普通点数组
       {"x": -43.800, "y": -20.800},
       {"x": -43.600, "y": -20.600},
       {"x": -43.400, "y": -20.600}
    ],
    "normalLineList": [  // (MapLine[]) 普通线数组
       {
           "startPos": {"x": 59.280, "y": -24.420},
           "endPos": {"x": 63.270, "y": -22.280}
       },
       {
           "startPos": {"x": 116.540, "y": -52.120},
           "endPos": {"x": 145.040, "y": -51.880}
       }
    ],
    "advancedPointList":[             // (AdvancedPoint[]) 高级点数组
        {"className": "LandMark", "instanceName": "LM0", "pos": {"x": 18.420, "y": 9.270}},
        {"className": "RobotHome", "instanceName": "LM1", "pos":{"x": 21.930, "y": 29.520}},
        {"className": "LandMark", "instanceName": "LM2", "pos":{"x":22.415,"y":38.103},
         "property": [{"key": "spin", "type": "int32", "value": "MQ==", "int32Value": 1},
                      {"key": "tshaped", "type": "int32", "value": "MQ==", "int32Value": 1}]},
        {"className": "LandMark", "instanceName": "LM3", "pos":{"x":22.297,"y":14.284},
         "property": [{"key": "spin", "type": "int32", "value": "MQ==", "int32Value": 1},
                      {"key": "tshaped", "type": "int32", "value": "MQ==", "int32Value": 1}]},
       {"className": "LandMark", "instanceName": "LM4", "pos":{"x":36.825,"y":-8.824},
        "property": [{"key": "spin", "type": "int32", "value": "MQ==", "int32Value": 1},
                     {"key": "tshaped", "type": "int32", "value": "MQ==", "int32Value": 1}]}
   ],
    "advancedLineList": [             // (AdvancedLine[]) 高级线数组
        {"className": "ForbiddenLine", "instanceName":"1",
         "line": {"startPos": {"x": 50.970,"y": 28.460}, "endPos": {"x": 74.690, "y": 28.460}}},
       {"className": "ForbiddenLine", "instanceName":"2",
        "line": {"startPos": {"x": -18.460,"y": 14.010}, "endPos": {"x": 3.280, "y": 14.010}}},
       {"className": "VirtualLine", "instanceName":"3",
        "line": {"startPos": {"x": 45.600,"y": -2.580}, "endPos": {"x": 111.700, "y": -2.580}}},
       {"className": "VirtualLine", "instanceName":"4",
        "line": {"startPos":{"x":4597,"y":-1440}, "endPos": {"x": 10725, "y": -1440}}}
   ],
    "advancedCurveList": [            // (AdvancedCurve[]) 高级曲线数组
       {"className": "BezierPath", // 连接上面高级点数组中 instanceName 为 0 和 1 的曲线
        "startPos": {"className": "LandMark", "instanceName": "LM0", "pos": {"x": 18.420, "y": 9.270}},
        "endPos": {"className": "LandMark", "instanceName": "LM1", "pos": {"x": 21.930, "y": 29.520}},
        "controlPos1": {"x": 22.009, "y": 28.664},
        "controlPos2": {"x": 22.369, "y": 20.501},
        "property": [],
        "devices": []},
       {"className": "BezierPath", // 连接上面高级点数组中 instanceName 为 1 和 2 的曲线
        "startPos": {"className": "LandMark", "instanceName": "LM1", "pos": {"x": 21.930, "y": 29.520}},
       "endPos": {"className": "LandMark", "instanceName": "LM2", "pos": {"x": 22.415, "y": 38.103}},
        "controlPos1": {"x": -32.702, "y": 6.313},
        "controlPos2": {"x": -32.702, "y": 6.313},
        "property": [],
        "devices": []}
    ],
    "advancedAreaList": [             // (AdvancedArea[]) 高级区域数组
        {"className":"AdvancedArea",
        "instanceName":"1",
        "posGroup":[
            {"x":1.889,"y":2.250},
            {"x":2.380,"y":2.250},
            {"x":2.380,"y":1.751},
            {"x":1.889,"y":1.751}],
        "property":[
            {"key":"ultrasonic","type":"bool","value":"ZmFsc2U=", "boolValue":false},  // 超声是否打开,不存在此字段时默认打开
            {"key":"fallingdown","type":"bool","value":"ZmFsc2U=", "boolValue":false}] // 防跌落是否打开,不存在此字段时默认打开
        }
    ],
    "patrolRouteList": [
        {"name": "route1",
         "stationList": [
             {
                 "id": "LM1"
             },
             {
                 "id": "LM2"
             }]
        }
    ]
}

注: 以上地图只是示例, 并不是一张可以使用的地图。

注: 高级点 (AdvancedPoint) 的点即为导航点,用户只需关心各种高级点以及连接它们的 BezierPath (AdvancedCurve) 即可。

results matching ""

    No results matching ""