需要:
软件平台:
硬件平台:
(以下任选其一)
- Slamware SDP mini
- Slamware SDP
- Slamware 套装 (基于Slamware导航方案的用户机器人系统)
- Zeus/Apollo等底盘系统
编译运行:
- 打开samples工程
- 右键composite_map_demo, 打开属性选项,将Slamware SDK 的include目录和lib目录添加到工程
- 右键composite_map_demo, 将此工程设置成StartUp project
- 右键composite_map_demo, 打开properties选项,设置Command Arguments
composite_map_demo [OPTS] [filename] <SDP IP Address>
SDP IP Address The ip address string of the SLAMWARE SDP
getstcm filename download compositeMap
If not specified, the default name map.stms will be used
setstcm filename upload compositeMap
-h Show this message 点击F5运行
- 从slamware里面读取composite map(此操作会在桌面上生成一个test.stcm的地图文件,并在console中输出地图数据信息):
可以用Robostudio的地图编辑器来查看生成的地图:
- 将本地的composite map上传至slamware
可以先在Robostudio里面查看将要上传的地图:
将此底图上传至slamware:
可以在Robostudio中连上机器人,可以看到地图已经上传成功
描述:
代码功能说明:从slamware模块下载composite map到客户端, 从客户端上传composite map至slamware模块,从composite map中读取虚拟轨道,虚拟墙等信息。
Code Block |
---|
language | cpp |
---|
firstline | 1 |
---|
title | 获取composite map |
---|
linenumbers | true |
---|
|
bool StcmMapWriter(const std::string file_name, SlamwareCorePlatform platform) {
CompositeMap composite_map = platform.getCompositeMap();
CompositeMapWriter composite_map_writer;
std::string error_message;
bool result = composite_map_writer.saveFile(error_message, file_name, composite_map);
return result;
} |
Code Block |
---|
language | cpp |
---|
firstline | 1 |
---|
title | 设置composite map |
---|
linenumbers | true |
---|
|
bool StcmMapReader(const std::string file_path, rpos::core::Pose pose, SlamwareCorePlatform platform) {
CompositeMapReader composite_map_reader;
std::string error_message;
boost::shared_ptr<CompositeMap> composite_map(composite_map_reader.loadFile(error_message, file_path));
if (composite_map) {
platform.setCompositeMap((*composite_map), pose);
return true;
}
return false;
} |
Code Block |
---|
language | cpp |
---|
firstline | 1 |
---|
title | 读取map layer信息 |
---|
linenumbers | true |
---|
|
CompositeMapReader composite_map_reader;
std::string error_message;
boost::shared_ptr<CompositeMap> composite_map(composite_map_reader.loadFile(error_message, file_path));
if (composite_map) {
for (auto it = composite_map->maps().begin(); it != composite_map->maps().end(); ++it) {
auto layer = *it;
std::string usage = layer->getUsage();
std::string type = layer->getType();
std::cout << "Layer Usage : " << usage << std::endl;
//get grid map layer
if (type == GridMapLayer::Type) {
auto grid_map = boost::dynamic_pointer_cast<GridMapLayer>(layer);
std::cout << "Map Position : (" << grid_map->getOrigin().x() << " , " <<
grid_map->getOrigin().y() << ")" <<std::endl;
std::cout << "Map Resolution : (" << grid_map->getResolution().x() <<
" , " << grid_map->getResolution().y() << ")" <<std::endl;
std::cout << "Map Dimension: (" << grid_map->getDimension().x() <<
" , " << grid_map->getDimension().y() << ")" <<std::endl;
std::cout << "Map Data:" << std::endl;
for (auto it = grid_map->mapData().begin(); it != grid_map->mapData().end(); ++it) {
std::cout << (int)*it << " " ;
}
std::cout << std::endl << std::endl;
}
//get line map layer
else if (type == LineMapLayer::Type) {
auto line_map = boost::dynamic_pointer_cast<LineMapLayer>(layer);
for (auto it = line_map->lines().begin(); it != line_map->lines().end(); ++it) {
auto line = it->second;
std::cout << "start: (" << line.start.x() << " , " << line.start.y() << ")" << std::endl;
std::cout << "end: (" << line.end.x() << " , " << line.end.y() << ")" << std::endl;
}
std::cout << std::endl;
}
//get pose map layer
else if (type == PoseMapLayer::Type) {
auto pose_map = boost::dynamic_pointer_cast<PoseMapLayer>(layer);
for (auto it = pose_map->poses().begin(); it != pose_map->poses().end(); ++it) {
auto pos = it->second;
std::cout << "Position : (" << pos.pose.x() << " , " << pos.pose.y() << ")" << std::endl;
}
std::cout << std::endl;
}
else if (type == PointsMapLayer::Type) {
//TODO: get Points map layer
std::cout << std::endl;
}
else {
//TODO: get unknown map layer
std::cout << std::endl;
}
} |