Server Example: Spring Damper Joints
Overview
Loads URDFs with spring and damper joints (cartpole and chain) to visualize joint compliance. This example focuses on spring-damper behavior.
Screenshot
Binary
CMake target and executable name: spring_damper_joints.
Run
Build and run from your build directory:
cmake --build . --target spring_damper_joints
./spring_damper_joints
On Windows, run spring_damper_joints.exe instead.
This example uses RaisimServer. Start a visualizer client (RaisimUnity, RaisimUnreal, or the rayrai TCP viewer) and connect to port 8080.
Details
Loads cartpole and chain URDFs with spring/damper joint parameters.
Demonstrates URDF-based joint spring/damper behavior.
Focuses on the ball-joint chain for clarity.
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(int argc, char* argv[]) {
auto binaryPath = raisim::Path::setFromArgv(argv[0]);
/// create raisim world
raisim::World world;
world.setTimeStep(0.0001);
/// create objects
world.addGround();
auto revAndPrisSpringAndDamper = world.addArticulatedSystem(binaryPath.getDirectory() + "\\rsc\\springDamper\\cartpole.urdf");
auto ballSpringAndDamper = world.addArticulatedSystem(binaryPath.getDirectory() + "\\rsc\\springDamper\\chainSpringed.urdf");
revAndPrisSpringAndDamper->setName("rev_pris_joint");
ballSpringAndDamper->setName("ball_joint");
/// launch raisim server
raisim::RaisimServer server(&world);
server.launchServer();
raisim_examples::warnIfNoClientConnected(server);
server.focusOn(ballSpringAndDamper);
for (int i=0; i<2000000; i++) {
RS_TIMED_LOOP(int(world.getTimeStep()*1e6))
server.integrateWorldThreadSafe();
}
server.killServer();
}