XML Example: World Loader
Overview
Loads a world directly from an XML file passed on the command line and runs a RaisimServer session. It also records a video, making it a reference for XML-driven scene loading and logging.
Screenshot
Binary
CMake target and executable name: xml_world_loader.
Run
Build and run from your build directory:
cmake --build . --target xml_world_loader
./xml_world_loader /full/path/to/world.xml
On Windows, run xml_world_loader.exe instead.
The XML loader expects an absolute path to the world file.
This example uses RaisimServer. Start a visualizer client (RaisimUnity, RaisimUnreal, or the rayrai TCP viewer) and connect to port 8080.
Details
Loads a world directly from an XML path provided on the command line.
Starts RaisimServer and records a video output file.
Useful as a reference for XML-driven world creation.
Source
// This file is part of RaiSim. You must obtain a valid license from RaiSim Tech
// Inc. prior to usage.
#include "raisim/World.hpp"
#include "raisim/RaisimServer.hpp"
#if WIN32
#include <timeapi.h>
#endif
int main(int argc, char* argv[]) {
auto binaryPath = raisim::Path::setFromArgv(argv[0]);
raisim::World::setActivationKey(binaryPath.getDirectory() + "\\rsc\\activation.raisim");
RSFATAL_IF(argc != 2 || !strcmp("--help", argv[1]) || !strcmp("-h", argv[1]),
"Requires the full path to the XML file as the first argument.")
std::string xmlPath = argv[1];
raisim::World world(xmlPath);
raisim::RaisimServer server(&world);
server.startRecordingVideo("heightMapUsingPng.mp4");
server.launchServer();
for (int i=0; i<10000000; i++) {
RS_TIMED_LOOP(int(world.getTimeStep()*1e6))
server.integrateWorldThreadSafe();
}
server.stopRecordingVideo();
server.killServer();
}