This document introduces the demo project of "speed_regulation", including how to call the setsystemparameter() API to regulate the speed.


Content


IDE Preperation

  • Software

    • Visual Studio 2010  SP1
    • Slamware Windows SDK:Slamware Windows SDK
    • RoboStudio(for map display):Robostudio installer 
    • Sample Code: 

      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

Win32-Demo



Compiling

  1. Right click on "speed_regulation" project, set as StartUp project.

  2. Right click on " speed_regulation ", then " Properties",configure "include" and "lib" directories to the corresponding folder path of Slamware SDK.

    It's not necessary to copy files to the project directory, user will only need to configure the path of SDK.




  3. Right click on " speed_regulation ", then "properties",set "Command Arguments" as follows:  
    Syntax :speed_regulation <IP address>> 

  4. Click " F5" to execute.
  5. Robot's motion could be seen in Robostudio.

Code

  • The robot will move around on the three sides of the triangle at low, medium and high speeds. The speed depends on the slamcore firmware setting. The official firmware is set to 0.15m/s 0.25m/s 0.35m/s.

    Speed Regulation
     		SlamwareCorePlatform sdp = SlamwareCorePlatform::connect(ip_address, 1445);
    		std::cout <<"SDK Version: " << sdp.getSDKVersion() << std::endl;
    		std::cout <<"SDP Version: " << sdp.getSDPVersion() << std::endl;
    		rpos::actions::MoveAction action = sdp.getCurrentAction();
    		
    		rpos::core::Location location1(1,0);
    		rpos::core::Location location2(-1,0);
    		rpos::core::Location location3(0,1.414);
    		while (true)
    		{
    			if (action)
    				action.cancel();
    
    			action = sdp.moveTo(location1, false,true);
    			if (action.getStatus() == rpos::core::ActionStatusError)
    				std::cout << "Action Failed: " << action.getReason() << std::endl;
    			bool bRet2 =sdp.setSystemParameter(SYSPARAM_ROBOT_SPEED, SYSVAL_ROBOT_SPEED_HIGH);
    			std::cout <<"Robot is moving to: (" << location1.x() <<" , "<<location1.y()<<") on speed"<< " HIGH( 0.35m/s )" << std::endl;
    			action.waitUntilDone();
    		
    		
    			action = sdp.moveTo(location2, false,true);
    			if (action.getStatus() == rpos::core::ActionStatusError)
    				std::cout << "Action Failed: " << action.getReason() << std::endl;
    			bool bRet3 =sdp.setSystemParameter(SYSPARAM_ROBOT_SPEED, SYSVAL_ROBOT_SPEED_LOW);
    			std::cout <<"Robot is moving to: (" << location2.x() <<" , "<<location2.y()<<") on speed"<< " LOW( 0.15m/s )" << std::endl;
    			action.waitUntilDone();
    		
    		
    			action = sdp.moveTo(location2, false,true);
    			if (action.getStatus() == rpos::core::ActionStatusError)
    				std::cout << "Action Failed: " << action.getReason() << std::endl;
    			bool bRet1 =sdp.setSystemParameter(SYSPARAM_ROBOT_SPEED, SYSVAL_ROBOT_SPEED_MEDIUM);
    			std::cout <<"Robot is moving to: (" << location3.x() <<" , "<<location3.y()<<") on speed"<< " MEDIUM( 0.25m/s )" << std::endl;
    			action.waitUntilDone();
    		 }
  • No labels