Excerpt |
---|
This document introduces the demo project of "go_power_status", including how to get the battery percentage and power status. |
...
Content
Table of Contents |
---|
...
IDE Preperation
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 "get_power_status" project, set as StartUp project.
Right click on "get_power_status", 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 " get_power_status ", then "properties",set "Command Arguments" as follows:
Syntax :get_power_status <IP address>> - Click " F5" to execute.
- The output from console will be as follows:
...
Code
get Get battery percentage and power status
Code Block language cpp firstline 1 title 获取电量/充电状态Get the battery percentage and power status 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; PowerStatus status = sdp.getPowerStatus(); std::cout << "Battery Percentage: " << status.batteryPercentage << std::endl; std::cout << "is Charging: " << status.isCharging << std::endl; std::cout << "is DC connected: " << status.isDCConnected << std::endl; if(status.dockingStatus == DockingStatusNotOnDock) std::cout << "Docking status: Not on dock" << std::endl; else if(status.dockingStatus == DockingStatusOnDock) std::cout << "Docking status: On dock" << std::endl; else std::cout << "Docking status: Unknown" << std::endl;