Excerpt |
---|
This document introduces the demo project of "move_to_spot", including how to move in standard mode and virtual track mode. |
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 "move_to_spot" project, set as StartUp project.
Right click on "move_to_spot",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 path of SDK.
- Right click on "move_to_spot",set "Command Arguments" as follows:
Syntax Description:move_to_spot <IP address> - Click " F5" to execute.
- Robot motion and map could be seen on Robostudio.
Multimedia name bandicam 2018-01-30 15-29-41-992.mp4
Code
Robot moves firstly to point(2, 0) in standard mode, and then back to point (0,0) in virtual track mode, if any obstacle is detected, it will be automatically avoided with the standard mode or it will stops on virtual tracks on virtual track mode.
Code Block language cpp firstline 1 title 导航到目标点 linenumbers true SlamwareCorePlatform sdp = SlamwareCorePlatform::connect(argv[1], 1445); std::cout <<"SDK Version: " << sdp.getSDKVersion() << std::endl; std::cout <<"SDP Version: " << sdp.getSDPVersion() << std::endl; rpos::actions::MoveAction action = sdp.getCurrentAction(); if (action) action.cancel(); //move to location (2, 0), not on virtual track rpos::features::motion_planner::MoveOptions options; options.flag = MoveOptionFlag(MoveOptionFlagMilestone | MoveOptionFlagPrecise); action = sdp.moveTo(rpos::core::Location(2, 0), options); action.waitUntilDone(); if (action.getStatus() == rpos::core::ActionStatusError) std::cout << "Action Failed: " << action.getReason() << std::endl; //draw a virtual track from (0, 0) to (2, 0), then move to (0, 0) via virtual track rpos::core::Line line(rpos::core::Point(0,0),rpos::core::Point(2,0)); sdp.addLine(ArtifactUsageVirtualTrack, line); options.flag = MoveOptionFlag(MoveOptionFlagKeyPoints | MoveOptionFlagPrecise); action = sdp.moveTo(rpos::core::Location(0, 0), options); action.waitUntilDone(); if (action.getStatus() == rpos::core::ActionStatusError) std::cout << "Action Failed: " << action.getReason() << std::endl;