Detour-API
Detour
Detour使用HTTP方法提供API。以下为主要API的清单:
里程计暂停运行
Path:{ip}:4321/pause
Method: GET
接口描述:
请求(案例):http://127.0.0.1:4321/pause
返回(案例):
{"success":true,"id":0}
里程计恢复运行
Path:{ip}:4321/resume
Method: GET
接口描述:
请求(案例):http://127.0.0.1:4321/resume
返回(案例):
{"success":true,"id":0}
执行Detour内部命令
Path:{ip}:4321/call
Method: GET
接口描述:
参数:cmd,指令。类似于odometry_0.pause()。[主语].([参数列表...])
请求(案例):http://127.0.0.1:4321/call?cmd=odometry_0.pause() 这表示调用odometry_0的pause方法(暂停指定里程计)。具体各个组件有哪些方法参考《Detour组件参考手册》
返回(案例):
{"result":"void"}
获取当前车体在世界坐标系下的位姿
Path:{ip}:4321/getPos
Method: GET
接口描述:
请求:http://127.0.0.1:4321/getPos
返回(案例):
byte[] 下载成文件保存到本地
切换是否进行地图匹配
Path:{ip}:4321/switchPosMatch
Method: GET
接口描述:
参数:
disabled:bool,是否关闭地图匹配
name:string,指定地图名称。不指定该参数则对所有图层生
请求(案例):http://127.0.0.1:4321/switchPosMatch
返回(案例):
{"performed":true}
使远端算法核将某指定图层当前的建图结果保存至文件
Path:{ip}:4321/setLocation
Method: GET
接口描述:
参数:
x:float,x 坐标值
y:float,y 坐标值
th:float:角度值
请求:http://127.0.0.1:4321/setLocation?x=1&y=2&th=3
返回(案例):
{"x":1.0,"y":2.0,"th":3.0,"l_step":9999,"tick":63832366282729,"error":"Timeout"}
获取程序运行状态,包括里程计状态、地图状态等
Path:{ip}:4321/getStat
Method: GET
接口描述:
请求:http://127.0.0.1:4321/getStat
返回(案例):
{"layoutStat":{"w1":{},"w2":{},"frontlidar":{}},"odoStat":{},"posStat":{},"TCStat":{"fitmethod":0,"fitsource":"/","poseEstim":"/","TCVar":0.0},"GOStat":{"maxTension":0.0,"edgeN":0},"licence":"DID:40B38B8C111BD4EC","globalStat":{"paused":false,"IsSettingPosition":false}}
设置激光雷达的无效范围,在一系列点构成的闭包范围内的激光点将被忽略,这些点的坐标为车体坐标系下的值
Path:{ip}:4321/setLidar2DOdometryMask
Method: GET
接口描述:
参数:
odometry:string,所设置的里程计名称字符串:一串 XY 坐标点构成的 json 字符串
请求(案例):
http://127.0.0.1:4321/setLidar2DOdometryMask?odometry=odometry_1&[{"X":123,"Y":456},{"X":123,"Y":456},{"X":123,"Y":456}]返回(案例):
设置成功:{success: true}
设置失败:{error=”No odometry named {指定里程计名称}”}
将程序设置为debug模式运行,将输出debug日志文件
Path:{ip}:4321/debug
Method: GET
接口描述:
请求:http://127.0.0.1:4321/debug
返回(案例):
{"success":true"}
获取程序的配置参数
Path:{ip}:4321/getConf
Method: GET
接口描述:
请求:http://127.0.0.1:4321/getConf
返回(案例):
{"license":"","initX":0.0,"initY":0.0,"initTh":0.0,"recordLastPos":false,"layout":{"chassis":{"width":1200.0,"length":2000.0,"contour":[-445.0,330.0,445.0,330.0,445.0,-330.0,-445.0,-330.0]},"components":[{"type":"wheel,component,haveposition","options":{"platform":0,"scale":1.0,"radius":200.0,"id":1,"name":"w1","noMove":false,"time_bias_ms":0,"x":0.0,"y":300.0,"th":0.0,"z":0.0,"alt":0.0,"roll":0.0}},{"type":"wheel,component,haveposition","options":{"platform":6,"scale":1.0,"radius":200.0,"id":2,"name":"w2","noMove":false,"time_bias_ms":0,"x":0.0,"y":-300.0,"th":0.0,"z":0.0,"alt":0.0,"roll":0.0}},{"type":"lidar2d,component,haveposition","options":{"derr":20.0,"kerr":0.0,"isCircle":false,"angleSgn":1.0,"endAngle":0.0,"rangeStartAngle":-180.0,"rangeEndAngle":180.0,"afterImageFilterOutN":7,"afterImageFilterOutDeg":2.0,"ignoreDist":100.0,"maxDist":200000.0,"correctionType":"angle","dazzleWindow":5,"dazzleDist":80,"useNormalization":true,"useGridSelection":true,"gridSelSz":20.0,"useChassisFilter":true,"maxpoint":640,"useBilateralFilter":true,"useReflex":false,"removeReflex":false,"removeReflexDist":300.0,"minpointsN":20.0,"reflexThres":0.4,"reflexDiffThres":0.3,"reflexChunkThres":2.5,"reflexMutePadding":7,"reflexSize":100,"reflexDistRange":150.0,"invalidAngArrLen":128,"stepDebug":false,"id":1101520006,"name":"frontlidar","noMove":false,"time_bias_ms":0,"x":350.0,"y":0.0,"th":0.0,"z":0.0,"alt":0.0,"roll":0.0}}]},"odometries":[],"positioning":[],"autoStart":false,"debug":true,"useGPU":true,"TCtimeWndSz":150,"TCtimeWndLimit":700,"useTC":false,"guru":{"SpatialIndex2StageCache":4194304,"SpatialIndex1StageCache":1048576,"ICPFastIterFac":0.8,"ICPUseFastMode":false,"ICP2DMaxIter":16,"RippleEnableEqualize":true,"Lidar2dMapMaxIter":50,"TCAddIterations":50,"phaseLockLvl":3,"rotMapProjectionLength":500.0,"gicp_p2pfac":0.02,"extractPlaneThresE":700.0,"lo3dlineWeightScale":0.3,"inputScale":1.0,"Lidar2DRippleDistDecay":15000.0,"Lidar2DRippleScale":1.0,"SI2DRectSmall":130,"SI2DRectBig":600,"TCVarMax":1600.0,"TCMaxBadEdges":3,"TCKalmanUseCurrentFac":0.2,"debugReg2D":true,"ICP2ddebugSource":-1,"ICP2dReflexWeight":3.0,"ICP2dReflexWeightTranslateFac":3.0,"TCInterconnectType":0,"TCAutoCaliberation":false,"dumpCriticalData":true},"recordPosInterval":500,"preventErrorLocation":true,"minimized":false}
进行一次全局匹配
Path:{ip}:4321/relocalize
Method: GET
接口描述:
请求:http://127.0.0.1:4321/relocalize
返回(案例):
{performed: true}
使远端算法核加载远端已保存的某个地图
Path:{ip}:4321/loadMap
Method: GET
接口描述:
参数:
name:string,指定的图层名称,默认为 mainmap
fn:string,指定加载的地图文件名称,默认为 mainmap.2dlm
请求:http://127.0.0.1:4321/loadMap?name=mainmap&fn= mainmap.2dlm
返回(案例):
{performed: true}
使远端算法核将某指定图层当前的建图结果保存至文件
Path:{ip}:4321/saveMap
Method: GET
接口描述:
参数:
name:string,指定的图层名称,默认为 mainmap
fn:string,指定加载的地图文件名称,默认为 mainmap.2dlm
请求:http://127.0.0.1:4321/saveMap?name=mainmap&fn= mainmap.2dlm
返回(案例):
{performed: true}
以PNG格式返回激光地图
Path:{ip}:4321/getMapPng?width=800&height=600¢erX=0¢erY=0&scale=0.01
Method: GET
接口描述:
参数:
width:int,PNG宽度
height:int,PNG高度
centerX & centerY:int,地图中心坐标
scale:float,地图缩放比例
请求:http://127.0.0.1:4321/getMapPng?width=800&height=600¢erX=0¢erY=0&scale=0.01
返回(案例):PNG字节流