Excerpt |
---|
This document introduces the demo project of "artifacts_demo", explaining user operation of Virtual Wall/Virtual Track, including how to add/delete/modify artifacts. |
Content
Table of Contents |
---|
IDE Preparation
Software
- Visual Studio 2010 SP1
- Slamware Windows SDK:Slamware Windows SDK
- RoboStudio(for map display):Robostudio installer
Sample Code:
Info Higher version of Visual Studio will cause errors. sometime you will need to upgrade SP1 package to make your VS compatable with .Net Framework.
Hardware
(Either one of following)
- Slamware SDP mini
- Slamware SDP
- Slamware Kit
- Zeus/Apollo robot base
Download
Compiling
- Right click on "artifacts_demo" project, set as StartUp project.
Right click on "artifacts_demo", then " Properties",configure "include" and "lib" directories to the corresponding folder path of Slamware SDK.
Info It's not necessary to copy files to the project directory, user will only need to configure the folder path of SDK.
- Right click on "artifacts_demo", then "properties",set "Command Arguments" as follows:
Syntax :artifacts_demo <IP address> - Click " F5" to execute.
- In robostudio, the output will be as follows:
Multimedia date //Virtual Track Operation( Add, Delete, Modify) name bandicam 2017-12-13 18-21-31-346.mp4 - The output from console will be as follows:
- Delete one of the virtual tracks by selecting one of the IDs. the ID selected in the video is 3.
Code
- Delete all virtual tracks/walls.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
SlamwareCorePlatform sdp = SlamwareCorePlatform::connect(argv[1], 1445); std::cout << "Clearing existing tracks and walls..." << std::endl; sdp.clearLines(ArtifactUsageVirtualTrack); sdp.clearLines(ArtifactUsageVirtualWall); |
- add Add virtual walls
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
std::cout << "Adding virtual walls..." << std::endl; std::vector<Line> walls; //add a 8 * 8 virtual wall square walls.push_back(Line(Point(-4, -4), Point(-4, 4))); walls.push_back(Line(Point(-4, 4), Point(4, 4))); walls.push_back(Line(Point(4, 4), Point(4, -4))); walls.push_back(Line(Point(4, -4), Point(-4, -4))); sdp.addLines(ArtifactUsageVirtualWall, walls); |
- add Add virtual tracks
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
std::cout << "Adding virtual tracks..." << std::endl; std::vector<Line> tracks; //add a 2 * 2 virtual track square tracks.push_back(Line(Point(-1, -1), Point(-1, 1))); tracks.push_back(Line(Point(-1, 1), Point(1, 1))); tracks.push_back(Line(Point(1, 1), Point(1, -1))); tracks.push_back(Line(Point(1, -1), Point(-1, -1))); sdp.addLines(ArtifactUsageVirtualTrack, tracks); |
- modify Modify a virtual wall ( similar with virtual wall modification)
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
std::cout << "Moving vitual walls..." << std::endl; //sleep 5 seconds for displaying purpose only, not necessary boost::this_thread::sleep_for(boost::chrono::milliseconds(5000)); std::vector<Line> get_walls = sdp.getLines(ArtifactUsageVirtualWall); //shrink virtual wall square from 8 * 8 to 6 *6 for (std::vector<Line>::iterator it = get_walls.begin() ; it != get_walls.end(); ++it) { it->startP().x() *= 0.75f; it->startP().y() *= 0.75f; } sdp.moveLines(ArtifactUsageVirtualWall, get_walls); |
- Delete virtual tracks( similar with virtual wall deletion)
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
std::cout << "Get all tracks..." << std::endl; std::vector<Line> get_tracks = sdp.getLines(ArtifactUsageVirtualTrack); for (std::vector<Line>::iterator it = get_tracks.begin() ; it != get_tracks.end(); ++it) { std::cout << "ID: " << it->id() << std::endl; std::cout << "Start from (" << it->startP().x() << " , " << it->startP().y() << ") " << "to (" << it->endP().x() << " , " << it->endP().y() << " ) " << std::endl; } std::cout << "Delete track by ID, please enter track ID:" << std::endl; int id; bool is_found = false; std::cin >> id ; for (std::vector<Line>::iterator it = get_tracks.begin() ; it != get_tracks.end(); ++it) { if (id == it->id()) { sdp.removeLineById(ArtifactUsageVirtualTrack, id); is_found = true; break; } } if(!is_found) std::cout << "Wrong ID" << std::endl; |