anyKode Marilou
ContentsIndexHome
PreviousUpNext
TraceDisplay

Geometry's TraceDisplay.

C++
class TraceDisplay : public ModaEntity;

ModaCpp.h

TraceDisplay creates and controls parent geometry's trace in the simulator. TraceDisplay object must be created by using Geom::CreateTraceDisplay function. 

 

TraceDisplay functions call locks the simulator in order to manage 3D objects: that's mean that the MODA application (the caller) remains locked for several milli-seconds awaiting the simulator response. You should not invoke TraceDisplay functions into a robotics loop. 

 

 

//From [samples/simple/7.0_TraceDisplay] directory

#include "stdafx.h"
#include "Modacpp.h"
#include "conio.h"

#define MODASERVER "localhost"

using namespace ModaCPP;

//--------------------------------------------------
TraceDisplay * ConfigureTraceDisplay(Geom *pGeom)
    {
    TraceDisplay *pRet=NULL;
    if(pGeom)
        {
        pRet=pGeom->CreateTraceDisplay();
        }
    return(pRet);
    }

//--------------------------------------------------
int main(int argc, char* argv[])
{
Connection *pConnection=new Connection(true);

//Try connect to MODA server
if(pConnection->Connect(MODASERVER))
    {
    _cprintf("Connection ok to moda server\r\n");
    //Find the robot
    RobotPHX *pWorld=pConnection->QueryWorld();
    if(pWorld)
        {
        _cprintf("world found\r\n");

        Geom *pSphere=pWorld->QueryGeom("/sphere0");
        ConfigureTraceDisplay(pSphere);

        pSphere=pWorld->QueryGeom("/sphere1");
        ConfigureTraceDisplay(pSphere);

        pSphere=pWorld->QueryGeom("/sphere2");
        TraceDisplay *pTrace=ConfigureTraceDisplay(pSphere);

        Moda::Commons::TraceDisplayOptions opts;
        if(pTrace->GetOptions(&opts))
            {
            opts.SetColorRGBA(255,0,0,255);
            opts.UpdateDelay=100;
            pTrace->SetOptions(&opts);
            }

        while(!_kbhit())
            {
            pWorld->Sleep(500);
            }

        //destroy the path in the simulator
        pTrace->Destroy();
        //delete the C++ object
        delete pTrace;
        }
    else
        {
        _cprintf("robot not found\r\n");
        }
    }
else
    {
    _cprintf("Unable to connect to moda server\r\n");
    }
//Disconnect & delete
pConnection->Disconnect();
delete pConnection;
return 0;
}
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!