Raisim Sever

RaisimServer serializes raisim::World and streams the data to clients via tcp/ip. We provide the raisimUnity (doc) client, which visualizes a raisim World. The basic usage is described in the doc.

Other than just visualizing a raisim world, RaisimSever can visualize additional visual objects. An example can be found here. The example will be displayed as following

../_images/visuals.gif

RaisimSever API

class raisim::RaisimServer

Public Functions

RaisimServer(World *world)

Parameters
  • [in] world: the world to visualize. create a raisimSever for a world.

void launchServer(int port = 8080)

Parameters
  • [in] port: port number to stream start spinning.

void integrateWorldThreadSafe()

set the world mutex. This will prevent visualization thread reading from the world (otherwise, there can be a segfault). Integrate the world.

void hibernate()

hibernate the server. This will stop the server spinning.

void wakeup()

wake up the server. Restart the server from hibernation

void killServer()

stop spinning the server and disconnect the client

void informClientForUpdate()

currently not used

void lockVisualizationServerMutex()

lock the visualization mutex so that the server cannot read from the world

void unlockVisualizationServerMutex()

unlock the visualization mutex so that the server can read from the world

ArticulatedSystemVisual *addVisualArticulatedSystem(const std::string &name, const std::string &urdfFile, double colorR = 0, double colorG = 0, double colorB = 0, double colorA = 0)

Return

the articulated system visual pointer add a sphere without physics

Parameters
  • [in] name: the name of the visual articulated system object

  • [in] urdfFile: the path to the urdf file

  • [in] colorR: the red value of the color (max=1)

  • [in] colorG: the green value of the color (max=1)

  • [in] colorB: the blue value of the color (max=1)

  • [in] colorA: the alpha value of the color (max=1)

Visuals *addVisualSphere(const std::string &name, double radius, double colorR = 1, double colorG = 1, double colorB = 1, double colorA = 1, const std::string &material = "", bool glow = false, bool shadow = false)

Return

the sphere pointer add a sphere without physics

Parameters
  • [in] name: the name of the visual object

  • [in] radius: radius of the sphere

  • [in] colorR: the red value of the color (max=1)

  • [in] colorG: the green value of the color (max=1)

  • [in] colorB: the blue value of the color (max=1)

  • [in] colorA: the alpha value of the color (max=1)

  • [in] material: visualization material

  • [in] glow: to glow or not

  • [in] shadow: to cast shadow or not

Visuals *addVisualBox(const std::string &name, double xLength, double yLength, double zLength, double colorR = 1, double colorG = 1, double colorB = 1, double colorA = 1, const std::string &material = "", bool glow = false, bool shadow = false)

Return

the box pointer add a box without physics

Parameters
  • [in] name: the name of the visual object

  • [in] xLength: length of the box

  • [in] yLength: width of the box

  • [in] zLength: height of the box

  • [in] colorR: the red value of the color (max=1)

  • [in] colorG: the green value of the color (max=1)

  • [in] colorB: the blue value of the color (max=1)

  • [in] colorA: the alpha value of the color (max=1)

  • [in] material: visualization material

  • [in] glow: to glow or not

  • [in] shadow: to cast shadow or not

Visuals *addVisualCylinder(const std::string &name, double radius, double length, double colorR = 1, double colorG = 1, double colorB = 1, double colorA = 1, const std::string &material = "", bool glow = false, bool shadow = false)

Return

the cylinder pointer add a cylinder without physics

Parameters
  • [in] name: the name of the visual object

  • [in] radius: radius of the cylinder

  • [in] length: length of the cylinder

  • [in] colorR: the red value of the color (max=1)

  • [in] colorG: the green value of the color (max=1)

  • [in] colorB: the blue value of the color (max=1)

  • [in] colorA: the alpha value of the color (max=1)

  • [in] material: visualization material

  • [in] glow: to glow or not

  • [in] shadow: to cast shadow or not

Visuals *addVisualCapsule(const std::string &name, double radius, double length, double colorR = 1, double colorG = 1, double colorB = 1, double colorA = 1, const std::string &material = "", bool glow = false, bool shadow = false)

Return

the capsule pointer add a capsule without physics

Parameters
  • [in] name: the name of the visual object

  • [in] radius: radius of the capsule

  • [in] length: length of the capsule

  • [in] colorR: the red value of the color (max=1)

  • [in] colorG: the green value of the color (max=1)

  • [in] colorB: the blue value of the color (max=1)

  • [in] colorA: the alpha value of the color (max=1)

  • [in] material: visualization material

  • [in] glow: to glow or not

  • [in] shadow: to cast shadow or not

PolyLine *addVisualPolyLine(const std::string &name)

Return

the polyline pointer add a polyline without physics

Parameters
  • [in] name: the name of the polyline

PolyLine *getVisualPolyLine(const std::string &name)

Parameters
  • [in] name: the name of the polyline get visualized polyline

ArticulatedSystemVisual *getVisualArticulatedSystem(const std::string &name)

Parameters
  • [in] name: the name of the visual articulated system get visualized articulated system

void removeVisualPolyLine(const std::string &name)

Parameters
  • [in] name: the name of the polyline to be removed remove an existing polyline

Visuals *getVisualObject(const std::string &name)

Return

visual object with a specified name retrieve a visual object with a specified name

Parameters
  • [in] name: the name of the visual object to be retrieved

void removeVisualObject(const std::string &name)

Parameters
  • [in] name: the name of the visual object to be removed remove an existing visual object

void startRecordingVideo(const std::string &videoName)

Parameters
  • [in] videoName: name of the video file to be saved. The videoName must be a valid file name (e.g., no spaces, ending in .mp4) start recording video. RaisimUnity only supports video recording in linux

void stopRecordingVideo()

stop recording video

void setCameraPositionAndLookAt(const Eigen::Vector3d &pos, const Eigen::Vector3d &lookAt)

Parameters
  • [in] pos: the position of the camera

  • [in] lookAt: the forward direction of the camera (the up direction is always z-axis) set the camera to a specified position

void focusOn(raisim::Object *obj)

Parameters
  • [in] obj: the object to look at move the camera to look at the specified object

bool isConnected() const

Return

if a client is connected to a server check if a client is connected to a server

Visuals API

struct raisim::Visuals

Public Functions

void setSphereSize(double radius)

Parameters
  • [in] radius: the raidus of the sphere. set size of the sphere.

void setBoxSize(double x, double y, double z)

Parameters
  • [in] x: length.

  • [in] y: width.

  • [in] z: height. set size of the box.

void setCylinderSize(double radius, double height)

Parameters
  • [in] radius: the raidus of the cylinder.

  • [in] height: the height of the cylinder. set size of the cylinder.

void setCapsuleSize(double radius, double height)

Parameters
  • [in] radius: the raidus of the capsule.

  • [in] height: the height of the capsule. set size of the capsule.

void setPosition(double x, double y, double z)

Parameters
  • [in] x: x coordinate of the visual object.

  • [in] y: y coordinate of the visual object.

  • [in] z: z coordinate of the visual object. set the position of the visual object.

void setOrientation(double w, double x, double y, double z)

Parameters
  • [in] w: angle part of the quaternion.

  • [in] x: scaled x coordinate of the rotation axis.

  • [in] y: scaled y coordinate of the rotation axis.

  • [in] z: scaled z coordinate of the rotation axis. set the orientation of the visual object.

void setPosition(const Eigen::Vector3d &pos)

Parameters
  • [in] pos: position of the visual object in Eigen::Vector3d. set the position of the visual object.

void setOrientation(const Eigen::Vector4d &ori)

Parameters
  • [in] ori: quaternion of the visual object in Eigen::Vector4d. set the orientation of the visual object.

void setColor(double r, double g, double b, double a)

Parameters
  • [in] r: red value of the color (max=1).

  • [in] g: green value of the color (max=1).

  • [in] b: blue value of the color (max=1).

  • [in] a: alpha value of the color (max=1). set the color of the visual object.

Eigen::Vector3d getPosition()

Return

the position of the visual object. get the position of the visual object.

Eigen::Vector4d getOrientation()

Return

the orientation of the visual object. get the orientation of the visual object.

Polyline API

struct raisim::PolyLine

Public Functions

void setColor(double r, double g, double b, double a)

Parameters
  • [in] r: red value of the color (max=1).

  • [in] g: green value of the color (max=1).

  • [in] b: blue value of the color (max=1).

  • [in] a: alpha value of the color (max=1). set the color of the polyline.

void addPoint(const Eigen::Vector3d &point)

Parameters
  • [in] point: new polyline point. append a new point to the polyline.

void clearPoints()

clear all polyline points.

ArticulatedSystemVisual API

struct raisim::ArticulatedSystemVisual

Public Functions

void setColor(double r, double g, double b, double a)

Parameters
  • [in] r: red value (max 1)

  • [in] g: green value (max 1)

  • [in] b: blue value (max 1)

  • [in] a: alpha value (max 1) set color. if the alpha value is 0, it uses the original color defined in the mesh file

void setGeneralizedCoordinate(const Eigen::VectorXd &gc)

Parameters
  • [in] gc: the generalized coordinate (max 1) set the configuration of the visualized articulated system