Server Example: Dzhanibekov Effect
Overview
Demonstrates the Dzhanibekov effect by spinning a box in zero gravity and visualizing the unstable rotation.
Screenshot
Binary
CMake target and executable name: dzhanibekov_effect.
Run
Build and run from your build directory:
cmake --build . --target dzhanibekov_effect
./dzhanibekov_effect
On Windows, run dzhanibekov_effect.exe instead.
This example uses RaisimServer. Start a visualizer client (RaisimUnity, RaisimUnreal, or the rayrai TCP viewer) and connect to port 8080.
Details
Simulates a freely rotating asymmetric box in zero gravity.
Shows the intermediate-axis (Dzhanibekov) flipping behavior.
Focuses the camera on the box for clear visualization.
Source
// This file is part of RaiSim. You must obtain a valid license from RaiSim Tech
// Inc. prior to usage.
#include "raisim/RaisimServer.hpp"
#include "raisim/World.hpp"
#include "rayrai_tcp_viewer_hint.hpp"
int main () {
raisim::World world;
world.setTimeStep(0.001);
raisim::RaisimServer server(&world);
world.setGravity(raisim::Vec<3>{0,0,0});
auto box = world.addBox(0.5,1,3,5);
box->setPosition(0, 0, 0);
box->setAngularVelocity(raisim::Vec<3>{0.0001,5,0});
server.launchServer();
raisim_examples::warnIfNoClientConnected(server);
server.focusOn(box);
for (int i=0; i<100000; i++) {
RS_TIMED_LOOP(1e6 * world.getTimeStep())
server.integrateWorldThreadSafe();
}
server.killServer();
return 0;
}