anyKode Marilou
|
Servo-motors management.
class DeviceServoMotor : public DeviceMotor;
ModaCpp.h
The DeviceServoMotor class cannot be created directly by user : it must be obtained by QueryDeviceServoMotor of the class RobotPHX.
The various parameters given to the functions can be interpreted and modified if necessary by the device in order to respect the constraints imposed in modeling.
//Sample Samples/Devices/ServoMotor/C++ #include "ModaCpp.h" #include "conio.h" //Settings: #define MODASERVER "localhost" int main(int argc, char* argv[]) { ModaCPP::Connection *connection=new ModaCPP::Connection(true); //Connect to MODA server if(connection->Connect(MODASERVER)) { _cprintf("Connexion to %s ok\r\n",MODASERVER); //Find the robot ModaCPP::RobotPHX *robot=connection->QueryRobotPHX("/"); if(robot) { _cprintf("robot found in this world\r\n"); ModaCPP::DeviceServoMotor *pServo1=robot->QueryDeviceServoMotor("hinge2/axisred/servo"); ModaCPP::DeviceServoMotor *pServo2=robot->QueryDeviceServoMotor("hinge2/axisgreen/servo"); if(pServo1 && pServo2) { float deg=0; while(!_kbhit()) { pServo1->GoPositionDeg(-90); connection->Sleep(2000); pServo1->GoPositionDeg(90); connection->Sleep(2000); pServo1->GoPositionDeg(0); connection->Sleep(2000); deg+=90; pServo2->GoPositionDeg(deg); connection->Sleep(2000); } delete pServo1; delete pServo2; } else { _cprintf("servo(s) not found ...\r\n"); } delete robot; } else { _cprintf("robot not found in this world\r\n"); } } else { _cprintf("Unable to connect to moda server : be sure Exec is running and MODA TCP/UDP ports are open\r\n"); } connection->Disconnect(); delete connection; return 0; }
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
|
What do you think about this topic? Send feedback!
|