anyKode Marilou
ContentsIndexHome
Example
#include "Modacpp.h"

#define MODASERVER "localhost"
#define MYROBOTNAME    "/myrobot"

//***********************************************************
//user custom class, inherits from RobotPHX
class MyRobot:public ModaCPP::RobotPHX
    {
    private:

    public:
        MyRobot(xkode::lib::String Name):RobotPHX(Name)
            {
            //The object is not yet created and connected to the system
            //Do not use QueryDevicexxxx functions !
            }

        virtual ~MyRobot()
            {

            }

        virtual void OnStartup(void) override
            {
            //OnStartup is called automatically if robot was found
            //from a QueryRobotPHX function.

            //You can here call the QueryDevicexxxx functions
            }

        bool MoveMyRobot(float speed)
            {
            //create your own robot's functions
            return(true);
            }
    };

//***********************************************************
int main(int argc, char* argv[])
{
xkode::lib::String RobotWorldPath="/phx/myrobot0";
xkode::lib::String ModaServer="127.0.0.1";

ModaCPP::Connection *pConnection=new ModaCPP::Connection(true);
if(pConnection->Connect(ModaServer))
    {
    MyRobot *pRobot=pConnection->QueryRobotPHX2<MyRobot>(RobotWorldPath);
    if(pRobot!=NULL)
        {
        //The robot is created and all devices are valid
        //You can use devices and make your robotics loop here
        delete pRobot;
        }
    delete pConnection;
    }
_getch();
return 0;
}
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.