Overview

Here we explain how to create a view simulator client using a sample.
A sample program is in OpenHRP/sample/example/viewSimulator.
Since this sample is created based on the sample program of a scheduler, only the change portion is explained. Please read How to Create Scheduler(Ver.3.1) about a portion without explanation.

ViewSimurator

Retrieve ViewSimurator.

    ViewSimulator_var viewSimulator;
    viewSimulator = checkCorbaServer <ViewSimulator, ViewSimulator_var> ("ViewSimulator", cxt);
    
    if (CORBA::is_nil(viewSimulator)) {
        std::cerr << "viewSimulator not found" << std::endl;
        return 1;
    }

The model of a floor and a robot is registered into ViewSimurator.

    viewSimulator->registerCharacter(floor->name(), floor);
    viewSimulator->registerCharacter(body->name(), body);

Update of a view simulator

Within a simulation loop, a view simulator is updated. In this example, the data of a camera is acquired, it is thinned out and it is displaying on standard output.

    try {
        dynamicsSimulator -> getWorldState( state );
        if((int)(time*500)%30==0){
            viewSimulator->updateScene( state );
            CameraSequence_var cameras;
            viewSimulator->getCameraSequence(cameras);
            for(int k=0; klength(); k++){
                ImageData_var imageData = cameras[k]->getImageData();
                std::cout << "camera(" << k << ") ";
                for(int l=0; lfloatData.length(); l+=100)
                    std::cout <floatData[l] << " " ;
                std::cout << std::endl;
            }
        }
    } catch (CORBA::SystemException& ex) {
        return 1;
    }

Execution

  1. Start GrxUI.
  2. Execut OpenHRP/sample/controller/SamplePD/SamplePD.sh (.bat) from a command line.
  3. Execut OpenHRP/sample/example/viewSimulator/viewSimulator.sh (.bat) from a command line.

In the case of Windows, please add (OpenHRP3)/bin to PATH.